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
Move the WordForm closer to the middle of various clouds.
def entrench(self, cloud, paradigms, informativity, categorization, unique_base): self.entrench_word(cloud, paradigms, informativity, categorization, unique_base) self.entrench_segments(cloud)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_cloud(self):\n self.remove()\n self.min_x -= 1\n self.max_x -= 1\n self.update()", "def delete_words(self):\n self.word_1.delete(0, tk.END)\n self.word_2.delete(0, tk.END)\n self.word_3.delete(0, tk.END)\n self.word_4.delete(0, tk.END)\n sel...
[ "0.59176266", "0.5135103", "0.5036837", "0.50123316", "0.49908572", "0.49366313", "0.49278474", "0.4916772", "0.49037313", "0.4899014", "0.48803365", "0.48684108", "0.48680285", "0.48149422", "0.48149082", "0.47981972", "0.47772795", "0.47746402", "0.47744653", "0.47741532", ...
0.0
-1
Entrench at the level of the WordForm.
def entrench_word(self, cloud, paradigms, informativity, categorization, unique_base): # Entrench within the WordForm's own cloud. Iterate over positions in # the WordForm (up to three Segments). for pos, seg in enumerate(self.segments): if pos < 3: # Iterate over features. for feat in seg.features: if uniform(0, 1) < probability_of_analogy: # Collect other values of the feature across the cloud. # Since this is the WordForm's own cloud, set all the # weights to 1. wv = [(e.segments[pos].features[feat], 1) for e in cloud if e.lemma == self.lemma and e.case == self.case] # Entrench the segment based on these values. seg.entrench_feature(feat, wv, top_value = self_top_value, max_movement = self_max_movement) # Entrench within other clouds of the same paradigm. if paradigms: # Iterate over positions in the WordForm (up to three Segments). for pos, seg in enumerate(self.segments): if pos < 3: # Iterate over features. for feat in seg.features: if uniform(0, 1) < (probability_of_analogy * paradigm_weight): # Get the weight for each case. weights = dict() # If informativity is measured via the entropy # method, the weight of a case is proportional to # the entropy of the feature across all lemmas of # that case. if informativity == 'entropy': weights = {c: entropy(feat, [e.segments[pos].\ features[feat] for e in cloud if e.case == c]) for c in cases} # If informativity is measured via a classification # algorithm, the weight of a case is proportional to # the performance of the classifier on lemmas within # that case using just the current feature. elif informativity == 'classification': weights = {c: performance([e for e in cloud if e.case == c], positions = [pos], features = [feat], method = categorization) for c in cases} # If informativity is not measured, set the weights # of all cases to 1. elif informativity == 'none': weights = {c: 1 for c in cases} # If paradigms are required to have a unique base, # the winner takes all the weight. if unique_base: max_weight = max(weights.values()) for c in weights: if weights[c] < max_weight: weights[c] = 0 # Collect other values of the feature across the # cloud, and pair them with their weights. wv = [(e.segments[pos].features[feat], weights[e.case]) for e in cloud if e.lemma == self.lemma and e.case != self.case] # Entrench the segment based on these values. seg.entrench_feature(feat, wv, top_value = paradigm_top_value, max_movement = paradigm_max_movement)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _commit_level(self):\n assert self.current_level is not None, \"Cannot write a level with an empty name\"\n # Create a new level descriptor in the lump directory\n self.wad.add_lump(self.current_level, None)\n # Add the lumps to WAD file\n self.wad.add_lump('THINGS', self.lum...
[ "0.51781356", "0.5135534", "0.51090235", "0.50966406", "0.5095478", "0.5094889", "0.5074766", "0.5069701", "0.49998125", "0.49493456", "0.4920468", "0.49131694", "0.4900337", "0.48817414", "0.48688623", "0.48541382", "0.48305783", "0.48229364", "0.4820413", "0.47837245", "0.4...
0.5143527
1
Entrench at the level of the Segment.
def entrench_segments(self, cloud): # Iterate over features. for feat in all_features: if feature_type(feat) == 'continuous': # Collect all values of the feature across the cloud. values = [(s.features[feat], 1) for e in cloud for p, s in enumerate(e.segments) if p < 3 and feat in s.features] # Iterate over Segments. for pos, seg in enumerate(self.segments): if pos < 3: if uniform(0, 1) < probability_of_feat_analogy: # Entrench the feature of the Segment based on # values across the cloud. seg.entrench_feature(feat, values, top_value = segment_top_value, max_movement = segment_max_movement)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __change_level(self, level):\n self.level = level", "def upgrage_level(self):\n print('level is upgraded on one point')\n self.level += 1", "def resetSagittalSegment(self):\r\n #research\r\n profprint()\r\n sYellow = slicer.mrmlScene.GetNodeByID(\"vtkMRMLSliceNodeYellow\")\r\n...
[ "0.5834273", "0.5602306", "0.5602119", "0.55198884", "0.5512972", "0.5512972", "0.5512972", "0.5404156", "0.53947735", "0.5348047", "0.5295594", "0.52906436", "0.52568555", "0.52522296", "0.5250421", "0.5206884", "0.52009", "0.5166423", "0.5164569", "0.51151156", "0.5082658",...
0.52542055
13
Add noise to the nonsuffix segments in the WordForm.
def add_noise(self): self.segments = deepcopy(self.segments) # Iterate through each of the first three Segments in the WordForm. for i in range(3): # Add noise to each Segment. self.segments[i].add_noise()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_noise(self, words, lengths):\n words, lengths = self.word_shuffle(words, lengths)\n words, lengths = self.word_dropout(words, lengths)\n # words, lengths = self.word_blank(words, lengths)\n return words, lengths", "def add_noise(self, data):", "def remove_noise(text):\n\n ...
[ "0.61349237", "0.6130484", "0.60680324", "0.604623", "0.5941968", "0.58597803", "0.58269954", "0.58108455", "0.56916386", "0.56686974", "0.56611174", "0.55890733", "0.55856615", "0.55645496", "0.556166", "0.55571675", "0.5511801", "0.55111974", "0.5508282", "0.5461142", "0.54...
0.8073021
0
Add articulatory bias to the nonsuffix segments in the WordForm.
def add_bias(self, bias_types): self.segments = deepcopy(self.segments) # Add the biases specified in the argument. if bias_types['final'] and len(self.segments) == 3: self.segments[2].add_bias('voiceless') if bias_types['medial'] and len(self.segments) == 4: self.segments[2].add_bias('voiced')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_suffix(self, suffix):\n # Append the suffix vowel to this WordForm.\n self.segments.append(Segment.new_segment(suffix))", "def add_noise(self):\n self.segments = deepcopy(self.segments)\n # Iterate through each of the first three Segments in the WordForm.\n for i in ran...
[ "0.6260935", "0.6102724", "0.51479083", "0.49983943", "0.48730773", "0.48502025", "0.4801285", "0.47731313", "0.4733862", "0.47119424", "0.4682679", "0.46698153", "0.4657512", "0.46404636", "0.4629202", "0.46024075", "0.45967445", "0.45915237", "0.4586859", "0.4568321", "0.45...
0.5587445
2
Return the distance between this WordForm and the one provided.
def distance(self, wf, positions = None, features = None): dist = 0 # Iterate through positions in the WordForm. for position in range(3): if positions == None or position in positions: if self.segments[position].seg_type == wf.segments[position].\ seg_type: # Use the WordForm's Segment to determine the possible # features of Segments in this position. for feature in self.segments[position].possible_features(): if features == None or feature in features: my_value = self.segments[position].\ get_feature_value(feature) comp_value = wf.segments[position].\ get_feature_value(feature) dist += abs(feature_distance(feature, my_value, comp_value)) else: return 100 return dist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distance(self):\n return self.value * len(self.alignment.query)", "def distance(self):\n return self._distance", "def distance(self) -> int:\n return 0", "def distance(self) -> float:\n return self._dist_two_wire() # at this time we only support 2-wire meausre", "def get_di...
[ "0.7310629", "0.7117631", "0.7048731", "0.7045804", "0.6998764", "0.69940305", "0.68218845", "0.66140974", "0.66028076", "0.65679866", "0.6541728", "0.6533054", "0.65226877", "0.65203345", "0.6491885", "0.6491787", "0.6487429", "0.6487429", "0.6478075", "0.6459302", "0.644873...
0.6702924
7
Return the similarity between this WordForm and the one provided.
def similarity(self, wf, positions = None, features = None): # The similarity is the inverse square of the distance between the two # WordForms. Impose a minimum on distances (to deal with zero). dist = self.distance(wf, positions = positions, features = features) if dist < .1: dist = .1 sim = 1 / (dist ** 2) return sim
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wordSimilarityRatio(sent_1,sent_2):", "def similarity(self, w1, w2):\r\n return self.represent(w1).dot(self.represent(w2))", "def similarity(self, w1, w2):\r\n return self.represent(w1).dot(self.represent(w2))", "def similarity(self, word1, word2):\n common_vect = +np.ones(self.nEmbe...
[ "0.7596557", "0.747573", "0.747573", "0.7371653", "0.73133916", "0.7294227", "0.72550523", "0.71882695", "0.71096104", "0.70324767", "0.7010185", "0.6944519", "0.692075", "0.6890939", "0.6874697", "0.68725497", "0.67834336", "0.67505664", "0.6722828", "0.6527661", "0.6500944"...
0.76069194
0
Return just the surface representation of the WordForm.
def sr(self): return ''.join([str(seg) for seg in self.segments])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def surface(self):\n return BRep_Tool_Surface(self.topods_shape())", "def get_preview(self, obj):\n\n return obj.cwr", "def get_preview(self, obj):\n\n return obj.cwr", "def exposedSurf(self):\n if self.precision:\n h = self.evaluations.exposedWing.edges[1].point1.x # ...
[ "0.60465777", "0.5572003", "0.5572003", "0.55544156", "0.5375487", "0.5374577", "0.52845716", "0.5260148", "0.5204533", "0.5131466", "0.5076054", "0.504823", "0.5015482", "0.50128734", "0.4972725", "0.4963215", "0.49538532", "0.4942636", "0.49395669", "0.49350926", "0.4928940...
0.0
-1
Return the number of segments in this WordForm.
def __len__(self): return len(self.segments)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def segment_n(self):\n return len(self.segment_lengths)", "def numSegments(self):\n\n return self.getHierView().numSegments()", "def getSegmentCount(self) -> int:\n ...", "def calculate_number_of_segments(self):\n return sum(len(eg.transcript_file.segments) for eg in self.exemplar...
[ "0.80350745", "0.7816462", "0.7777629", "0.76368123", "0.7336316", "0.7148496", "0.7035357", "0.6993581", "0.6829113", "0.6728645", "0.6592498", "0.6582837", "0.65064055", "0.6500765", "0.6491579", "0.6489725", "0.6485269", "0.64289606", "0.6355083", "0.6320407", "0.63141876"...
0.7166042
5
Given an Frame object, will return the bytes of that Frame's file. If provided, will also scale the size of the image and convert to the required format.
def convert_frames(frame, img_format: str, scale=None) -> bytes: path = frame.filename with open(path, "rb") as image_file: im = Image.open(image_file) converted_img = BytesIO() if scale: _LOGGER.debug("Scaling the image") (width, height) = (int(im.width * scale), int(im.height * scale)) _LOGGER.debug("Original size is {}wx{}h, new size is {}wx{}h".format(im.width, im.height, width, height)) im = im.resize([width, height]) im.save(converted_img, img_format) return converted_img.getvalue()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to_image(self, frame, base64_encode=False):\n #NOTE: tuple (85010, 1) ndarray --> data reduction\n img_buf_arr = cv2.imencode(\".jpeg\", frame)[1]\n if base64_encode:\n img_buf_arr = b\"data:image/jpeg;base64,\" + base64.b64encode(img_buf_arr)\n return img_buf...
[ "0.5845967", "0.5829252", "0.568239", "0.5598484", "0.5597409", "0.5580428", "0.5558993", "0.55013925", "0.54556245", "0.54468995", "0.54443717", "0.54354507", "0.54354507", "0.54297215", "0.5396869", "0.5359741", "0.5324554", "0.5318987", "0.53071946", "0.53018034", "0.52503...
0.7540226
0
Given a dictionary, converts both the keys and values of it to string and returns it.
def stringify_dict(d: dict) -> dict: return {str(key): str(value) for key, value in d.items()}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keys2string(dictionary):\r\n if not isinstance(dictionary, dict):\r\n return dictionary\r\n return dict((str(k), keys2string(v)) \r\n for k, v in dictionary.items())", "def convert_keys_to_string(dictionary):\n if not isinstance(dictionary, dict):\n return dictionary\n return...
[ "0.8282609", "0.8013096", "0.79114354", "0.7898864", "0.7838265", "0.77222395", "0.7700551", "0.75931054", "0.75236297", "0.74511623", "0.7303022", "0.727308", "0.70777315", "0.6990856", "0.69411385", "0.68564725", "0.6851728", "0.68371916", "0.6835815", "0.6810409", "0.67745...
0.72467685
12
Given a dictionary, changes the key from snake case to lower camel case.
def lower_camel_casify_dict_keys(d: dict) -> dict: return {to_camel_case(key): value for key, value in d.items()}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transform_from_camelcase(key):\n s1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', key)\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', s1).lower()", "def transform_to_camelcase(key):\n return Jsonifiable.lower_first(\n ''.join(c.capitalize() or '_' for c in key.split('_')))", "def convert_dict_...
[ "0.7801124", "0.77649593", "0.77066845", "0.7620036", "0.7379338", "0.7279606", "0.71873266", "0.71728736", "0.7140577", "0.70116407", "0.69478273", "0.69024104", "0.68458456", "0.6818799", "0.6726056", "0.67258394", "0.6712159", "0.6710847", "0.67080796", "0.6662867", "0.659...
0.7839561
0
Ensure IPCMessageSubscriber.connect gets wrapped by salt.utils.asynchronous.SyncWrapper.
async def test_ipc_connect_sync_wrapped(io_loop, tmp_path): if salt.utils.platform.is_windows(): socket_path = ports.get_unused_localhost_port() else: socket_path = str(tmp_path / "noexist.ipc") subscriber = salt.utils.asynchronous.SyncWrapper( salt.transport.ipc.IPCMessageSubscriber, args=(socket_path,), kwargs={"io_loop": io_loop}, loop_kwarg="io_loop", ) with pytest.raises(tornado.iostream.StreamClosedError): # Don't `await subscriber.connect()`, that's the purpose of the SyncWrapper subscriber.connect()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sync_connect(self):\n loop = asyncio.get_event_loop()\n task = loop.create_task(self.connect())\n loop.run_until_complete(task)", "async def _connect(self):\n pass", "async def connect(self):\n raise NotImplementedError", "async def on_connect(self) -> None:", "async ...
[ "0.65937483", "0.6521959", "0.6248328", "0.60831505", "0.6030129", "0.6018049", "0.58920634", "0.58730686", "0.58308804", "0.5825015", "0.58228856", "0.5811319", "0.58058876", "0.57596046", "0.57403564", "0.5738906", "0.5736388", "0.5714165", "0.5698439", "0.5685224", "0.5668...
0.7188033
0
Receives a list and a search term. Use a loop to go through the list and see if the string is there. if it is return "string found". if not, return "string not found"
def search_for_string(lst_str, stringy): if stringy in lst_str: return "Found string" else: return "string not found"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_by_contains(self, tl):\n print(\"Search by string\")\n string = input(\"Please enter search string: \")\n return tl.findall_contains(string)", "def search(self, q):\n for x in self.strings:\n if q in x:\n return True\n \n return ...
[ "0.7277806", "0.7085442", "0.70570374", "0.7042019", "0.6853034", "0.68284607", "0.6799059", "0.6741653", "0.67367554", "0.6710084", "0.6704459", "0.6700498", "0.65898585", "0.65151054", "0.6475276", "0.6447157", "0.64241886", "0.6397633", "0.6358592", "0.6356772", "0.6352888...
0.8100969
0
expression = andExpr { "or" andExpr }
def expression( ):#DOUBLE CHECK THIS tok = tokens.peek( ) if debug: print("Expression: ", tok) left = andExpr( ) #does the left side of the grammar tok = tokens.peek( ) while tok == "or": #checks to see if there is the token or and will preform what is inside the curly bracket since it is a series tokens.next() right = andExpr( ) left = BinaryExpr(tok, left, right) # MIGHT HAVE TO CHANGE THIS TO STRING CAUSE ITS "or" tok = tokens.peek( ) return left
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_expression_and_or(self):\n\n # Checks several examples with \"and\" and \"or\" operators\n expression = BooleanExpression(\"NORMAL\", or_(and_(models.Network.label != \"network_3\", models.Network.multi_host == True), models.Network.label == \"network_3\"))\n value = expression.evalua...
[ "0.74250734", "0.72573024", "0.7222321", "0.7148551", "0.71077687", "0.7057985", "0.6887752", "0.6887752", "0.6884606", "0.68829834", "0.68762136", "0.68715703", "0.68482435", "0.68293345", "0.67756486", "0.6733616", "0.671462", "0.6710137", "0.67097753", "0.6688344", "0.6681...
0.6960249
6
andExpr = relationalExpr { "and" relationalExpr }
def andExpr( ): #DOUBLE CHECK THIS tok = tokens.peek( ) if debug: print("andExpr: ", tok) left = relationalExpr( ) #does the left side of the grammar tok = tokens.peek( ) while tok == "and": #checks to see if there is the token "and" and will preform what is inside the curly bracket since it is a series tokens.next() right = relationalExpr( ) left = BinaryExpr(tok, left, right)#MIGHT HAVE TO CHANGE TO STRING tok = tokens.peek( ) return left
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AND(*expressions):\n return {'$and': list(expressions)}", "def __and__(self, query):\r\n return And([self, query]).normalize()", "def and_(a, b):", "def And(*conditions):\n def andPred(db):\n from functools import reduce\n return reduce(lambda result, c: c(result),\n ...
[ "0.7694933", "0.7391504", "0.7278942", "0.72714126", "0.72140443", "0.71525294", "0.71054393", "0.7005105", "0.6971053", "0.6965941", "0.69083124", "0.68721735", "0.68457156", "0.68190354", "0.6809348", "0.6774739", "0.67718345", "0.6753265", "0.6741417", "0.67354465", "0.670...
0.8083135
0
relationalExpr = addExpr [ relation addExpr ]
def relationalExpr( ):#MAKE SURE I USED THE RIGHT LOGIC FOR THIS tok = tokens.peek( ) if debug: print("relationalExpr: ", tok) left = addExpr( ) expr = "" tok = tokens.peek( ) if tok in relations: rel = relation( ) # expecting a relation to start off right = expression( ) # if there is a relation we expect there to be an expression to the right of the relation expr = BinaryExpr( rel, left, right ) return expr #fix this for syntax tree maybe return left
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_relation(wn, source, target, new_rel, change_list=None):\n insert_rel(source, new_rel, target, change_list)\n if new_rel in inverse_synset_rels:\n inv_rel_type = inverse_synset_rels[new_rel]\n insert_rel(target, inv_rel_type, source, change_list)", "def addExpr( ):\n\n\ttok = tokens.p...
[ "0.6230691", "0.61780995", "0.60156584", "0.590059", "0.58807737", "0.5856698", "0.5843209", "0.58185554", "0.5784956", "0.5745773", "0.57166684", "0.5676181", "0.5653579", "0.5636797", "0.5615812", "0.5576591", "0.5564806", "0.5537048", "0.55229557", "0.5472008", "0.54082906...
0.7208437
0
factor = number | '(' expression ')'
def factor( ): tok = tokens.peek( ) if debug: print ("Factor: ", tok) if re.match( Lexer.number, tok ): expr = Number(tok) tokens.next( ) tok = tokens.peek( ) return expr if tok == "(": tokens.next( ) # or match( tok ) expr = addExpr( )#might need to change to expression( ) tokens.peek( ) tok = match( ")" ) return expr if re.match( Lexer.identifier, tok ): # added this to take into accout identifiers expr = VarRef(tok) tokens.next( ) return expr if re.match( Lexer.String, tok ): # added this to take into account strings expr = String( tok ) return expr error( "Invalid operand" ) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _num_factor(number, factor):\n assert factor != 0\n return number // factor", "def make_multiplier(factor):\n return lambda x: factor * x", "def make_anonymous_factorial():\n return 'YOUR_EXPRESSION_HERE'", "def make_anonymous_factorial():\n return 'YOUR_EXPRESSION_HERE'", "def make_anon...
[ "0.65296596", "0.6441182", "0.641148", "0.641148", "0.641148", "0.641148", "0.63577914", "0.60211015", "0.5988639", "0.5983069", "0.59670454", "0.5808318", "0.5783513", "0.57786024", "0.57604265", "0.5731007", "0.5716077", "0.57154644", "0.5681956", "0.5650473", "0.56236184",...
0.74144316
0
term = factor { ('' | '/') factor }
def term( ): tok = tokens.peek( ) if debug: print ("Term: ", tok) left = factor( ) tok = tokens.peek( ) while tok == "*" or tok == "/": tokens.next() right = factor( ) left = BinaryExpr( tok, left, right ) tok = tokens.peek( ) return left
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visit_term(self, node, children):\n if self.debug:\n print(\"Term {}\".format(children))\n term = children[0]\n for i in range(2, len(children), 2):\n if children[i-1] == \"*\":\n term *= children[i]\n else:\n term /= children[...
[ "0.6671328", "0.5942621", "0.578661", "0.5665476", "0.5546639", "0.55136436", "0.55068946", "0.5483381", "0.5461509", "0.5405435", "0.53730965", "0.5351918", "0.5335714", "0.5334143", "0.5312731", "0.5308194", "0.52843577", "0.52693665", "0.52682096", "0.52596307", "0.5258266...
0.7452738
0
addExpr = term { ('+' | '') term }
def addExpr( ): tok = tokens.peek( ) if debug: print ("addExpr: ", tok) left = term( ) tok = tokens.peek( ) while tok == "+" or tok == "-": tokens.next() right = term( ) left = BinaryExpr( tok, left, right ) tok = tokens.peek( ) return left
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(text):\n orig = dispb[\"text\"]\n new = orig + text\n ops = [\"+\",\"-\",\"*\",\"/\"]\n # conditions\n # length 21\n if len(new) > 21:\n dispb[\"text\"] = orig\n return 0\n \n # one calc at a time\n if len(orig) > 0:\n if (orig[-1] in ops) & (text in ops):\n ...
[ "0.6888404", "0.63378376", "0.63330656", "0.6294168", "0.6236394", "0.6221723", "0.6219546", "0.6147867", "0.61287045", "0.6115096", "0.60734725", "0.60724515", "0.60708827", "0.6070692", "0.60704505", "0.60387814", "0.60252726", "0.5984255", "0.5975357", "0.5954446", "0.5949...
0.8184933
0
whileStatement = "while" expression block
def parseWhileStatement( ): # parse rountine for while and uses the while class to print out the appropriate string tok = tokens.peek( ) if debug: print( "whileStatement: ", tok ) start = match( "while" ) expr = expression( ) blk = parseBlock( ) tok = tokens.peek( ) whileString = whileStatement( start, expr, blk ) return whileString
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visit_while(self: Parser, node: doc.While) -> None:\n with self.var_table.with_frame():\n cond = self.eval_expr(node.test)\n with T.While(cond):\n self.visit_body(node.body)", "def _While(self, t):\n self.fill(\"while (\")\n self.dispatch(t.test)\n self.write(...
[ "0.806411", "0.7875308", "0.76918495", "0.7558932", "0.74995136", "0.7440557", "0.7426091", "0.73713285", "0.7269703", "0.72638226", "0.7247464", "0.7088606", "0.6975367", "0.69033563", "0.6820734", "0.68020827", "0.66737217", "0.6664865", "0.6610299", "0.6537933", "0.6398223...
0.7981215
1
ifStatement = "if" expression block [ "else" block ]
def parseIfStatement( ): # parse rountine for the if and uses the if class to print out the appropriate string tok = tokens.peek( ) if debug: print( "ifStatement: ", tok ) start = match( "if" ) expr = expression( ) blk = parseBlock( ) elseblk = None tok = tokens.peek( ) if tok == "else": match( "else" ) elseblk = parseBlock( ) return ifStatement(expr, blk, elseblk)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stmt_if(executor, stmt):\n e = Expression()\n result = e.eval(stmt._tokens, symbols=executor._symbols)\n if not result:\n executor.goto_next_line()", "def test_if_elseif_paren_statement():\n r = convert_code(\n \"{if foo}\\nbar\\n{elseif (foo and bar) or foo and (bar or (foo and bar...
[ "0.75067496", "0.71437025", "0.69992465", "0.69453186", "0.6932306", "0.6923417", "0.6896828", "0.68624914", "0.6846336", "0.68457514", "0.683607", "0.683607", "0.683607", "0.683607", "0.6810346", "0.68025327", "0.6774503", "0.6755583", "0.6644169", "0.66357064", "0.6629795",...
0.7603634
0
assign = ident "=" expression eoln
def parseAssign( ): # parse rountine for the assign and uses the assign class to print out the appropriate string tok = tokens.peek( ) if debug: print( "assign: ", tok ) if re.match( Lexer.identifier, tok ): ident = VarRef( tok ) else: error( "Invalid identifier" ) tok = tokens.next( ) equals = match( "=" ) tok = tokens.peek( ) expr = expression( ) match( ";" ) equals = VarRef( equals ) statement = assign( equals, ident, expr ) return statement
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visit_assign(self: Parser, node: doc.Assign) -> None:\n if len(node.targets) != 1:\n self.report_error(node, \"Consequential assignments like 'a = b = c' are not supported.\")\n lhs = node.targets[0]\n\n if isinstance(node.value, doc.Subscript):\n check_slices = []\n if isinstance...
[ "0.7246561", "0.6989228", "0.6973773", "0.6966724", "0.6946717", "0.6939313", "0.6896663", "0.6890361", "0.6872121", "0.67357904", "0.6725393", "0.6725393", "0.6697676", "0.66803247", "0.6641363", "0.6609404", "0.6593395", "0.65624285", "0.648081", "0.63984084", "0.638135", ...
0.74569654
0
statement = ifStatement | whileStatement | assign
def statement( ): # parse rountin for statement that makes sure the token is one of the following, eventually there will be an error caught tok = tokens.peek( ) if debug: print( "statement: ", tok ) if tok == "if": stat = parseIfStatement( ) return stat elif tok == "while": stat = parseWhileStatement( ) return stat else: stat = parseAssign( ) return stat
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stmt_if(executor, stmt):\n e = Expression()\n result = e.eval(stmt._tokens, symbols=executor._symbols)\n if not result:\n executor.goto_next_line()", "def _analyse_stmt_Assign(self, statement: ast.Assign, *, next: CFNode) -> CFNode:\n return self._ast_node(statement, next=next, error=s...
[ "0.6292355", "0.6017129", "0.58480483", "0.5790392", "0.57717943", "0.57585835", "0.5709609", "0.5649995", "0.56101805", "0.5588036", "0.5515717", "0.550607", "0.5487956", "0.5476171", "0.5472926", "0.5407076", "0.54064995", "0.54023397", "0.5397795", "0.5369516", "0.53665644...
0.635177
0
stmtList = { statement }
def stmtList( ): tok = tokens.peek( ) if debug: print( "stmtList: ", tok ) stat = statement( ) return stat
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stmts_to_stmt(statements):\n if len(statements) == 1:\n return statements[0]\n array = FakeArray(statements, arr_type=pr.Array.NOARRAY)\n return FakeStatement([array])", "def __init__(self):\n self.Statement = []", "def parseStmtList( tokens ):\n\n\ttok = tokens.peek( )\n\tast = list...
[ "0.6858657", "0.6821307", "0.6613819", "0.6559915", "0.64512044", "0.63355", "0.6250831", "0.61308306", "0.5997265", "0.58391565", "0.57354546", "0.5710025", "0.5697581", "0.567703", "0.567703", "0.5657745", "0.55945855", "0.5572425", "0.5521451", "0.5517517", "0.55145484", ...
0.8045383
0
gee = { Statement }
def parseStmtList( tokens ): tok = tokens.peek( ) ast = list( ) # list that keeps track of the all the returns from the parse rountines while tok is not None: # need to store each statement in a list statement = stmtList( ) ast.append( statement ) tok = tokens.peek( ) return ast
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.Statement = []", "def declaration(self) -> global___Statement.Declaration:", "def PolicyStatement(self) -> PolicyStatement:", "def __init__(self, grammar, trace=...):\n ...", "def Statement(self):\n t = self.token\n if t.stmt_begin:\n self._...
[ "0.6804917", "0.5830523", "0.57813966", "0.55667824", "0.554171", "0.54849756", "0.5472526", "0.5465269", "0.5427294", "0.54140335", "0.53767276", "0.53541756", "0.5350958", "0.53406405", "0.5316228", "0.53140706", "0.53092444", "0.5294509", "0.529304", "0.52851737", "0.52746...
0.0
-1
main program for testing
def main(): global debug ct = 0 for opt in sys.argv[1:]: if opt[0] != "-": break ct = ct + 1 if opt == "-d": debug = True if len(sys.argv) < 2+ct: print ("Usage: %s filename" % sys.argv[0]) return parse("".join(mklines(sys.argv[1+ct]))) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n pass", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():"...
[ "0.84278727", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", "0.8427348", ...
0.0
-1
Returns ssh username for connecting to cluster workers.
def get_ssh_user(): return getpass.getuser()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ssh_user(self):\n if self.configuration.get(\"pg_ssh_user\"):\n return \"%s@\" % self.configuration.get(\"pg_ssh_user\")\n else:\n return \"%s@\" % DEFAULT_SSH_USER", "def get_username(self) -> str:\n try:\n return self[\"user\"]\n except KeyEr...
[ "0.7331437", "0.6813522", "0.67854804", "0.67478967", "0.67478967", "0.6733212", "0.66904676", "0.66705793", "0.66705793", "0.66705793", "0.6658738", "0.66570204", "0.6605207", "0.65863043", "0.65245265", "0.6501686", "0.6480417", "0.6475567", "0.6475105", "0.64678997", "0.64...
0.72012144
1
Returns ssh key to connecting to cluster workers. If the env var TUNE_CLUSTER_SSH_KEY is provided, then this key will be used for syncing across different nodes.
def get_ssh_key(): path = os.environ.get("TUNE_CLUSTER_SSH_KEY", os.path.expanduser("~/ray_bootstrap_key.pem")) if os.path.exists(path): return path return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host_key(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"host_key\")", "def cluster_id(self) -> str:\n return pulumi.get(self, \"cluster_id\")", "def cluster_id(self) -> str:\n return pulumi.get(self, \"cluster_id\")", "def cluster_id(self) -> str:\n return ...
[ "0.63742065", "0.61436695", "0.61436695", "0.61436695", "0.61436695", "0.61436695", "0.6095634", "0.6095634", "0.6095634", "0.6095634", "0.60669327", "0.60669327", "0.60669327", "0.60669327", "0.60669327", "0.60669327", "0.60596585", "0.597747", "0.58629495", "0.58629495", "0...
0.70618993
0
writes uuids and extras of given nodes to a file (json). This is useful for import/export because currently extras are lost. Therefore this can be used to save and restore the extras on the nodes.
def export_extras(nodes, filename='node_extras.txt'): #outstring = ''#' node uuid | extras \n' outdict = {} for node in nodes: if isinstance(node, int): #pk node = load_node(node) elif isinstance(node, basestring): #uuid node = load_node(node) if not isinstance(node, Node): print('skiped node {}, is not an AiiDA node, did not know what to do.'.format(node)) continue uuid = node.uuid extras_dict = node.get_extras() outdict[uuid] = extras_dict #line = '{} | {}\n'.format(uuid, extras_dict) #outstring = outstring + line #outfile = open(filename, 'w') #outfile.write(outstring) #outfile.close() json.dump(outdict, open(filename,'w')) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_nodes(node, filename):\n\n with open(filename, 'w', newline='') as f:\n writer = csv.DictWriter(f,\n fieldnames=node[0].keys(),\n quoting=csv.QUOTE_ALL)\n writer.writeheader()\n writer.writerows(node)", "def write(node...
[ "0.6882683", "0.6683414", "0.6664386", "0.6651517", "0.664519", "0.64958185", "0.6158971", "0.5804926", "0.56545246", "0.5637596", "0.56242365", "0.5573552", "0.5563774", "0.55553705", "0.5554492", "0.5551853", "0.5548628", "0.5515836", "0.55090535", "0.5494786", "0.54754364"...
0.846316
0
reads in nodes uuids and extras from a file and aplies them to nodes in the DB. This is useful for import/export because currently extras are lost. Therefore this can be used to save and restore the extras on the nodes.
def import_extras(filename): all_extras = {} # read file #inputfile = open(filename, 'r') #lines = inputfile.readlines() #for line in lines[1:]: # splitted = line.split(' | ') # uuid = splitted[0].rstrip(' ') # extras = splitted[1].rstrip(' ') # #extras = dict(extras) # print(extras) # all_extras[uuid] = extras #inputfile.close() try: all_extras = json.load(open(filename)) except: print('The file has to be loadabel by json. i.e json format (which it is not).') for uuid, extras in all_extras.iteritems(): try: node = load_node(uuid) except: # Does not exists print('node with uuid {} does not exist in DB'.format(uuid)) node = None continue if isinstance(node, Node): node.set_extras(extras) else: print('node is not instance of an AiiDA node') #print(extras) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def export_extras(nodes, filename='node_extras.txt'):\n\n #outstring = ''#' node uuid | extras \\n'\n outdict = {}\n for node in nodes:\n if isinstance(node, int): #pk\n node = load_node(node)\n elif isinstance(node, basestring): #uuid\n node = load_node(node)\n\n ...
[ "0.673297", "0.5395848", "0.5311601", "0.5258237", "0.5242158", "0.52234995", "0.50911427", "0.5082365", "0.50697577", "0.5054883", "0.49930757", "0.4956298", "0.4920614", "0.49156678", "0.48891574", "0.4886341", "0.48851725", "0.48767012", "0.48547512", "0.4849261", "0.48488...
0.8099154
0
Delete a set of nodes. (From AiiDA cockbook)
def delete_nodes(pks_to_delete): from django.db import transaction from django.db.models import Q from aiida.backends.djsite.db import models from aiida.orm import load_node # Delete also all children of the given calculations # Here I get a set of all pks to actually delete, including # all children nodes. all_pks_to_delete = set(pks_to_delete) for pk in pks_to_delete: all_pks_to_delete.update(models.DbNode.objects.filter( parents__in=pks_to_delete).values_list('pk', flat=True)) print "I am going to delete {} nodes, including ALL THE CHILDREN".format( len(all_pks_to_delete)) print "of the nodes you specified. Do you want to continue? [y/N]" answer = raw_input() if answer.strip().lower() == 'y': # Recover the list of folders to delete before actually deleting # the nodes. I will delete the folders only later, so that if # there is a problem during the deletion of the nodes in # the DB, I don't delete the folders folders = [load_node(pk).folder for pk in all_pks_to_delete] with transaction.atomic(): # Delete all links pointing to or from a given node models.DbLink.objects.filter( Q(input__in=all_pks_to_delete) | Q(output__in=all_pks_to_delete)).delete() # now delete nodes models.DbNode.objects.filter(pk__in=all_pks_to_delete).delete() # If we are here, we managed to delete the entries from the DB. # I can now delete the folders for f in folders: f.erase()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_nodes(self, _ids):\n return self.make_request(\"POST\", \"nodes/delete\", { \"nodes\" : _ids })", "def deleteNode(*args, **kwds):\n nodes = args\n if len(args) < 1:\n nodes = cmds.ls(sl=1)\n \n for node in nodes:\n node_lst = [node]\n if isinstance(node, (list, ...
[ "0.7969933", "0.767122", "0.7110108", "0.7096792", "0.70466393", "0.6917409", "0.685601", "0.6738954", "0.6675691", "0.66630596", "0.6651388", "0.6613611", "0.66037107", "0.6587649", "0.6580377", "0.65754753", "0.6555476", "0.6534313", "0.65310407", "0.652126", "0.64312625", ...
0.69111544
6
This method deletes all AiiDA nodes in the DB, which have a extra trash=True And all their children. Could be advanced to a garbage collector. Be careful to use it.
def delete_trash(): #query db for marked trash q = QueryBuilder() nodes_to_delete_pks = [] q.append(Node, filters = {'extras.trash': {'==' : True} } ) res = q.all() for node in res: nodes_to_delete_pks.append(node[0].dbnode.pk) print('pk {}, extras {}'.format(node[0].dbnode.pk, node[0].get_extras())) #Delete the trash nodes print('deleting nodes {}'.format(nodes_to_delete_pks)) delete_nodes(nodes_to_delete_pks) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _delete_all(self):\n logging.info(\"Remove all nodes and relations from database.\")\n self.graph.delete_all()\n return", "def DeleteAllItems(self):\r\n\r\n self.DeleteRoot()", "def clear_db():\n humans = Human4j.nodes.all()\n for h in humans:\n h.delete()\n bino...
[ "0.75391054", "0.7246509", "0.6745943", "0.6743173", "0.66865116", "0.66524655", "0.6503817", "0.64772564", "0.6394675", "0.63327867", "0.6293654", "0.62701166", "0.6248863", "0.6222633", "0.6217673", "0.6183407", "0.61382097", "0.6128062", "0.61192054", "0.6104992", "0.60861...
0.7323777
1
Creates a group for a given node list. So far this is only an AiiDA verdi command.
def create_group(name, nodes, description=None): group, created = Group.get_or_create(name=name) if created: print('Group created with PK={} and name {}'.format(group.pk, group.name)) else: print('Group with name {} and pk {} already exists. Do you want to add nodes?[y/n]'.format(group.name, group.pk)) answer = raw_input() if answer.strip().lower() == 'y': pass else: return nodes2 = [] nodes2_pks = [] for node in nodes: try: node = int(node) except ValueError: pass nodes2_pks.append(node) try: nodes2.append(load_node(node)) except:# NotExistentError: pass group.add_nodes(nodes2) print('added nodes: {} to group {} {}'.format(nodes2_pks, group.name, group.pk)) if description: group.description = description return group
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_new_group(self, a, b):\n self.groups[self.group_id] = set([a,b])\n self.node_id[a] = self.node_id[b] = self.group_id\n self.group_id += 1", "def create(self, context=None):\n values = self.obj_get_changes()\n db_nodegroup = self.dbapi.create_nodegroup(values)\n ...
[ "0.7485883", "0.72396135", "0.71599764", "0.66984046", "0.66795355", "0.65447414", "0.6374939", "0.6371427", "0.63429767", "0.63429767", "0.6336112", "0.6318668", "0.631537", "0.63136333", "0.6290033", "0.6238642", "0.6233603", "0.62333775", "0.616521", "0.61182487", "0.61024...
0.7037025
3
returns a list of node uuids for a given group as, name, pk, uuid or group object
def get_nodes_from_group(group, return_format='uuid'): from aiida.orm import Group from aiida.common.exceptions import NotExistent nodes = [] g_nodes = [] try: group_pk = int(group) except ValueError: group_pk = None group_name = group if group_pk is not None: try: str_group = Group(dbgroup=group_pk) except NotExistent: str_group = None message = ('You have to provide a valid pk for a Group ' 'or a Group name. Reference key: "group".' 'given pk= {} is not a valid group' '(or is your group name integer?)'.format(group_pk)) print(message) elif group_name is not None: try: str_group = Group.get_from_string(group_name) except NotExistent: str_group = None message = ('You have to provide a valid pk for a Group or a Group name.' 'given group name= {} is not a valid group' '(or is your group name integer?)'.format(group_name)) print(message) elif isinstance(group, Group): str_group = group else: str_group = None print('I could not handle given input, either Group, pk, or group name please.') return nodes g_nodes = str_group.nodes for node in g_nodes: if return_format == 'uuid': nodes.append(node.uuid) elif return_format == 'pk': nodes.append(node.pk) return nodes
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getGroup(group: int, name=\"\") -> list:\n groups = mongo.db.groups.find({'id':group},{'_id':0})\n userID_list = []\n user_list = []\n for entry in groups:\n if entry[\"id\"] == group:\n userID_list = userID_list + entry[\"members\"]\n if len(userID_list) != 0:\n for ent...
[ "0.6142465", "0.5999166", "0.59815145", "0.58869386", "0.5741488", "0.5735394", "0.5697292", "0.5640951", "0.563847", "0.56142646", "0.55772024", "0.5554826", "0.5521682", "0.5469941", "0.5396493", "0.5393709", "0.53740793", "0.5341698", "0.5340419", "0.5333693", "0.53306866"...
0.73784983
0
Cost and time of test_fn on a given dataset section. Pass only one of `valid_feeder` or `test_feeder`. Don't pass `train_feed`.
def monitor(data_feeder): _total_time = 0. _costs = [] _data_feeder = data_feeder(BATCH_SIZE, SEQ_LEN, OVERLAP, Q_LEVELS, Q_ZERO, Q_TYPE) for _seqs, _reset, _mask in _data_feeder: _start_time = time.time() _cost = test_fn(_seqs, _mask) _total_time += time.time() - _start_time _costs.append(_cost) return numpy.mean(_costs), _total_time
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test(self, reader, feeding=None):\n import py_paddle.swig_paddle as api\n from data_feeder import DataFeeder\n feeder = DataFeeder(self.__data_types__, feeding)\n evaluator = self.__gradient_machine__.makeEvaluator()\n out_args = api.Arguments.createArguments(0)\n eval...
[ "0.6524617", "0.6314485", "0.63126904", "0.62246484", "0.61073464", "0.60626286", "0.60052073", "0.5928098", "0.5889206", "0.58809704", "0.586239", "0.5848877", "0.58438563", "0.58372283", "0.5764127", "0.5758687", "0.5740815", "0.5740264", "0.5721871", "0.5714371", "0.571391...
0.6274846
3
This creates the basic model, which needs only few adjustements by the other configurations, in order to work for other datasets and/or detection neural networks.
def base_model_config(): BASE_CONFIG_FILENAME = os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs", "base_config.json") with open(BASE_CONFIG_FILENAME, 'r') as fp: cfg = edict(json.load(fp, encoding="utf8")) return cfg
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, opt):\n BaseModel.__init__(self, opt)\n # specify the training losses you want to print out. The training/test scripts will call <BaseModel.get_current_losses>\n self.loss_names = ['D_adv','D_cls', 'G_A','G_B', 'cycle_A','G_adv','reg','idt']\n # specify the images you...
[ "0.72591865", "0.7110485", "0.7058212", "0.70567673", "0.7052484", "0.7031042", "0.7014822", "0.7008694", "0.6998083", "0.6991139", "0.6976989", "0.6958172", "0.6947366", "0.69150037", "0.69144577", "0.6914014", "0.68923914", "0.6875319", "0.6874616", "0.6869344", "0.6869033"...
0.0
-1
This function is usefull for merging basic config with external configs. External config's constants overwrite those of basic config.
def cook_config(ext_config_filename): mc = base_model_config() with open(ext_config_filename, "r") as fp: ext_mc = edict(json.load(fp, encoding="utf8")) for s in ext_mc.keys(): mc[s] = ext_mc[s] # mc.ANCHOR_BOX = set_anchors(mc) # print(np.max(np.square(np.array(set_anchors_testing(mc)) - np.array(set_anchors(mc))))) # mc.ANCHORS = len(mc.ANCHOR_BOX) # H, W, C = _get_output_shape(mc) # mc.MODEL_OUTPUT_SHAPE = [H, W, mc.ANCHOR_PER_GRID] return mc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _merge(config, env):\n if 'common' in config and env in config:\n c = config['common'].copy()\n c.update(config[env])\n elif env in config.keys():\n c = config[env]\n elif 'common' in config.keys():\n c = config['common']\n else:\n c = config\n return c", "de...
[ "0.6710672", "0.6409883", "0.6342374", "0.6342374", "0.63211066", "0.6320828", "0.6272454", "0.62308407", "0.6153629", "0.61424506", "0.6138934", "0.61278063", "0.61195934", "0.6030474", "0.6018767", "0.6000672", "0.5999597", "0.5980619", "0.5938822", "0.589723", "0.5872071",...
0.0
-1
This function returns the default anchors given the image shapes and the anchors per grid point. The grid has width and height equal to the final's layer output.
def set_anchors(mc): H, W, C = _get_output_shape(mc) B = mc.ANCHOR_PER_GRID X = np.array(mc.INITIAL_ANCHOR_SHAPES) X[:,0] *= mc.IMAGE_WIDTH X[:,1] *= mc.IMAGE_HEIGHT anchor_shapes = np.reshape( # it refers to the anchor width and height [X] * H * W, (H, W, B, 2) ) center_x = np.reshape( np.transpose( np.reshape( np.array([np.arange(1, W+1)*float(mc.IMAGE_WIDTH)/(W+1)]*H*B), (B, H, W) ), (1, 2, 0) ), (H, W, B, 1) ) center_y = np.reshape( np.transpose( np.reshape( np.array([np.arange(1, H+1)*float(mc.IMAGE_HEIGHT)/(H+1)]*W*B), (B, W, H) ), (2, 1, 0) ), (H, W, B, 1) ) anchors = np.reshape( np.concatenate((center_x, center_y, anchor_shapes), axis=3), (-1, 4) ) return anchors
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_grid_anchors(grid_sizes, strides, cell_anchors):\n anchors = []\n assert cell_anchors is not None\n\n for size, stride, base_anchors in zip(grid_sizes, strides, cell_anchors):\n grid_height, grid_width = size\n stride_height, stride_width = stride\n\n # For output anchor, comp...
[ "0.71884936", "0.7036838", "0.70205647", "0.692611", "0.6890038", "0.6888356", "0.68680495", "0.6852056", "0.68242455", "0.6721483", "0.6713985", "0.6680048", "0.6649211", "0.6587107", "0.6582483", "0.6504692", "0.6504201", "0.65007716", "0.64910555", "0.6475948", "0.64250964...
0.73078704
0
test create new user
def test_create_user(self): url = reverse('rest_register') data = { 'username': "tommy", 'email': "henry@tomusange.com", 'password1': "thisPass", 'password2': "thisPass", } resp = self.client.post(url, data) self.assertEqual(resp.status_code, 201) self.assertIn('key', resp.data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_user(self):\n pass", "def test_create_user(self):\n pass", "def test_create_user(self):\n pass", "def test_createUser_single(self):\n #TODO: this and other tests", "def test_create_user(self):\n data = {\n \"firstname\": \"John\",\n \...
[ "0.9118798", "0.9118798", "0.9118798", "0.8665263", "0.85160905", "0.84581566", "0.8421159", "0.8413208", "0.84032094", "0.8297671", "0.8266993", "0.82470185", "0.82303685", "0.821916", "0.8214676", "0.8203459", "0.81913304", "0.817495", "0.8174881", "0.8171025", "0.81610763"...
0.7802782
68
Authorization header credentials are not valid
def bad_credentials(self, token = True): # Should not match up with anything in the database bad_creds = str(uuid.uuid4()) if token: return self.credentials(HTTP_AUTHORIZATION=("Token %s" % bad_creds)) else: return self.credentials(HTTP_AUTHORIZATION=("Basic %s" % bad_creds))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unauthorized():\n return HttpError(401)", "def authenticate_header(self, request):\n return \"Api key authentication failed.\"", "def test_authorization_header_empty(self, get_key_secret):\r\n request = Request(self.environ)\r\n request.authorization = \"bad authorization header\"\r...
[ "0.7151656", "0.6980444", "0.69387716", "0.6932599", "0.69088596", "0.6879544", "0.6865807", "0.68371814", "0.6741195", "0.6717008", "0.67152405", "0.668238", "0.66528887", "0.66374475", "0.66084486", "0.65807706", "0.6570014", "0.6560585", "0.6551", "0.65419096", "0.65318316...
0.63877547
33
Returns a base64 encoded image
def get_image_base64(path): with open(path, 'r') as img: return base64.b64encode(img.read())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base64(self):\n image = self.png.getvalue()\n return base64.encodestring(image).decode('utf-8')", "def b64_image(self) -> bytes:\n buffer = BytesIO()\n self.image.save(buffer, \"PNG\") \n im_b64 = base64.b64encode(buffer.getvalue())\n im_b64 = b\"data:image/png;bas...
[ "0.869036", "0.848181", "0.792245", "0.7919407", "0.78182817", "0.7813553", "0.7783526", "0.7704936", "0.7685311", "0.76038045", "0.7507104", "0.74403137", "0.7422337", "0.7361644", "0.73501134", "0.73389935", "0.7311974", "0.7309352", "0.7265232", "0.722809", "0.7165373", ...
0.8013179
2
Pretty prints a dictionary object
def pretty_print(data): print json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pretty_print(dictionary: dict):\n return json.dumps(dictionary, indent=4)", "def _format_dict(self, dict_, indent=0):\n prefix = indent*\" \"*4\n output = \"{\\n\"\n for key, val in sorted(dict_.items()):\n if isinstance(val, dict):\n rval = self._format_...
[ "0.7756763", "0.77491796", "0.7593614", "0.75883794", "0.747514", "0.74257255", "0.74077237", "0.7393802", "0.7355092", "0.7287501", "0.72772837", "0.7269156", "0.7246214", "0.72203445", "0.72087824", "0.71886367", "0.7185559", "0.71673584", "0.7134078", "0.7124751", "0.70953...
0.65422326
56
Create and return an author for testing
def create_author(user_dict, author_dict): user = User.objects.create_user(**user_dict) user.save() author_dict['user'] = user author = Author.objects.create(**author_dict) author.save() return (user, author)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_author(first_name='testfirstname', last_name='testlastname'):\n return Author.objects.create(first_name=first_name, last_name=last_name)", "def create_author(name):\n return Author.objects.create(name=name)", "def create(self, validated_data):\n return Author.objects.get_or_create_autho...
[ "0.79695106", "0.7857562", "0.7657986", "0.746278", "0.71505", "0.7013657", "0.6913632", "0.6895028", "0.68653756", "0.6783304", "0.6783304", "0.66965", "0.6666494", "0.66540325", "0.6537066", "0.64950055", "0.64649695", "0.64644116", "0.6461421", "0.6401893", "0.63745886", ...
0.7088164
5
Returns a list of created posts for the given author
def create_multiple_posts(author, num, ptext = TEXT, visibility = ACL_DEFAULT): posts = [] for i in range(num): posts.append(Post.objects.create(content = ptext, author = author, visibility=visibility)) return posts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_queryset(self):\r\n\r\n user = get_object_or_404(User, username=self.kwargs.get('username'))\r\n return Post.objects.filter(author=user).order_by('-date_posted')", "def get_queryset(self):\n id = self.kwargs['pk']\n target_author=get_object_or_404(Author, pk = id)\n ret...
[ "0.6751652", "0.6719958", "0.6679745", "0.64851755", "0.6355382", "0.63139474", "0.6307772", "0.62711054", "0.6250475", "0.62041193", "0.61662126", "0.6099204", "0.6088763", "0.60696316", "0.6060949", "0.59918046", "0.59400725", "0.58352584", "0.58273214", "0.58035225", "0.57...
0.6749558
1
Test to ensure that all authors added to relationship are in the returned data Called after a retrieve relationship test has passed
def authors_in_relation(context, data, authors): guids = [a.id for a in authors] guids = map( lambda x: str(x).replace('-', ''), guids) for guid in guids: context.assertTrue(unicode(guid) in data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_retrieve_authors(self):\n sample_author()\n sample_author()\n\n res = self.client.get(reverse('authors'))\n authors = Author.objects.all()\n serializer = AuthorSerializer(authors, many=True)\n self.assertEqual(res.data, serializer.data)\n self.assertEqual(r...
[ "0.719106", "0.6605452", "0.65803057", "0.64502394", "0.6409618", "0.6390426", "0.62981063", "0.6223942", "0.6172895", "0.6143107", "0.6092482", "0.60106426", "0.5917884", "0.587733", "0.5856236", "0.5841362", "0.58273274", "0.5820912", "0.5778369", "0.5765315", "0.574128", ...
0.7145637
1
Create Friends and Friends of Friends and associated posts
def create_friends(friend, friendors, create_post = True, visibility = ACL_DEFAULT): for friendor in friendors: friend.add_friend(friendor) friendor.add_friend(friend) # FriendRelationship.objects.create(friendor = friendor, friend = friend) if create_post: Post.objects.create(content = TEXT, author = friendor, visibility = visibility)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_friend(request, profile_pk, friend_pk):\n\n profile_object = Profile.objects.get(pk=profile_pk)\n friend_object = profile_object.get_friend_suggestions().get(pk=friend_pk)\n \n profile_object.friends.add(friend_object)\n profile_object.save()\n\n return redirect(reverse('show_profile_page...
[ "0.6206124", "0.60353947", "0.5980641", "0.5965954", "0.59487104", "0.56830245", "0.56672275", "0.56354594", "0.56294787", "0.55971295", "0.55717593", "0.5568948", "0.5557959", "0.5542263", "0.54640216", "0.54584336", "0.54564565", "0.54361814", "0.5435222", "0.54146063", "0....
0.7941469
0
Takes post author, comment author and creates a post and associated comment
def create_post_with_comment(pauthor, cauthor, visibility, ptext, ctext): post = Post.objects.create(content = ptext, author = pauthor, visibility=visibility) comment = Comment.objects.create(comment = ctext, post = post, author = cauthor) return (post, comment)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_comment(post, author, content):\n return Comment.objects.create(post=post, author=author, content=content)", "def postCreate(post):\n post_list = list()\n comments = commentList(post)\n comment_url = \"{}/api/posts/{}/comments\".format(DOMAIN, post.id)\n visible_to = list()\n visible...
[ "0.7968736", "0.69776434", "0.680873", "0.6670445", "0.6624297", "0.6575736", "0.6529041", "0.6456722", "0.64194477", "0.6396711", "0.6375334", "0.6340401", "0.63245595", "0.6278583", "0.62078166", "0.6168181", "0.6167977", "0.61602026", "0.61574775", "0.6155002", "0.6143866"...
0.79196894
1
Takes response.data and confirms no repeated guids (No repeated posts)
def assertNoRepeatGuids(context, posts): guids = [p['guid'] for p in posts] context.assertTrue(len(set(guids)) == len(posts), "Some guids repeated")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_response_reusage_after_replied(self):\n\n post1 = self._create_tweet(\n content=\"I need a foo.\",\n channel=self.inbound,\n demand_matchables=True)\n\n resp1 = Response.objects.upsert_from_post(post1)\n\n support = UserProfile.objects.upsert('Twitter'...
[ "0.5659422", "0.55370516", "0.5480621", "0.5440656", "0.5439443", "0.5430286", "0.53764886", "0.53743136", "0.5368204", "0.53578305", "0.53345466", "0.532668", "0.530157", "0.5287817", "0.5268618", "0.52629507", "0.5260671", "0.5257835", "0.5253612", "0.52466136", "0.52329594...
0.6993569
0
Compares a list of authors against a list of displaynames
def cross_check(context, authors, poscom): displaynames = [x['author']['displayname'] for x in poscom] for author in authors: if author.user.username not in displaynames: context.assertFalse(True, "%s not in list" %author.user.username)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_authors( data ) :\n return list(set( chain.from_iterable( [ authors(x) for x in data ] ) ))", "def display_authors(self, *args):\n return ', '.join(author.name for author in args[0].authors.all()[:3])", "def test_author_many_lastnames(self):\n inv_search = 'author:\"alvarez gaume, ...
[ "0.64632857", "0.63929", "0.6384049", "0.6332246", "0.62227446", "0.6216081", "0.6199922", "0.615091", "0.6108188", "0.6102564", "0.6097298", "0.6095483", "0.6072117", "0.60518503", "0.59991443", "0.5962012", "0.595125", "0.59264", "0.5892751", "0.5881848", "0.5834737", "0....
0.68802696
0
Cross checks a list of authors against post
def assertAuthorsInPosts(context, authors, posts): cross_check(context, authors, posts)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_check(context, authors, poscom):\n displaynames = [x['author']['displayname'] for x in poscom]\n\n for author in authors:\n if author.user.username not in displaynames:\n context.assertFalse(True, \"%s not in list\" %author.user.username)", "def author_ManyToMany_entry_check(): ...
[ "0.72640485", "0.6881462", "0.6769553", "0.65692633", "0.6538516", "0.63877165", "0.6319493", "0.62692463", "0.60791737", "0.6033017", "0.5904452", "0.5835843", "0.58165914", "0.579224", "0.5788046", "0.57680523", "0.57557714", "0.5726369", "0.5697314", "0.56669766", "0.56610...
0.7797011
0
Cross checks a list of authors against comments
def assertAuthorsInComments(context, authors, comments): cross_check(context, authors, comments)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_check(context, authors, poscom):\n displaynames = [x['author']['displayname'] for x in poscom]\n\n for author in authors:\n if author.user.username not in displaynames:\n context.assertFalse(True, \"%s not in list\" %author.user.username)", "def assertAuthorsInPosts(context, aut...
[ "0.74669504", "0.65934074", "0.6494307", "0.6315845", "0.6253867", "0.62438315", "0.61274093", "0.6090594", "0.5927208", "0.59244573", "0.58965456", "0.5887174", "0.58157754", "0.579177", "0.57523257", "0.5713481", "0.5709423", "0.5708671", "0.5706471", "0.56644917", "0.56633...
0.7966482
0
Takes a list of cachedauthors and adds them to the author follower list
def create_cached_author_followers(author, followers): for f in followers: author.followers.add(f)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addAuthor2():\n\n author_list = list()\n\n authors = Author.objects.all()\n\n for author in authors:\n author_dict = dict()\n author_dict['id'] = \"{}/api/author/{}\".format(DOMAIN, author.id)\n author_dict['host'] = \"{}/api/\".format(author.host_url)\n author_dict['displa...
[ "0.64747363", "0.6431524", "0.6423831", "0.6329321", "0.6274541", "0.6242031", "0.6238875", "0.62265736", "0.6178677", "0.61373085", "0.6131011", "0.6087273", "0.60318464", "0.59967387", "0.5986646", "0.5947148", "0.5934538", "0.5911428", "0.59073174", "0.590661", "0.59045154...
0.81595033
0
Retorna todos los proyectos registrados hasta ahora
def get_queryset(self): return Proyecto.objects.all()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_users():", "def get_registered_users():\n registered_users = (\n current_app.scoped_session()\n .query(User)\n .filter(User.additional_info[\"registration_info\"] != \"{}\")\n .all()\n )\n registration_info_list = {\n u.username: u.additional_info[\"registr...
[ "0.633144", "0.61951846", "0.5960654", "0.5862325", "0.5837356", "0.58092964", "0.57713354", "0.5747028", "0.5717182", "0.5696331", "0.5695908", "0.56900585", "0.5685562", "0.5600017", "0.5582856", "0.55819285", "0.55757916", "0.5572261", "0.5559203", "0.55448735", "0.5522238...
0.0
-1
Creates a leaf node with the given datum (an integer).
def __init__(self, data): self.data = data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_instantiate_leaf_node(self):\n try:\n LeafNode('my_label')\n except Exception:\n message = \"LeafNode instantiation failed\"\n self.fail(message)", "def make_leaves(self):\n\n curr_leaf = self.root\n i = 1\n while i < self.length:\n ...
[ "0.6327141", "0.6087558", "0.60294986", "0.5793774", "0.5791541", "0.5787082", "0.57470906", "0.5739957", "0.5700532", "0.5640091", "0.55949605", "0.5552148", "0.5547106", "0.5514915", "0.5505738", "0.5499741", "0.54990375", "0.54628", "0.54603404", "0.5457154", "0.54411215",...
0.0
-1
Returns the value of the expression.
def value(self): return self.data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value(self) -> global___Expression:", "def value(self) -> global___Expression:", "def value(self) -> Optional[Expression]:\n return self.__value", "def value_expression(self) -> str:\n return pulumi.get(self, \"value_expression\")", "def value_expression(self) -> Optional[str]:\n r...
[ "0.80231833", "0.80231833", "0.7905604", "0.7728165", "0.76552755", "0.7503011", "0.74549043", "0.7429503", "0.7389446", "0.73270637", "0.7262415", "0.723994", "0.720171", "0.71606433", "0.7152678", "0.7130495", "0.710755", "0.710755", "0.7055234", "0.70376086", "0.7030717", ...
0.0
-1
Returns the expression in prefix form.
def prefix(self): return str(self.data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prefix(self):\n return str(self.operator) + \" \" + self.leftOperand.prefix() + \" \" + self.rightOperand.prefix()", "def calculate_prefix_expression(cls, expression):\n\t\tlogger.info(f\"in the calculate prefix expression {expression}\")\n\t\telements = expression.split()\n\t\tstack = []\n\t\tfor e ...
[ "0.7265404", "0.710734", "0.6866923", "0.6425482", "0.63313454", "0.63313454", "0.63225156", "0.63132906", "0.6267651", "0.62378424", "0.62378424", "0.62378424", "0.6218811", "0.6152476", "0.6141088", "0.6069823", "0.6069823", "0.6055349", "0.60520095", "0.6048974", "0.602687...
0.54560906
77
Returns the expression in infix form.
def infix(self): return str(self.data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def infix(self):\n return \"(\" + self.leftOperand.infix() + \" \" + str(self.operator) + \" \" + self.rightOperand.infix() + \")\"", "def calculate_infix_expression(cls, expression):\n\t\tlogger.info(f\"in the calculate infix expression {expression}\")\n\t\telements = expression.split()\n\t\tstack = []\n...
[ "0.820744", "0.74909353", "0.6935869", "0.68716174", "0.6740321", "0.670735", "0.66578454", "0.6584289", "0.6553258", "0.64778376", "0.636958", "0.6362766", "0.6355834", "0.634328", "0.6335792", "0.6330504", "0.6273808", "0.62522274", "0.62522274", "0.62522274", "0.624801", ...
0.68402994
4
Returns the expression in postfix form.
def postfix(self): return str(self.data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def infix_to_postfix(self, expr: str) -> str:\n\n # The stack that we will be performing operations on\n stack: list[str] = []\n\n # The output\n output: str = \"\"\n\n # We always need surrounding parentheses\n expr = f\"({expr})\"\n\n # The tokenized expression\n ...
[ "0.7961822", "0.78936446", "0.7821992", "0.77166677", "0.76865053", "0.7469475", "0.7190205", "0.71594596", "0.7055572", "0.696866", "0.6934861", "0.6923071", "0.6912573", "0.68213874", "0.6815801", "0.68071514", "0.6803007", "0.67953223", "0.67841136", "0.67317486", "0.66949...
0.6813625
15
Returns the string rep of the expression.
def __str__(self): return str(self.data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expression(self):\n\n result = u\"{}({}\".format(self.function.lower(),\n self.metric_name)\n\n if self.dimensions_str:\n result += u\"{{{}}}\".format(self.dimensions_str)\n\n if self.deterministic:\n result += u\", deterministic\"\n\n ...
[ "0.736386", "0.68066204", "0.67740124", "0.675347", "0.6752998", "0.6706245", "0.6700624", "0.6700624", "0.666184", "0.6628258", "0.6522713", "0.6517617", "0.646707", "0.646707", "0.6448369", "0.6398307", "0.63835007", "0.6337211", "0.6321024", "0.6310438", "0.6302699", "0....
0.0
-1
Creates an interior node with the given operator (a token), and left and right operands (other nodes).
def __init__(self, opToken, leftOper, rightOper): self.operator = opToken self.leftOperand = leftOper self.rightOperand = rightOper
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __create_internal_node_by_operator(operator: PatternStructure, sliding_window: timedelta, parent: Node = None):\n operator_type = operator.get_top_operator()\n if operator_type == SeqOperator:\n return SeqNode(sliding_window, parent)\n if operator_type == AndOperator:\n ...
[ "0.6768396", "0.6402284", "0.6212105", "0.6038182", "0.6029708", "0.59814626", "0.59771395", "0.5969799", "0.57881653", "0.57876146", "0.57825124", "0.57195956", "0.56935775", "0.56912225", "0.56751347", "0.559061", "0.5583933", "0.5532599", "0.54641896", "0.5460819", "0.5419...
0.66272795
1
Utility routine to compute a value.
def computeValue(self, op, value1, value2): result = 0 theType = op.getType() # Use python's application of an operator depending on theType of the token if theType == Token.PLUS: result = value1 + value2 elif theType == Token.MINUS: result = value1 - value2 elif theType == Token.MUL: result = value1 * value2 elif theType == Token.MOD: result = value1 % value2 elif theType == Token.EXP: result = value1**value2 elif theType == Token.DIV: if value2 == 0: raise ZeroDivisionError("Attempt to divide by 0") else: result = value1 // value2 return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_value(self, *args, **kwargs):\n\n return None", "def getValue(self):\n # compute and return my value\n return functools.reduce(operator.mul, (op.getValue() for op in self.operands))", "def value(self) -> float:", "def val(self):\r\n if not self.value:\r\n se...
[ "0.7594629", "0.7220241", "0.705439", "0.6837795", "0.6837795", "0.67696714", "0.67696714", "0.67696714", "0.6758692", "0.66920656", "0.66820556", "0.65508604", "0.6509542", "0.6488429", "0.6488429", "0.6481076", "0.64206606", "0.64025074", "0.6401865", "0.64014447", "0.63940...
0.6336137
24
Returns the value of the expression.
def value(self): return self.computeValue(self.operator, self.leftOperand.value(), self.rightOperand.value())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value(self) -> global___Expression:", "def value(self) -> global___Expression:", "def value(self) -> Optional[Expression]:\n return self.__value", "def value_expression(self) -> str:\n return pulumi.get(self, \"value_expression\")", "def value_expression(self) -> Optional[str]:\n r...
[ "0.80231833", "0.80231833", "0.7905604", "0.7728165", "0.76552755", "0.7503011", "0.74549043", "0.7389446", "0.73270637", "0.7262415", "0.723994", "0.720171", "0.71606433", "0.7152678", "0.7130495", "0.710755", "0.710755", "0.7055234", "0.70376086", "0.7030717", "0.70151573",...
0.7429503
7
Returns the expression in prefix form.
def prefix(self): return str(self.operator) + " " + self.leftOperand.prefix() + " " + self.rightOperand.prefix()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_prefix_expression(cls, expression):\n\t\tlogger.info(f\"in the calculate prefix expression {expression}\")\n\t\telements = expression.split()\n\t\tstack = []\n\t\tfor e in reversed(elements):\n\t\t\tif e.isdigit():\n\t\t\t\tstack.append(int(e))\n\t\t\telse:\n\t\t\t\t# this is an operator\n\t\t\t\tif ...
[ "0.710734", "0.6866923", "0.6425482", "0.63313454", "0.63313454", "0.63225156", "0.63132906", "0.6267651", "0.62378424", "0.62378424", "0.62378424", "0.6218811", "0.6152476", "0.6141088", "0.6069823", "0.6069823", "0.6055349", "0.60520095", "0.6048974", "0.60268766", "0.59823...
0.7265404
0
Returns the expression in infix form (fully parenthesized).
def infix(self): return "(" + self.leftOperand.infix() + " " + str(self.operator) + " " + self.rightOperand.infix() + ")"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_infix(string):\n return postfix(infix_to_postfix(string))", "def infix_to_prefix(self, expr: str) -> str:\n\n # Reverse expr\n expr = reversed(expr)\n\n # Convert expr to list\n expr = list(expr)\n\n # Reverse all parantheses\n for i, e in enumerate(expr)...
[ "0.71687776", "0.70765674", "0.70678484", "0.70356464", "0.69882065", "0.6876605", "0.6813432", "0.6722101", "0.6542399", "0.6502566", "0.648048", "0.64614725", "0.645874", "0.63886565", "0.63599867", "0.632505", "0.626854", "0.6246395", "0.62401587", "0.62371445", "0.6197802...
0.81181073
0
Returns the expression in postfic form.
def postfix(self): return self.leftOperand.postfix() + " " + self.rightOperand.postfix() + " " + str(self.operator)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expression(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"expression\")", "def expression(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"expression\")", "def expression(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"expression\")", "def expression(self) -> ...
[ "0.7534816", "0.7534816", "0.7534816", "0.7497278", "0.7497278", "0.74922043", "0.7467428", "0.6997637", "0.69282675", "0.6805527", "0.67491686", "0.66249216", "0.6623153", "0.6500933", "0.6368758", "0.62659156", "0.6263841", "0.62291735", "0.6209051", "0.6111835", "0.6105642...
0.53761655
65
Returns a string representation with the tree rotated 90 degrees counterclockwise.
def __str__(self): def recurse(node, level): s = "" if type(node) == LeafNode: return ("| " * level) + str(node) + "\n" if node != None: s += recurse(node.rightOperand, level + 1) s += "| " * level s += str(node.operator) + "\n" s += recurse(node.leftOperand, level + 1) return s return recurse(self, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self) -> str:\n values = []\n self._str_helper(self.root, values)\n return \"TREE in order { \" + \", \".join(values) + \" }\"", "def __str__(self) -> str:\n values = []\n self._str_helper(self.root, values)\n return \"TREE in order { \" + \", \".join(values)...
[ "0.7079702", "0.7079702", "0.6723897", "0.6693969", "0.6500883", "0.6468781", "0.6459211", "0.64515245", "0.64155436", "0.64153516", "0.64048725", "0.6403809", "0.6297127", "0.62846375", "0.6280475", "0.62751967", "0.6263699", "0.6237177", "0.6221739", "0.6201274", "0.6197721...
0.62242943
18
Returns all possible velocity dispersons from all particles found in the data set. A particle filter can be passed using "filter" which is a list
def compute_velocity_dispersion(data, types = None, fields = None, filter = None): types_to_fields = {'x': 'particle_velocity_x', 'y': 'particle_velocity_y', 'z': 'particle_velocity_z', 'r': 'particle_velocity_spherical_radius', 'theta': 'particle_velocity_spherical_theta', 'phi': 'particle_velocity_spherical_phi'} if types is None and fields is None: fields = types_to_fields.values() keys = types_to_fields.keys() elif fields is None: fields = [ types_to_fields[x] for x in types ] keys = types else: keys = fields dispersion = {} for i,x in enumerate(fields): if filter is not None: v = data[x][filter] else: v = data[x] if np.size(v) == 0: dispersion[keys[i]] = 0.0 else: dispersion[keys[i]] = vel_dispersion( v.convert_to_units('km/s') ) return dispersion
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_velocities(self):\n\n return np.array([p.velocity for p in self.particles])", "def particle_forceV(R,N,sigma,epsilon,D):\n F = np.zeros((3,N))\n x = np.zeros(N-1)\n y = np.zeros(N-1)\n z = np.zeros(N-1)\n r = np.zeros(N-1)\n # loop over all particles\n for i in range(N):\n ...
[ "0.5962206", "0.57577115", "0.5713186", "0.56626225", "0.56291974", "0.5555897", "0.5501763", "0.5466105", "0.54309624", "0.54021454", "0.5381622", "0.53503567", "0.53398895", "0.5317946", "0.52965754", "0.5289197", "0.5287057", "0.52832603", "0.52564645", "0.5244272", "0.523...
0.6084097
0
This api does not return xml
def xml(self): raise NotImplementedError('This api does not return xml')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xml(self, request):\n raise Exception(\"Not Implemented\")", "def content_api_xml(url, request):\n headers = {'content-type': 'application/xml'}\n content = 'xml string'\n return response(status_code=200,\n content=content,\n headers=h...
[ "0.6906242", "0.681684", "0.66007024", "0.64178306", "0.6360245", "0.629127", "0.61903584", "0.61852777", "0.6081651", "0.6022426", "0.6001489", "0.5988445", "0.59532", "0.5934724", "0.5896389", "0.5798428", "0.57974744", "0.57974744", "0.5797071", "0.5797071", "0.576466", ...
0.75670606
0
Spring error is either an error in the wrapper response or an error returned by the api in the json
def error(self): error = self._wrapped.error if error: return error return self.json['response'].get('error')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_api_exception(error):\n response = flask.jsonify(error.to_dict())\n response.status_code = error.status_code\n return response", "def handle_error(error):\n response = jsonify(error.to_dict())\n response.status_code = error.status_code\n return response", "def on_response_validation_erro...
[ "0.75166994", "0.7210059", "0.70859104", "0.70615435", "0.69839483", "0.6966496", "0.69491005", "0.6889269", "0.6889269", "0.688472", "0.68772686", "0.68692976", "0.6838407", "0.6829438", "0.6813062", "0.67832464", "0.67662054", "0.6756578", "0.6753409", "0.675096", "0.672443...
0.70127034
4
return the error code
def error_code(self): return self.json['response'].get('error_code')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error_code(self) -> int:\n return pulumi.get(self, \"error_code\")", "def error_code(self) -> int:\n return self._error_code", "def error_code(self):\n # type: () -> int\n return self._error_code", "def error_code(self):\n return self._error_code", "def errorcode(self...
[ "0.8525533", "0.84996057", "0.8444067", "0.83733237", "0.83133256", "0.8211999", "0.80976784", "0.8081181", "0.8055439", "0.80443174", "0.7319064", "0.7141462", "0.7095967", "0.7091699", "0.7091612", "0.7072328", "0.705872", "0.70341647", "0.6983146", "0.692198", "0.69102186"...
0.76482093
10
Returns whether erorr is NOAUTH
def noauth(self): try: # some endpoints dont return json return self.json['response'].get('error_id') == 'NOAUTH' except: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth_error():\n return unauthorized('Invalid credentials')", "def unauthorized():\n return HttpError(401)", "def check_auth_none(self, username):\n return AUTH_FAILED", "def test_no_auth(self) -> None:\n channel = self.make_request(\"GET\", self.url, {})\n\n self.assertEqual(40...
[ "0.7120319", "0.70609397", "0.7014564", "0.6881835", "0.6881835", "0.6855839", "0.67338675", "0.67045474", "0.66409737", "0.66409737", "0.66238505", "0.6619812", "0.66152024", "0.659969", "0.65859014", "0.6582713", "0.6556535", "0.6549733", "0.6540464", "0.6489589", "0.648874...
0.81090945
0
Write a custom auth property where we grab the auth token and put it in the headers
def authenticate(self): #it's weird i have to do this here, but the code makes this not simple auth_json={'email':self.user, 'password':self.password} #send a post with no auth. prevents an infinite loop auth_response = self.post('/auth', data = json.dumps(auth_json), auth = None) _token = auth_response.json['token'] self._token = _token self._wrapped.auth = SpringAuth(_token)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self, r):\n r.headers[\"x-aims-auth-token\"] = self._token\n return r", "def auth_header_value(self):\n return f\"token {self.API_TOKEN}\"", "def authorization(self):\n return {'auth-token': '{token}'.format(token=self.token)}", "def authorization(self):\n retu...
[ "0.7161087", "0.7057166", "0.6970341", "0.6970341", "0.6921795", "0.68667036", "0.67996633", "0.6784417", "0.6764053", "0.66727406", "0.66410804", "0.6630715", "0.66150844", "0.6613414", "0.6583362", "0.65666574", "0.6546947", "0.6528426", "0.6521229", "0.6509429", "0.6488572...
0.5789005
80
Returns the token from the api to tell us that we have been logged in
def token(self): if not self._token: self._token = self.authenicate().token return self._token
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_token(self):\n return user.get_token()", "def get_token(self):\n response = self.client.post(\n url_for('auth.login'),\n data=json.dumps({'username': 'thundoss@gmail.com', 'password': 'denno'}),\n headers={'content_type': 'application/json'})\n retur...
[ "0.7961458", "0.7928275", "0.78518677", "0.7729143", "0.7523873", "0.750345", "0.7439859", "0.7439859", "0.73954666", "0.7394398", "0.7386385", "0.736755", "0.7338549", "0.7287521", "0.7270584", "0.7262894", "0.72374797", "0.7226831", "0.71970665", "0.71939373", "0.7190025", ...
0.72815895
14
Open website and verify that it is load successfully.
def test_should_open_website(self): search_str = "//*[text()='Generate']" els = self.driver.find_elements_by_xpath(search_str) self.assertGreater(len(els), 0, 'Page loads failed!')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_open(self):\n page, resources = self.ghost.open(base_url)\n self.assertEqual(page.url, base_url)\n \n self.ghost.click(\"#run\")", "def simple_test_open_url(url):\n try:\n return requests.get(url, headers={\"User-Agent\": random.choice(useragents.useragents())}).sta...
[ "0.7061345", "0.6986661", "0.681532", "0.67337334", "0.6537021", "0.64900905", "0.64784175", "0.6409724", "0.6388426", "0.63827145", "0.63675433", "0.6326356", "0.6323878", "0.6320799", "0.631518", "0.62944365", "0.6293973", "0.62766635", "0.62705076", "0.6237263", "0.6229745...
0.65583813
4
Verify can select Maven option
def test_should_choose_maven(self): search_str = "//*[text()='Maven Project']" els = self.driver.find_elements_by_xpath(search_str) self.assertGreater(len(els), 0, 'Maven project is not found!') els[0].click()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_install_project(self):\n return True", "def test_target_repo(self):\n # network may be unavailable, but we are not interested anyway,\n # so we ignore the exitcode\n output = self.run_command(\"selfupdate --check bennr01:dev\", exitcode=None)\n self.assertIn(\"Target: b...
[ "0.56208634", "0.5418946", "0.5402192", "0.5377991", "0.53591835", "0.53054255", "0.5300273", "0.52879065", "0.52866113", "0.5282876", "0.52460307", "0.5236804", "0.5199385", "0.51885027", "0.5179016", "0.5172662", "0.5153789", "0.5144154", "0.5144154", "0.51356703", "0.50819...
0.7265652
0
Checks that all transformers in self.transformer_list are compatible with methods fit, transform and fit_transform.
def _check_transformers(self): assert all([hasattr(trf, "fit") for trf in self.transformer_list]), "At least one transformer object is not " \ "compatible with 'fit' method." assert all([hasattr(trf, "transform") for trf in self.transformer_list]), "At least one classifier object " \ "is not compatible with " \ "'transform' method." assert all([hasattr(trf, "fit_transform") for trf in self.transformer_list]), "At least one classifier " \ "object is not compatible with " \ "'fit_transform' method."
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_transforms(self):\n if len(self.transforms) > 1:\n for transform in self.transforms:\n if transform.applies is None:\n raise ValueError(\n 'If more than one transform is provided, each '\n 'provided tran...
[ "0.6600919", "0.6600919", "0.6245045", "0.60071653", "0.60061026", "0.597027", "0.5953561", "0.57135946", "0.566122", "0.5652529", "0.5621234", "0.55733705", "0.5559613", "0.5533336", "0.54827064", "0.5438628", "0.5429233", "0.5416639", "0.5386236", "0.53803736", "0.5358731",...
0.9007204
0
Runs back and forth between the ball and a random point in the field.
def warm_up(self): self.velocity = self.steering_behaviours.calculate() self.pos += self.velocity self.pos = Point(int(self.pos.x), int(self.pos.y)) if not self.is_moving(): if self.steering_behaviours.target == self.soccer_field.ball.pos: # let's go back towards where I was. self.steering_behaviours.target = self.initial_pos else: # let's go towards the ball. self.steering_behaviours.target = self.soccer_field.ball.pos self.direction = Vec2d(self.steering_behaviours.target - self.pos).normalized()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spawn_ball(direction):\n global ball_pos, ball_vel \n ball_pos = [WIDTH / 2, HEIGHT / 2]\n ball_vel = ball_generate_velocity(direction) # Ball velocity randomization ", "def move(self):\n if self._z >= 75:\n a = random.random()\n print(str(a))\n if a < 0.2:\n ...
[ "0.6942022", "0.6932368", "0.6906408", "0.6877452", "0.685227", "0.6844614", "0.68308836", "0.68072754", "0.6727945", "0.66941935", "0.6596098", "0.65557665", "0.6538567", "0.65164626", "0.64776844", "0.64438", "0.63699085", "0.6309126", "0.6304336", "0.62798154", "0.62781817...
0.5636123
85
Redundant, implemented to demonstrate _find
def find(self, cargo): return self._find(cargo).cargo
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(self, p):\n pass", "def find(self, sub) -> int:\n pass", "def find(self):\n raise NotImplementedError", "def rfind(self, sub) -> int:\n pass", "def testFind(self):\n\n N = randint(20,150)\n s = SplayTree()\n for i in xrange(N):\n self.s.insert(i,1)\n for i in x...
[ "0.7247958", "0.70327836", "0.70220166", "0.66316307", "0.6484891", "0.6347973", "0.6303143", "0.6281496", "0.6251936", "0.62015027", "0.6197718", "0.5998828", "0.5998442", "0.5941339", "0.59164965", "0.5911454", "0.58913594", "0.5884457", "0.58645743", "0.584961", "0.5751502...
0.0
-1
This is a raw test so there is only a single line of 32x32 blocks
def testPatternBasic(tiles=8, cols=16): matrix = Adafruit_RGBmatrix(32, tiles) # cols, rows tileSize = (32, 32) sizeX = tileSize[0] * tiles / cols sizeY = 32 # cols = int(tileSize[0] * tiles / sizeX) rows = 1 imageToRender = Image.new("RGBA", (tileSize[0] * tiles, tileSize[1] * rows)) draw = ImageDraw.Draw(imageToRender) print("imageToRender", imageToRender, sizeX) # Print tile numbers font = ImageFont.truetype("/home/pi/RPI/fonts/freefont/FreeSerifBold.ttf", 30) count = 0 for n in range(0, tiles): xPos = count * 32 yPos = -5 draw.text((xPos, yPos), str(count), (255, 0, 0), font=font) count = count + 1 iid = imageToRender.im.id matrix.SetImage(iid, 0, 0) time.sleep(4) # (0,200,0) wheel = [ (255, 0, 0), (255, 125, 0), (255, 255, 0), (0, 255, 0), (0, 255, 125), (0, 0, 255), (125, 0, 255), (255, 0, 255), ] n = clri = 0 b = 1 cName1 = wheel[clri] cName2 = (10, 10, 10) t1 = time.clock() t2 = time.clock() for c in range(0, cols): xPos = c * sizeX + 0 yPos = 0 xPos2 = xPos + sizeX yPos2 = yPos + sizeY b = 1 draw.rectangle( (xPos, yPos, xPos2, yPos2), fill=(int(cName1[0] * b), int(cName1[1] * b), int(cName1[2] * b)), ) n += 1 if n > len(wheel): b *= 0.8 # print(n, clri, xPos, yPos, xPos2, yPos2) if clri < len(wheel) - 1: clri += 1 else: clri = 0 cName1 = wheel[clri] cName2 = (10, 10, 10) t2 = time.clock() print(t2 - t1) iid = imageToRender.im.id matrix.SetImage(iid, 0, 0) print(time.clock() - t2) time.sleep(10) draw.rectangle((0, 0, tileSize[0] * cols, tileSize[1] * rows), fill=0, outline=1) matrix.SetImage(iid, 0, 0) time.sleep(0.1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_blocks_to_line_1(self):\n grid = self.sudoku.inicializate_sudoku(9)\n\n # Assigment especify values\n grid[0][0] = 1 # Block 1\n grid[1][1] = 2 # Block 1\n grid[2][2] = 3 # Block 1\n grid[5][5] = 9 # Block 5\n grid[7][4] = 7 # Block 8\n grid[6][...
[ "0.65974164", "0.6437619", "0.6378572", "0.6358274", "0.634844", "0.63045037", "0.6271461", "0.6197353", "0.6164198", "0.61533105", "0.6144925", "0.60612434", "0.60551167", "0.6042766", "0.6040426", "0.6015868", "0.60060424", "0.59940493", "0.5990534", "0.5964054", "0.595681"...
0.0
-1
Sets the default values for the project
def __init__(self): # BASE_DIR:///artifice/scraper/ self.BASE_DIR = os.path.dirname(loc) # prototypes self._eth0 = '0.0.0.0' self._exposed_port = 8080 self._db_name = 'site.db' self._redis_pword = 'password' self._redis_host = 'localhost' self._redis_port = 6379 self._celery_broker_uname = 'michael' self._celery_broker_pword = 'michael123' self._celery_broker_host = 'localhost' self._celery_broker_virtual_host = 'michael_vhost' # flask self.TESTING = False self.URL_PREFIX = '' self.FLASK_PORT = self._exposed_port self.FLASK_HOST = '0.0.0.0' self.FLASK_DEBUG = False self.FLASK_USE_RELOADER = False self.FLASK_THREADED = True # logging self.LOG_FILE = 'flask.log' self.LOG_LEVEL = 'INFO' self.CELERY_LOG_LEVEL = 'ERROR' self.CELERY_LOG_FILE = 'celery.log' self.STDOUT = True # database self.DROP_TABLES = True self.SQLALCHEMY_TRACK_MODIFICATIONS = False self.SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format( os.path.join(self.BASE_DIR, self._db_name)) # redis self.REDIS_URL = 'redis://{}:@{}:{}/0'.format( self._redis_pword, self._redis_host, self._redis_port) self.REDIS_HIT_COUNTER = 'HIT_COUNTER' # defaults self.ARGS_DEFAULT_LIMIT = 10 self.ARGS_DEFAULT_STATUS = ['READY', 'TASKED', 'DONE'] self.SUPERVISOR_ENABLED = True self.SUPERVISOR_DEBUG = False self.SUPERVISOR_POLITE = 1 # celery self.CELERY_WORKERS = 8 self.CELERY_MODULE = 'background' self.CELERY_BROKER = 'amqp://{}:{}@{}/{}'.format( self._celery_broker_uname, self._celery_broker_pword, self._celery_broker_host, self._celery_broker_virtual_host) self.CELERY_BACKEND = 'rpc://' self.CELERY_INCLUDE = ['artifice.scraper.background.tasks'] # endpoints self.URL_FOR_STATUS = 'http://{}:{}/status'.format(self._eth0, self._exposed_port) self.URL_FOR_QUEUE = 'http://{}:{}/queue'.format(self._eth0, self._exposed_port) self.URL_FOR_CONTENT = 'http://{}:{}/content'.format(self._eth0, self._exposed_port)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_defaults(context: CreateCommandsContext):\n job_default_parameters: List[\n Parameter\n ] = context.settings.job_default_parameters\n logger.info(\n \"Please set default rows current value shown in [brackets]. Pressing enter\"\n \" without input will keep current value\"\n ...
[ "0.6994468", "0.6959797", "0.68457776", "0.67833525", "0.66337454", "0.6582282", "0.6558582", "0.6526463", "0.6523897", "0.6491703", "0.6482176", "0.6464206", "0.6461486", "0.6424208", "0.6412936", "0.6357029", "0.63031733", "0.6299067", "0.6298111", "0.6293933", "0.6293933",...
0.0
-1
Deduce correct spark dtype from pandas dtype for column col of pandas dataframe df
def infer_spark_dtype(df, col): logger = logging.getLogger(__name__ + ".infer_spark_dtype") pd_dtype = df.dtypes[col] # get a sample from column col sample = df[col].dropna() if sample.shape[0] == 0: logger.warning("column %s of dtype %s containing nulls found" % (col, pd_dtype)) sample = None else: sample = sample.iloc[0] # infer spark dtype # datetimes if pd.api.types.is_datetime64_any_dtype(pd_dtype): ret = T.TimestampType() # ints elif (pd_dtype == 'int8') or (pd_dtype == 'int16'): # int8, int16 ret = T.ShortType() elif pd_dtype == 'int32': ret = T.IntegerType() elif pd.api.types.is_int64_dtype(pd_dtype): ret = T.LongType() # uints elif pd_dtype == 'uint8': ret = T.ShortType() elif pd_dtype == 'uint16': ret = T.IntegerType() elif pd_dtype == 'uint32': ret = T.LongType() elif pd_dtype == 'uint64': logger.warning("converting column %s of type uint64 to spark LongType - overflows will be nulls" % col) ret = T.LongType() # floats elif (pd_dtype == 'float16') or (pd_dtype == 'float32'): ret = T.FloatType() elif pd_dtype == 'float64': # float64 ret = T.DoubleType() elif pd_dtype == 'bool': ret = T.BooleanType() # object elif pd_dtype == 'object': if (sample is None) or (isinstance(sample, str)): logger.warning("converting column %s of type object to spark StringType" % col) ret = T.StringType() elif isinstance(sample, tuple): raise NotImplementedError("cannot convert column %s containing tuples to spark" % col) else: raise NotImplementedError("values in column %s of type object not understood" % col) # category elif pd.api.types.is_categorical_dtype(pd_dtype): logger.warning("converting column %s of type category to spark StringType" % col) ret = T.StringType() else: raise NotImplementedError("column %s of type %s not understood" % (col, pd_dtype)) return ret
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_dtype(data_df, settings):\n data_df = data_df.astype(settings[\"dtype\"])\n return data_df", "def change_col_type(df,schema):\n d = {'int':IntegerType(),'str':StringType(),'float':FloatType(),'bool':BooleanType()}\n \n for c,t in schema.items():\n df = df.withColumn(c,col(c).cas...
[ "0.72055167", "0.70074373", "0.67383504", "0.66940576", "0.66150796", "0.65282935", "0.64637434", "0.64026904", "0.63992226", "0.63900924", "0.63755214", "0.63500774", "0.6339335", "0.63325894", "0.6327806", "0.63060737", "0.62946403", "0.62688094", "0.6235217", "0.6229606", ...
0.7871534
0
Model function for CNN.
def cnn_model_fn(input_data): # Input Layer # [batch_size, image_height, image_width, channels] input_layer = tf.reshape(input_data, [-1, 100, 100, 3]) # Convolutional Layer #1 conv1 = tf.layers.conv2d( inputs=input_layer, filters=32, kernel_size=[5, 5], padding="same", activation=tf.nn.relu) # Pooling Layer #1 pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=[2, 2], strides=2) # Convolutional Layer #2 and Pooling Layer #2 conv2 = tf.layers.conv2d( inputs=pool1, filters=64, kernel_size=[5, 5], padding="same", activation=tf.nn.relu) pool2 = tf.layers.max_pooling2d(inputs=conv2, pool_size=[2, 2], strides=2) # Dense Layer pool2_flat = tf.reshape(pool2, [-1, 25 * 25 * 64]) dense = tf.layers.dense(inputs=pool2_flat, units=1024, activation=tf.nn.relu) dropout = tf.layers.dropout( inputs=dense, rate=0.4, training=mode == tf.estimator.ModeKeys.TRAIN) # Logits Layer logits = tf.layers.dense(inputs=dropout, units=PREDICT_CLASSES) predictions = { # Generate predictions (for PREDICT and EVAL mode) "classes": tf.argmax(input=logits, axis=1), # Add `softmax_tensor` to the graph. It is used for PREDICT and by the # `logging_hook`. "probabilities": tf.nn.softmax(logits, name="softmax_tensor") } return logits, predictions
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CNN_model():\n prob = 0.1\n model = Sequential()\n # model.add(Conv2D(filters = 32, kernel_size = (5,5),padding = 'Same',\n # activation ='relu', input_shape = (28,28,1)))\n # model.add(Conv2D(filters = 64, kernel_size = (5,5),padding = 'Same',\n # activation =...
[ "0.7548566", "0.7336699", "0.7334111", "0.7312466", "0.7297639", "0.72836435", "0.7270212", "0.7219095", "0.7172809", "0.7157214", "0.7129322", "0.7123428", "0.7075449", "0.70725286", "0.70709413", "0.70399654", "0.70386714", "0.7026649", "0.69520336", "0.694842", "0.6929263"...
0.6860718
26
Call API, get returned model output_text
def formatText(input_text): data = {"text": input_text} print 'Waiting for return ...' req = requests.post('http://34.212.39.136:5678/format', json = data) output_text = req.json()['result'] return output_text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_text(self):\n return self.output.getvalue()", "def get_text(self):\n\n return self.output['text']", "def _text_command(self, request):\n response = self._send(request)\n self._check_response(response)\n return response.text", "def get_output(self):\r\n return...
[ "0.6547523", "0.64406526", "0.6372505", "0.63234127", "0.63181823", "0.62049085", "0.61882645", "0.6186225", "0.61427337", "0.61218154", "0.611173", "0.6090764", "0.60520905", "0.6046867", "0.60038114", "0.59461546", "0.58610237", "0.5852279", "0.5844785", "0.58447844", "0.58...
0.6135099
9
Run a command and echo it first
def run_cmd(call, cmd, *, echo=True, **kwargs): if echo: print('$> ' + ' '.join(map(pipes.quote, cmd))) return call(cmd, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(command):\n if arguments['--dry-run']:\n print command\n else:\n subprocess.call(command, shell=True)", "async def terminal(event):\r\n command = utils.raw(event.message)\r\n await event.edit(f\"**Running command:**\\n`{command}`\")\r\n result = subprocess.getoutput(command)\...
[ "0.69847924", "0.6959119", "0.69450945", "0.6919458", "0.6859296", "0.6812634", "0.67663026", "0.6756266", "0.67383146", "0.67201954", "0.670066", "0.6692517", "0.66810435", "0.6675754", "0.6665769", "0.6646724", "0.65908474", "0.6578724", "0.65752876", "0.6571929", "0.656086...
0.696063
1
Return the URL for remote git repository. Depending on the system setup it returns ssh or https remote.
def git_remote(git_repo): github_token = os.getenv(GITHUB_TOKEN_KEY) if github_token: return 'https://{0}@github.com/{1}'.format( github_token, git_repo) return 'git@github.com:{0}'.format(git_repo)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def git_remote_url(self):\n return self._git_remote_url", "def url(self):\n\n return maybe_string(C.git_remote_url(self._remote))", "def get_repository_uri(self) -> str:\n try:\n url = subprocess.check_output(\n ['git', 'config', '--get', 'remote.origin.url']\n ...
[ "0.8327677", "0.8047084", "0.74365985", "0.74162096", "0.70978475", "0.70588034", "0.7024028", "0.70150566", "0.69381243", "0.69171757", "0.6888431", "0.6873803", "0.6837741", "0.6745437", "0.6676825", "0.66446656", "0.6639019", "0.6631967", "0.6614763", "0.6497674", "0.64818...
0.75394326
2
Get the last commit to modify the given paths
def last_modified_commit(*paths, **kwargs): return check_output([ 'git', 'log', '-n', '1', '--pretty=format:%h', '--', *paths ], **kwargs).decode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_diff_to_last_commit(path_to_repository, ignore_subrepositories):\n repo = Repo(path_to_repository)\n if ignore_subrepositories==True:\n unstaged_diff = repo.index.diff(other=None, paths=None, create_patch=False, ignore_submodules=\"all\")\n staged_diff = repo.head.commit.diff(other=Dif...
[ "0.66357094", "0.646586", "0.64447695", "0.6435589", "0.6427532", "0.6335761", "0.629556", "0.6295136", "0.6277516", "0.6207843", "0.6153193", "0.61308944", "0.6121598", "0.6120476", "0.60908526", "0.5947546", "0.5922661", "0.5920262", "0.5910456", "0.58968264", "0.5894823", ...
0.7615342
0
Return the last modified date (as a string) for the given paths
def last_modified_date(*paths, **kwargs): return check_output([ 'git', 'log', '-n', '1', '--pretty=format:%cd', '--date=iso', '--', *paths ], **kwargs).decode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_date_modified(path):\n return str(datetime.datetime.fromtimestamp(os.path.getmtime(path)))", "def _get_last_modified_date(path):\n last_date = 0\n root_dir, subdirs, files = os.walk(path).next()\n # get subdirs and remove hidden ones\n subdirs = [s for s in subdirs if not s.startswith...
[ "0.8046738", "0.7416479", "0.7245152", "0.7219578", "0.71944565", "0.6939524", "0.67891824", "0.6737202", "0.6734333", "0.67058384", "0.6656483", "0.6634494", "0.6624429", "0.6620233", "0.6591059", "0.6591059", "0.65882814", "0.6566373", "0.6562852", "0.6555743", "0.6548625",...
0.7935193
1
Return whether the given paths have been changed in the commit range Used to determine if a build is necessary
def path_touched(*paths, commit_range): return check_output([ 'git', 'diff', '--name-only', commit_range, '--', *paths ]).decode('utf-8').strip() != ''
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_rev_dirty(ctx: \"PlanemoCliContext\", directory: str) -> bool:\n return io.shell([\"git\", \"diff\", \"--quiet\"], cwd=directory) != 0", "def _can_checkout(wit_path) -> bool:\n\n current_id = _get_head(wit_path)\n changes_to_be_committed = _return_as_string(_get_changes_to_be_committed, wit_path,...
[ "0.6485178", "0.64627033", "0.63761", "0.6337259", "0.6332157", "0.6283598", "0.6267245", "0.6246275", "0.6215795", "0.6191025", "0.6181917", "0.6179466", "0.6164216", "0.6145015", "0.6080553", "0.6079178", "0.6058201", "0.6047565", "0.6034595", "0.6026013", "0.6012013", "0...
0.8217679
0
Get docker build args dict, rendering any templated args.
def render_build_args(options, ns): build_args = options.get('buildArgs', {}) for key, value in build_args.items(): build_args[key] = value.format(**ns) return build_args
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def docker_build_context(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"docker_build_context\")", "def docker_build_context(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"docker_build_context\")", "def read_dockerfile_for_args(target):\n import colorama\n...
[ "0.64995056", "0.6460428", "0.5992242", "0.59243613", "0.5775845", "0.56487375", "0.5570073", "0.5546533", "0.5522067", "0.5497052", "0.5493939", "0.54721403", "0.5428458", "0.5366059", "0.5361795", "0.535775", "0.5269126", "0.5204375", "0.5196358", "0.51938367", "0.518926", ...
0.7038579
0
Cached getter for docker client
def docker_client(): return docker.from_env()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def get_docker_client(self) -> \"DockerClient\":", "def docker_client():\n client = docker.from_env()\n return client", "def get_client():\n info = {}\n host = os.environ.get('DOCKER_HOST')\n net_host = os.environ.get('DOCKER_NET_HOST')\n\n client_api_version = os.environ.get('DOCKER_AP...
[ "0.7949226", "0.6975132", "0.69293606", "0.6704719", "0.6433767", "0.6314111", "0.6047752", "0.59885114", "0.59635204", "0.5917807", "0.5916698", "0.5907519", "0.5857684", "0.58574104", "0.58456975", "0.5838481", "0.58354545", "0.58210045", "0.58168083", "0.58074665", "0.5708...
0.72880656
1
Return whether an image needs pushing
def image_needs_pushing(image): d = docker_client() try: d.images.get_registry_data(image) except docker.errors.APIError: # image not found on registry, needs pushing return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def PrePush(self, image):\n pass", "def hasImage(self):\n if self.getImage():\n return True\n return False", "def _pushing(pushop):\n return bool(\n pushop.outgoing.missing\n or pushop.outdatedphases\n or pushop.outobsmarkers\n or pushop.outbookmarks\n...
[ "0.67209774", "0.66439164", "0.6631148", "0.656371", "0.64065194", "0.63889164", "0.6336889", "0.6315508", "0.6282437", "0.6282437", "0.62279326", "0.61669666", "0.6137131", "0.6032941", "0.6019985", "0.59767556", "0.5969536", "0.59661514", "0.5943", "0.5921205", "0.59130216"...
0.7235848
0
Return whether an image needs building Checks if the image exists (ignores commit range), either locally or on the registry.
def image_needs_building(image): d = docker_client() # first, check for locally built image try: d.images.get(image) except docker.errors.ImageNotFound: # image not found, check registry pass else: # it exists locally, no need to check remote return False # image may need building if it's not on the registry return image_needs_pushing(image)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_needs_pushing(image):\n d = docker_client()\n try:\n d.images.get_registry_data(image)\n except docker.errors.APIError:\n # image not found on registry, needs pushing\n return True\n else:\n return False", "def check_image(self, tag):\n image_name = self.b...
[ "0.74606645", "0.7137432", "0.70654684", "0.6916333", "0.6890094", "0.6849104", "0.68168086", "0.6784783", "0.6744717", "0.66717255", "0.6600988", "0.6536723", "0.65264153", "0.65185374", "0.650834", "0.6502069", "0.6478776", "0.6386925", "0.6359315", "0.6355004", "0.6343484"...
0.8575527
0
Build a collection of docker images
def build_images(prefix, images, tag=None, commit_range=None, push=False, chart_version=None, skip_build=False): value_modifications = {} for name, options in images.items(): image_path = options.get('contextPath', os.path.join('images', name)) image_tag = tag # include chartpress.yaml itself as it can contain build args and # similar that influence the image that would be built paths = list(options.get('paths', [])) + [image_path, 'chartpress.yaml'] last_commit = last_modified_commit(*paths) if tag is None: if chart_version: image_tag = "{}-{}".format(chart_version, last_commit) else: image_tag = last_commit image_name = prefix + name image_spec = '{}:{}'.format(image_name, image_tag) value_modifications[options['valuesPath']] = { 'repository': image_name, 'tag': SingleQuotedScalarString(image_tag), } if skip_build: continue template_namespace = { 'LAST_COMMIT': last_commit, 'TAG': image_tag, } if tag or image_needs_building(image_spec): build_args = render_build_args(options, template_namespace) build_image(image_path, image_spec, build_args, options.get('dockerfilePath')) else: print(f"Skipping build for {image_spec}, it already exists") if push: if tag or image_needs_pushing(image_spec): check_call([ 'docker', 'push', image_spec ]) else: print(f"Skipping push for {image_spec}, already on registry") return value_modifications
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _build_docker_images(self):\n print(f\"+ building {len(self.neurodocker_specs)} Docker images\")\n self.docker_status = []\n for sha1, neurodocker_dict in self.neurodocker_specs.items():\n try:\n print(\"++ building image: {}\".format(neurodocker_dict))\n ...
[ "0.8046437", "0.73141617", "0.68958426", "0.6610562", "0.6573472", "0.65122867", "0.64818895", "0.64219844", "0.64116544", "0.63784987", "0.63149446", "0.6278506", "0.6173914", "0.61501855", "0.61332744", "0.61190534", "0.6108034", "0.61043316", "0.6097722", "0.60768604", "0....
0.6628026
3
Update name/values.yaml with modifications
def build_values(name, values_mods): values_file = os.path.join(name, 'values.yaml') with open(values_file) as f: values = yaml.load(f) for key, value in values_mods.items(): parts = key.split('.') mod_obj = values for p in parts: mod_obj = mod_obj[p] print(f"Updating {values_file}: {key}: {value}") if isinstance(mod_obj, MutableMapping): keys = IMAGE_REPOSITORY_KEYS & mod_obj.keys() if keys: for key in keys: mod_obj[key] = value['repository'] else: possible_keys = ' or '.join(IMAGE_REPOSITORY_KEYS) raise KeyError( f'Could not find {possible_keys} in {values_file}:{key}' ) mod_obj['tag'] = value['tag'] else: raise TypeError( f'The key {key} in {values_file} must be a mapping.' ) with open(values_file, 'w') as f: yaml.dump(values, f)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _write_values(self, app_name, chart_dir, values):\n\n data = self._get_values(app_name, chart_dir)\n new_data = {**data, **values}\n new_raw = yaml.dump(new_data)\n\n values_path = \"%s/%s/values.yaml\" % (chart_dir, app_name)\n with open(values_path, mode=\"w\") as values_fi...
[ "0.6856736", "0.6455863", "0.6232132", "0.6048177", "0.5998861", "0.5927065", "0.5708528", "0.56122386", "0.5609265", "0.560229", "0.5582246", "0.55429924", "0.552479", "0.5504513", "0.54904646", "0.54742396", "0.54720205", "0.54367936", "0.54282165", "0.53917795", "0.5384969...
0.69657123
0
Update chart with specified version or lastmodified commit in path(s)
def build_chart(name, version=None, paths=None, reset=False): chart_file = os.path.join(name, 'Chart.yaml') with open(chart_file) as f: chart = yaml.load(f) if version is None: if paths is None: paths = ['.'] commit = last_modified_commit(*paths) if reset: version = chart['version'].split('-')[0] else: version = chart['version'].split('-')[0] + '-' + commit chart['version'] = version with open(chart_file, 'w') as f: yaml.dump(chart, f) return version
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, commit, **kwargs):\n self._pkg_changes(commit=self.commit, **kwargs)\n self.commit = commit", "def updateLastCommitFile(self):\n f = open(self.last_released, 'w')\n f.write(self.new_rev)\n f.close()", "def update_chicago_graph(path=\"chicago.xml\"):\n\n\tChicago = downlo...
[ "0.60562843", "0.5704721", "0.5672184", "0.56603265", "0.5605551", "0.5470727", "0.5463986", "0.53915817", "0.53834933", "0.5340218", "0.5326489", "0.52888274", "0.5209247", "0.5190477", "0.5189303", "0.5181957", "0.5151227", "0.51332885", "0.51260006", "0.5121645", "0.509134...
0.54293627
7
Publish helm chart index to github pages
def publish_pages(name, paths, git_repo, published_repo, extra_message=''): version = last_modified_commit(*paths) checkout_dir = '{}-{}'.format(name, version) check_call([ 'git', 'clone', '--no-checkout', git_remote(git_repo), checkout_dir], echo=False, ) check_call(['git', 'checkout', 'gh-pages'], cwd=checkout_dir) # package the latest version into a temporary directory # and run helm repo index with --merge to update index.yaml # without refreshing all of the timestamps with TemporaryDirectory() as td: check_call([ 'helm', 'package', name, '--destination', td + '/', ]) check_call([ 'helm', 'repo', 'index', td, '--url', published_repo, '--merge', os.path.join(checkout_dir, 'index.yaml'), ]) # equivalent to `cp td/* checkout/` # copies new helm chart and updated index.yaml for f in os.listdir(td): shutil.copy2( os.path.join(td, f), os.path.join(checkout_dir, f) ) check_call(['git', 'add', '.'], cwd=checkout_dir) if extra_message: extra_message = '\n\n%s' % extra_message else: extra_message = '' check_call([ 'git', 'commit', '-m', '[{}] Automatic update for commit {}{}'.format(name, version, extra_message) ], cwd=checkout_dir) check_call( ['git', 'push', 'origin', 'gh-pages'], cwd=checkout_dir, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template(c, release=\"url-shortener\"):\n c.run(f\"helm template {release} {HELM_CHART_DIR} > ./generated-deployment.yml\")", "def index():\n return render_template(\"charts.html\")", "def main():\n \n root = Folder(name=os.getcwd(), file='meta.json',\n collection='.github/jeky...
[ "0.6303632", "0.5992799", "0.59895986", "0.56986564", "0.5615526", "0.55472004", "0.5513828", "0.53691167", "0.5364688", "0.5286044", "0.5263749", "0.52587676", "0.5251907", "0.5230299", "0.5216074", "0.52005446", "0.5190611", "0.5182666", "0.5175446", "0.51723653", "0.516488...
0.6350673
0
Add the domain restrictions.
def add_domains_restriction(self, domain_restriction): self._domain_restricion = domain_restriction self._size_var = self._get_size_var() self._nr_of_bits = self._get_nr_of_bits()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare_domain_restrictions(self):\n for index, restriction in enumerate(self._domain_restrictions):\n self.add_specific_domain_restriction(index+1, restriction)", "async def setjradd(self, ctx, domain):\n allowedDomains = await self.config.guild(ctx.guild).allowedDomains()\n ...
[ "0.7922115", "0.623785", "0.60880244", "0.5960196", "0.58387566", "0.57663685", "0.5692345", "0.5655885", "0.56333846", "0.55938256", "0.558293", "0.5558514", "0.55429906", "0.5535729", "0.5511199", "0.54556143", "0.5452144", "0.54225695", "0.54151505", "0.54145116", "0.53412...
0.7894003
1
Check if the Clase is finnal.
def is_implemented(cls): return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Estado_final(self,profundidad:int) -> bool:\n\n\t\tself.Evaluar(profundidad)\n\t\tif self.completo:\n\t\t\treturn True\n\t\telse:\n\t\t\treturn False", "def is_cis(self):\n prev_res = self.get_offset_residue(-1)\n if prev_res is None:\n return None\n\n prev_omega = prev_res.ca...
[ "0.6189312", "0.60821956", "0.5967552", "0.57333314", "0.568045", "0.56697154", "0.5623153", "0.552748", "0.545972", "0.5450248", "0.5449714", "0.54326916", "0.5420256", "0.5419858", "0.5419858", "0.5409019", "0.5409019", "0.5409019", "0.54056567", "0.54056567", "0.54056567",...
0.0
-1
Get the size of every variable.
def _get_size_var(self): size_var = [] for index in range(self._nr_args): restriction = self._domain_restricion[index] size_var.append(utils.get_nr_bits(restriction, self._precision)) return size_var
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_size(self):\n tmpsize = 0\n for variable in self.variables:\n tmpsize += variable.get_size()\n for subchunk in self.subchunks:\n tmpsize += subchunk.get_size()\n return tmpsize", "def size(self, varname):\n if self.handle == None: return []\n ...
[ "0.8138758", "0.80240923", "0.7549388", "0.7541823", "0.7528079", "0.7511355", "0.75046957", "0.7494464", "0.7438866", "0.7414112", "0.73386174", "0.7333908", "0.73007977", "0.72860545", "0.72836995", "0.7265444", "0.72609293", "0.7239517", "0.7197402", "0.7189756", "0.717883...
0.7626377
2