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
A partir de la estructura en C de un punto asigna los valores en el diccionario de python que representa un punto.
def CPy_Punto(C, P): P['x'][0] = C.x[0] P['x'][1] = C.x[1] P['x'][2] = C.x[2] P['y'][0] = C.y[0] P['y'][1] = C.y[1] P['y'][2] = C.y[2] P['D'] = C.D P['a'], P['b'], P['c'] = C.a, C.b, C.c P['d'], P['e'], P['f'] = C.d, C.e, C.f
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init(self):\n # pC es un puntero a la imagen en C\n nP = len(self.puntos)\n self.pC = c_colision.malloc_tren(nP)\n # Estas magnitudes se inicializan en la imagen y\n # ya no se tocan desde python\n for i in range(nP):\n self.pC.contents.P[i]= pointer(PyC_Pun...
[ "0.55818385", "0.54350394", "0.5377207", "0.53720134", "0.53423417", "0.51250035", "0.508531", "0.508531", "0.508531", "0.508531", "0.508531", "0.50723153", "0.5046252", "0.5030646", "0.5010223", "0.5001038", "0.4996938", "0.49926582", "0.49638692", "0.49526796", "0.4942924",...
0.5662838
0
A partir de los puntos reserva la memoria necesaria
def init(self): # pC es un puntero a la imagen en C nP = len(self.puntos) self.pC = c_colision.malloc_tren(nP) # Estas magnitudes se inicializan en la imagen y # ya no se tocan desde python for i in range(nP): self.pC.contents.P[i]= pointer(PyC_Punto(self.punt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def MAXMEM(self):", "def MEM (self,n):", "def reemplaza_tildes(palabra):", "def primos_permitidos():\r\n parejas_permitidas = [(31,23),(47,19),(7,19),(17,41),(31,7),(29,47),(37,23),(2,79),(43,17),(7,37),(5,61),\r\n (17,31),(23,19),(23,7),(11,83),(17,7),(71,3),(37,29),(7,79),(11,59),(37,3),(3,59),(13,5...
[ "0.58108115", "0.5770057", "0.5529878", "0.5465062", "0.5461957", "0.53970796", "0.536112", "0.5325736", "0.5277575", "0.5260761", "0.52398014", "0.51984286", "0.51866937", "0.51829827", "0.518129", "0.5172161", "0.5170659", "0.51253873", "0.51014656", "0.5087792", "0.5082665...
0.0
-1
A selfcontained routine to give you feedback on a wrong command
def provide_command_feedback(self, message): self.refresh() # reset the display self.command_feedback_bar.draw_text(message) self.input_box.clear() self.input_box.draw_text("PRESS (C) to CONTINUE") selection = "" while selection != ord("C") and selection != ord("c"): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error_check(command):\r\n\r\n # TODO\r", "def invalid_command(response): # string -> interaction\r\n print(\"Sorry; '\" + response + \"' isn't a valid command. Please try again.\")", "def test_bad_input():\n\n for arg in ['5', 'ch']:\n rv, out = getstatusoutput('{} {}'.format(prg, arg))\n...
[ "0.761977", "0.7487954", "0.71842384", "0.68550605", "0.6715813", "0.6696444", "0.66137606", "0.6575614", "0.6571421", "0.6568672", "0.65369827", "0.653671", "0.65142375", "0.6501786", "0.647243", "0.64185756", "0.6417606", "0.6413744", "0.6387135", "0.63675106", "0.63556767"...
0.0
-1
initialise Domain with cell vertices and sizes
def __init__( self, xh ): super( Domain, self ).__init__( xh ) self.dg = 0.5*self.dxh # cell jacobian return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initializeDomainBorder(self):\n #Read image of the structure\n if (self.PictureExistance == \"'yes'\"):\n self.__processImage()\n #re-define the domain size with the layers of boundaries and ghost points\n self.ny, self.nx = self.effectiveDomain.shape\n ...
[ "0.65595925", "0.6468736", "0.6450791", "0.6306958", "0.62393385", "0.6191882", "0.61890566", "0.6186516", "0.6183734", "0.61758626", "0.61507654", "0.6102445", "0.60795426", "0.60794216", "0.6060467", "0.60585374", "0.60388637", "0.60134053", "0.5997532", "0.59871835", "0.59...
0.65838295
0
set the expansion basis type and order, and the quadrature point type calculate the physical nodal points, cell jacobians and cell boundary extrapolation vectors
def set_expansion( self, order ): self.p = order q = polys.Legendre() self.zp = q.zeros[ order ] self.wp = q.weights[ order ] b = polys.Lagrange() b.interpolate( self.zp, np.ones( self.p ) ) self.Lm1 = np.zeros( self.nh*self.p ) #extrapolation to left cell...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculateElementQuadrature(self):\n #\n #get physical locations of quadrature points and jacobian information there\n #assume all components live on the same mesh\n #\n #mwf debug\n #import pdb\n #pdb.set_trace()\n self.u[0].femSpace.elementMaps.getValues...
[ "0.5704942", "0.5704799", "0.5604357", "0.54918164", "0.5463238", "0.54338795", "0.52082103", "0.52003396", "0.5145004", "0.51399213", "0.51352584", "0.5112741", "0.5099069", "0.5083901", "0.5081253", "0.5072265", "0.5071606", "0.50711", "0.5052168", "0.5050582", "0.50389147"...
0.6494705
0
initialise field with a name, mesh, and empty nodal value array
def __init__( self, name, mesh ): super( Field1D, self ).__init__( ) self.name = name self.mesh = mesh self.p = mesh.p self.bconds = [] self.val = np.zeros_like( self.mesh.xp ) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, mesh: Mesh):\n self.mesh = mesh\n self.f = [0]*len(mesh.delaunay.simplices)", "def __init__(self):\n self.temperature = np.array([])\n self.salinity = np.array([])\n self.date = np.array([])\n self.temperatureQF = np.array([])\n self.salinityQF ...
[ "0.644951", "0.64103436", "0.6257394", "0.61790735", "0.6124536", "0.609891", "0.60961914", "0.6010147", "0.5938188", "0.59196675", "0.5910425", "0.58786947", "0.5766448", "0.576308", "0.575183", "0.5747807", "0.573995", "0.5739801", "0.5733518", "0.57318676", "0.57302076", ...
0.72849774
0
sets the nodal values to the value of data
def set_field( self, data ): self.val[:] = data[:] return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_values(self, new_values):\n for name, value in new_values.items():\n self.nodes_db.loc[name][\"node\"].set_value(value)", "def set_data(node, value):\n node['data'] = value", "def setData(self,data):\n self.data=data\n self.leaf=True", "def __call__(self, data):\n ...
[ "0.68666023", "0.6781336", "0.6719989", "0.6640533", "0.6485141", "0.6477887", "0.6435104", "0.64134103", "0.63924325", "0.6391475", "0.6217284", "0.6155936", "0.61521435", "0.6145748", "0.6063041", "0.60438406", "0.5995593", "0.5991051", "0.59044737", "0.5903618", "0.5897617...
0.54879194
67
update the nodal values by the amount dval
def update( self, dval ): self.val[:] += dval[:] return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_attr(self):\n\n # Retrieve all current values\n all_values = nx.get_node_attributes(self.G, 'value')\n\n new_values = {}\n\n # Loop over all nodes\n for i in range(self.n_v):\n\n # Obtain list of neighbors\n neighbors = list(nx.all_neighbors(self....
[ "0.66173327", "0.6386377", "0.63390785", "0.6290867", "0.61031574", "0.607318", "0.60284334", "0.59924954", "0.5955133", "0.58953375", "0.5832942", "0.57472765", "0.57249826", "0.5718284", "0.57078254", "0.57078254", "0.57078254", "0.57078254", "0.5679883", "0.56649834", "0.5...
0.6818316
0
returns a copy (separate instance) of the field with identical mesh, nodal values and boundary conditions
def copy( self ): g = type(self)( self.name, self.mesh ) g.set_field( self.val ) for bc in self.bconds: g.add_boundary_condition( bc ) return g
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy(self):\r\n return BasicMesh(self.gl_lists, list(self.pos),\r\n list(self.rotation), list(self.verts),\r\n self.scale, list(self.colorize))", "def copy(self):\n dyn = type(self)(self._hyperparams)\n dyn.Fm = np.copy(self.Fm)\n dy...
[ "0.646273", "0.6136491", "0.6136491", "0.6033814", "0.6033814", "0.6026285", "0.597527", "0.59729373", "0.5958256", "0.58507407", "0.58323413", "0.5791815", "0.57766306", "0.5762455", "0.57526517", "0.57449275", "0.573039", "0.5729646", "0.57285917", "0.5709468", "0.5665728",...
0.7353876
0
set the value of the field and start recording history
def set_field( self, data ): super( UnsteadyField1D, self ).set_field( data ) self.history[:] = self.val[:] return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record(self, step):", "def set_recording(self, recording):\r\n self.recording = recording", "def record(self, pop, off, dad, mom):\n if mom is not None:\n off.setInfo(0, str(self.field))\n else:\n off.setInfo(dad.info(self.field) + 1, self.field)\n...
[ "0.6511677", "0.61678815", "0.59728336", "0.591871", "0.5911478", "0.58802354", "0.58583605", "0.57788575", "0.5733154", "0.57327724", "0.5729399", "0.57100177", "0.5677953", "0.56552887", "0.56398624", "0.56385005", "0.56361896", "0.5626299", "0.5611821", "0.5608883", "0.558...
0.6801956
0
update nodal value and save periodically save history
def update( self, dvar ): super( UnsteadyField1D, self ).update( dvar ) self.nt+=1 self.t += self.dt if self.nt % self.save_interval == 0: self.history = np.append( self.history, [self.val], axis=0 ) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update():", "def update():", "def update( ):\r\n pass", "def update_data():\n pass", "def _save_state(self):\n with open(self.histFile,'wb') as hf:\n hf.write(self.dbFile.Value)", "def force_update_graph(self):\n self.updated_data = 1\n self.update_graph(...
[ "0.6502267", "0.6502267", "0.6157122", "0.5947119", "0.5897002", "0.5839323", "0.57809687", "0.57069737", "0.5700425", "0.56924236", "0.56924236", "0.56924236", "0.5672736", "0.56651103", "0.56511647", "0.564683", "0.564683", "0.5632322", "0.56249356", "0.56016004", "0.559664...
0.63814884
2
Logout the current user.
def logout(): user = current_user user.authenticated = False db.session.add(user) db.session.commit() logout_user() return render_template("login.html")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_out_user(self):\n flask_login.logout_user()", "def logout():\n\n # remove the username from the session if it is there\n out_user = current_user.get_id()\n logout_user()\n logger.info(out_user + ' has been logged out.')\n return redirect(url_for('home'))", "def logout(self):\n ...
[ "0.8568456", "0.8273883", "0.82125884", "0.8188479", "0.8166452", "0.8102029", "0.8008094", "0.79780316", "0.7977338", "0.79505426", "0.7934361", "0.79214805", "0.7897054", "0.7892089", "0.7887028", "0.7876468", "0.786737", "0.7829867", "0.77613544", "0.7753704", "0.7742324",...
0.77614456
18
Returns the output of a native command on a give system.
def native_cmd(cmd, whitespace=False): result = subprocess.check_output(cmd, shell=True).decode() result = subprocess.run(cmd, stdout=subprocess.PIPE).stdout.decode('utf-8') return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def system_call(command):\n p = subprocess.Popen([command], stdout=subprocess.PIPE, shell=True)\n return p.stdout.read()", "def system_call(command):\n process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)\n return process.communicate()[0]", "def output(cmd):\n return subpr...
[ "0.7396365", "0.7161807", "0.7143486", "0.7129648", "0.70993006", "0.7083398", "0.7071331", "0.69864917", "0.693033", "0.6849974", "0.6830674", "0.6825894", "0.67233115", "0.67181", "0.67122537", "0.669967", "0.6611063", "0.6568101", "0.6561279", "0.653629", "0.65305054", "...
0.73972946
0
Forces sphinx docs to conform to GitHub pages conventions.
def main(): if os.path.exists("docs"): try: shutil.move("docs", "html") except FileNotFoundError as err: print(err) if os.path.exists("html"): try: native_cmd("html\make.bat html") except Exception as err: print(err) try:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def docs():\n sh('sphinx-build -W -b html docs docs/_build/html')", "def serve_sphinx_docs():\n\n return redirect(\n \"https://final-epam.readthedocs.io/en/latest/main_launch.html#main_launch.compile\",\n code=302,\n )", "def html():\n builtdocs = path(\"docs\") / options.sphinx.build...
[ "0.6144091", "0.60086167", "0.5847455", "0.5837519", "0.58055687", "0.567688", "0.5596296", "0.55484325", "0.5539346", "0.5525571", "0.55115086", "0.54753125", "0.5467334", "0.5433665", "0.54312086", "0.53938997", "0.53804797", "0.53803563", "0.53764", "0.53746617", "0.537146...
0.0
-1
Run a command with subprocess.check_output and send the output to the console and the specified logfile
def run_and_log_output(command: List[str], logfile: str, print_errors: bool=True): log_dir = os.path.dirname(logfile) if log_dir: os.makedirs(log_dir, exist_ok=True) with open(logfile, 'wb') as fh: print(f'Running command: {" ".join(command)}', flush=True) try: output = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _subprocess_check_log_output(cmd, cwd, logfile):\n _LOG.info(\"Execute (%s): %s\", cwd, cmd)\n cmd_base = cmd[0] if isinstance(cmd, (list, tuple)) else cmd.split(\" \", 1)[0]\n proc = subprocess.Popen(\n cmd,\n cwd=cwd,\n shell=True,\n bufsize=0,\n stdout=subprocess....
[ "0.732296", "0.7279438", "0.69670844", "0.68011194", "0.66960585", "0.6675629", "0.66571283", "0.66340595", "0.6601035", "0.6580322", "0.6577095", "0.6573328", "0.63622284", "0.6356524", "0.63254493", "0.631472", "0.63002706", "0.627858", "0.6268076", "0.6259961", "0.6221673"...
0.75880843
0
Calculate how many people can receive blood
def assign_blood(donors, rec): will_receive = 0 for i in range(len(rec)): j = i # only compare recipients against compatible donors, ie those with larger indexes while j < len(donors) and rec[i] > 0: # even is Rh+, odd is Rh-. + cannot donate to -, so skip this combination ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numRescueBoats(self, people, limit):\n queue = collections.deque(sorted(people))\n count = 0\n while queue:\n count += 1\n last = queue.pop()\n if len(queue) >= 1:\n first = queue[0]\n if first + last <= limit:\n ...
[ "0.6176571", "0.59303373", "0.5874365", "0.58660656", "0.5806364", "0.5792218", "0.5688796", "0.5648685", "0.5615235", "0.5615221", "0.55981386", "0.55980515", "0.55885375", "0.5583483", "0.5520244", "0.551486", "0.5471188", "0.5453424", "0.54509294", "0.54326224", "0.5422095...
0.55190307
15
for use in search result
def search_category(self): return _(self.child_class)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def processSearchResult(self):", "def search(self, query):", "def search(self, term):", "def search():\n pass", "def search(self, *args, **kwargs):", "def getResults():", "def question_new_search():", "def search(self, search):\n raise NotImplementedError", "def search(self, query, maxhit...
[ "0.78076315", "0.75077313", "0.729676", "0.7164715", "0.71005964", "0.7023101", "0.69145894", "0.67870533", "0.67773867", "0.6639964", "0.6615119", "0.6582103", "0.6554918", "0.65364075", "0.6333854", "0.63027674", "0.6248984", "0.62355167", "0.62296265", "0.6225494", "0.6184...
0.0
-1
to avoid reexecution of methods its results are cached in a local storage per instance cache
def __init__(self, *args, **kwargs): super(ContainerBox, self).__init__(*args, **kwargs) if not hasattr(self, 'local_cache'): self.local_cache = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _retrieveCachedData(self):", "def getData(self, local_cache):", "def cache(self):\n self.cached_mu = self.mu.eval()\n self.cached_var = self.var.eval()\n self.cached_count = self.count.eval()", "def __init__(self, *args, **kwargs):\n self._cachedict = {}", "def instance_cach...
[ "0.7423074", "0.6660697", "0.63958657", "0.6376113", "0.63036364", "0.6294587", "0.62335587", "0.6182092", "0.6165916", "0.61588365", "0.61556774", "0.60807264", "0.6053478", "0.6053478", "0.6053478", "0.6053478", "0.6028237", "0.60207075", "0.6018756", "0.60091215", "0.60054...
0.0
-1
This tests connectivity to a service running on a given host and port.
def connect_test(dstaddr, port): timenow = strftime("%m/%d/%Y %H:%M:%S %Z") try: port = int(port) except ValueError: raise ConnectivityPortValueError(port) try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # new TCP socket except socket.error: raise Connect...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_connection(self):\n self._bind_to_service()", "def test_connection(self):\n req = requests.get(\"http://{}:{}\".format(self.config.options.get(\"Server\", \"ListenAddress\"),\n self.config.options.get(\"Server\", \"Port\")))\n\n self.a...
[ "0.75703657", "0.70836467", "0.6863058", "0.6765218", "0.67554086", "0.671898", "0.6669946", "0.6655844", "0.66064155", "0.6586737", "0.6508594", "0.6499962", "0.6497981", "0.64864665", "0.64635426", "0.6448632", "0.6410356", "0.6392736", "0.6381422", "0.6369898", "0.6358473"...
0.6236401
26
Dataset mapping function to split one audio into segments. It only works in batch mode.
def to_segment(batch, segment_length=SEGMENT_LENGTH_TRAIN): noisy_arrays = [] clean_arrays = [] for x, y in zip(batch['noisy'], batch['clean']): length = min(len(x['array']), len(y['array'])) noisy = x['array'] clean = y['array'] for offset in range(segment_length, length + 1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_chunks(self, audio_segment, chunk_length):\r\n\t\tnumber_of_chunks = math.ceil(len(audio_segment) / float(chunk_length))\r\n\t\treturn [audio_segment[i * chunk_length:(i + 1) * chunk_length]\r\n\t\t\t\tfor i in range(int(number_of_chunks))]", "def segment(data):", "def _segment(data, segment_length=20...
[ "0.65247566", "0.61910456", "0.61483103", "0.6108048", "0.6108048", "0.6069994", "0.6060502", "0.59619766", "0.59619397", "0.59066033", "0.58721644", "0.5824011", "0.5755497", "0.5725454", "0.5643471", "0.56388396", "0.56370366", "0.5618862", "0.55873287", "0.55770665", "0.55...
0.5455956
25
Smoothing by number of voxel SD in all three spatial dimensions
def smoothing(data, mask): smooth_data = gaussian_filter(data, [2, 2, 2, 0]) Y = smooth_data[mask].T return Y
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_spatial_smoothing_xesmf_reduce_spatial_dims_CESM(\r\n reconstruction_ds_3d_full,\r\n):\r\n da = reconstruction_ds_3d_full\r\n step = 0.1\r\n actual = spatial_smoothing_xesmf(\r\n da,\r\n d_lon_lat_kws={\"lat\": step},\r\n )\r\n # test whether upsampled\r\n assert actual[...
[ "0.6293014", "0.6130545", "0.60603076", "0.6040567", "0.6027338", "0.59236306", "0.58670217", "0.5791785", "0.57902724", "0.5700219", "0.5665365", "0.5630333", "0.55882144", "0.55863285", "0.5585738", "0.557179", "0.5543831", "0.5530594", "0.552715", "0.55213904", "0.5512534"...
0.53712463
38
Generate three thresholded pvalue maps.
def p_map(task, run, p_values_3d, threshold=0.05): fmri_img = image.smooth_img('../../../data/sub001/BOLD/' + 'task00' + str(task) + '_run00' + str(run) + '/filtered_func_data_mni.nii.gz', fwhm=6) mean_img = image.m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_mapped_inputs(self,**kwargs):\n result = {}\n for v,t,o,p,n in zip(self.values,self.thresholds,self.operations,self.proportions,self.output_names):\n value = kwargs.get(v)\n if isinstance(t,basestring):\n threshold = kwargs.get(t)\n else:\n...
[ "0.63004917", "0.6016937", "0.5716552", "0.5661418", "0.5656309", "0.5539111", "0.5485241", "0.5467683", "0.5453258", "0.5430361", "0.54262054", "0.54162514", "0.5398394", "0.5353483", "0.53040725", "0.53033864", "0.5280172", "0.52591413", "0.52558345", "0.5253739", "0.524021...
0.60059744
2
Default constructor jfile_path string with the path to the JSON input file yfile_path=None string with the path to the YAML output file. If none is given, a default path is built by replacing JSON's extension to YAML's.
def __init__(self, jfile_path, yfile_path=None): super(JSON2YAML, self).__init__() if not yfile_path: yfile_path = jfile_path.replace('.json', '.yml') self.jfile_path = jfile_path self.yfile_path = yfile_path self._l.debug(f"Converting JSON <{self.jfile_path}> to Y...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, path, extension=\"yml\", expand=False, filename_field=None):\r\n self.path = path\r\n self.expand = expand\r\n self.filename_field = filename_field\r\n self.extension = extension", "def __init__ (self,\n path_to_json = None):\n self.default_p...
[ "0.5904695", "0.57020366", "0.5694569", "0.54628336", "0.5354753", "0.5232867", "0.51144755", "0.5109806", "0.5109366", "0.5074633", "0.50634974", "0.5014528", "0.5008866", "0.500834", "0.49745527", "0.49411646", "0.49310875", "0.49155352", "0.48995346", "0.48877087", "0.4879...
0.7463917
0
This method converts the loaded JSON file into a YAML file.
def _convert(self): json_data = xjson.loads(self.jfile_path) with io.open(self.yfile_path, 'w', encoding='utf8') as f: yaml.dump(json_data, f, default_flow_style=False, allow_unicode=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conversion_yaml():\r\n data ={\r\n 'name': 'george',\r\n 'age': 16,\r\n 'friends':\r\n [{'name': 'marry', 'age': 16}, {'name': 'jack', 'age': 17}]\r\n }\r\n yaml_data = yaml.dump(data)\r\n dirname = os.path.dirname(os.path.dirname(__file__))\r\n # data_dir = os.path.j...
[ "0.6950082", "0.65651673", "0.64373296", "0.6395889", "0.6372225", "0.63502705", "0.6332867", "0.6277105", "0.62494844", "0.62304705", "0.6180754", "0.61751336", "0.6173389", "0.6132995", "0.6115755", "0.61057806", "0.609142", "0.60893536", "0.6081999", "0.60774404", "0.60572...
0.7058134
0
Definition of the model to use. Do not modify the function here placeholder for the actual definition in `model/` (see example)
def define_model(self, data_source: DataManager , mode: str): #pylint: disable=E0202 raise NotImplementedError('No model defined.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model_definition(self):\n pass", "def MakeModel(self):\n pass", "def build_model_fn(self):", "def build_model():", "def create_model(self):\r\n model = self.model_fn(self.flags)\r\n print(model)\r\n return model", "def create_model(self):\n pass", "def crea...
[ "0.8052724", "0.7740161", "0.7617755", "0.75467086", "0.73872656", "0.71930957", "0.71930957", "0.7158589", "0.7132", "0.71097296", "0.70628566", "0.70628566", "0.69783163", "0.6969725", "0.69217443", "0.69060683", "0.6877336", "0.6877336", "0.6877336", "0.6877336", "0.687733...
0.68491864
21
Build with TPUEstimators for TPU usage
def _tpu_build(self): def _define_model(features, labels, mode, params): data_source = (features, labels) self.outputs = {} self.losses = {} self.otters = {} outputs, losses, others = self.define_model(data_source, mode) if mode == tf.esti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_tpu_estimator(model_fn, feature_columns, params):\n\n tpu_cluster_resolver = tf.distribute.cluster_resolver.TPUClusterResolver(\n params[\"tpu\"],\n zone=params[\"tpu_zone\"],\n project=params[\"gcp_project\"],\n coordinator_name=\"coordinator\")\n\n config = tf_estimator.tpu.RunCo...
[ "0.6620379", "0.64619344", "0.6336337", "0.6044041", "0.6040361", "0.6033146", "0.5936819", "0.58590895", "0.5826569", "0.57875663", "0.5746748", "0.5682275", "0.5632957", "0.5593171", "0.5550863", "0.5521687", "0.5521416", "0.5520666", "0.5501502", "0.54913414", "0.54882205"...
0.8038507
0
Normal build for CPU/GPU usage
def _regular_build(self): # This overwrites define_model, is that ok? self.define_model = tf.make_template(self.define_model.__name__, #pylint: disable=E1101 self.define_model, create_scope_now_=True) sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def with_cpu(ops, model):\n ...", "def main(gpu_device='/gpu:0', cpu_device='/cpu:0'):\n config = Config()\n params = experiment_params()\n model_tools.model_builder(\n params=params,\n config=config,\n model_spec=build_model,\n gpu_device=gpu_device,\n cpu_device=c...
[ "0.63447547", "0.63169456", "0.63169456", "0.6286549", "0.6255142", "0.6183486", "0.6146034", "0.60948944", "0.6008407", "0.5986733", "0.59800196", "0.59380627", "0.59286845", "0.5860372", "0.58479303", "0.58412206", "0.58348906", "0.580838", "0.5801897", "0.58008057", "0.579...
0.0
-1
Buids the optimizer(s) to minimize the loss(es) of the model.
def _build_optimizer(self, optimizer_to_use=tf.train.AdamOptimizer, tpu_support=False): self.optimize_ops = [] for loss in self.losses['train']: # TODO Create apropoiate external training scheme optimize_op = optimizer_to_use( learning_rate=self.learning_rate ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_optimizers(self, *args, **kwargs):\n\n # self.optimizers.append(...)\n # self.loss.append(...)\n pass", "def optimizer(self, model: nn.Module) -> torch.optim.Optimizer: # type: ignore\n pass", "def add_optimizers_to_graph(self):\n with tf.device(self.params.device):\n ...
[ "0.6608268", "0.64778686", "0.6411067", "0.62030786", "0.6198828", "0.61828005", "0.6151315", "0.6079092", "0.6024876", "0.60010314", "0.59784526", "0.59219277", "0.5897613", "0.58832854", "0.5872504", "0.5870774", "0.5869316", "0.58690035", "0.58505696", "0.5844197", "0.5842...
0.5378428
72
Run network on validation set
def _validate(self, global_step): # Todo clean summaries and add example outputs fetches = {} fetches['losses'] = self.losses['validation'] if self.otters['train']: fetches['others'] = self.otters['validation'] fetches['summary_ops'] = self.summary_ops['validation'] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _perform_validation(self):\n # -- Extract the information of the current fold -- #\n trained_on_folds = self.already_trained_on[str(self.fold)]\n\n # -- Extract all tasks into a list to loop through -- #\n tasks = list(self.mh_network.heads.keys())\n\n # -- Add the current tr...
[ "0.68970865", "0.6680294", "0.6592768", "0.6575097", "0.65173167", "0.6465279", "0.6446488", "0.6411777", "0.64112735", "0.6360535", "0.62759846", "0.62650895", "0.62235796", "0.6218539", "0.62140054", "0.6204643", "0.6203151", "0.61995304", "0.61995304", "0.616694", "0.61612...
0.5830484
68
Save the model weights.
def _save(self, step): output_path = self.output_path + '/checkpoints/' if not os.path.isdir(output_path): os.makedirs(output_path) self.saver.save(self.session, save_path=output_path,global_step=step)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_model_weights(self, filename):\n self.model.save_weights(filename)", "def save_weights(self, the_path):\n torch.save(self.model.state_dict(), the_path)", "def save(self, weights_file):\r\n \r\n self.model.save_weights(weights_file)", "def save(self, filename):\n se...
[ "0.8466241", "0.8258961", "0.8241626", "0.8169553", "0.8100238", "0.803548", "0.7927707", "0.79263896", "0.79263896", "0.7868274", "0.78136045", "0.7808261", "0.77804136", "0.77626294", "0.77180934", "0.77111787", "0.76874655", "0.7680562", "0.7570725", "0.7569059", "0.756476...
0.0
-1
Restore the trained variables from the last stored checkpoint
def _restore(self): output_path = self.output_path + '/checkpoints/' checkpoint = tf.train.latest_checkpoint(output_path) if checkpoint: self.saver.restore(self.session, save_path=checkpoint) restored_step = int(checkpoint.split('-')[-1]) # Robust enough? re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore(self):\n\n self.brain.restore_checkpoint()", "def restore_checkpoint(restore_dir):\n restored_train_state = checkpoints.restore_checkpoint(restore_dir, None)\n variables = {'params': restored_train_state['optimizer']['target']}\n model_state = restored_train_state['model_state']\n variable...
[ "0.80677176", "0.7964258", "0.7779497", "0.77639174", "0.7590523", "0.7496448", "0.73879194", "0.7298708", "0.7264404", "0.7238544", "0.72161573", "0.72161573", "0.72116035", "0.71820366", "0.71754044", "0.7120686", "0.7097083", "0.7093601", "0.69751537", "0.6958839", "0.6939...
0.70988476
16
Set up connection to database and create tables if they do not yet exist.
def __init__(self, bot): self.bot = bot self.connection = sqlite3.connect(DATABASE_PATH.format(bot.root)) sql_create_command = """ CREATE TABLE IF NOT EXISTS points ( 'viewer_id' INTEGER NOT NULL, 'amount' INTEGER NOT NULL, PRIMARY KEY('viewer_i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_db(self) -> None:\n conn = mysql.connector.connect(\n user=self.app.config[\"DATABASE_USER\"], password=self.app.config[\"DATABASE_PASSWORD\"],\n host=self.app.config[\"DATABASE_HOST\"], port=self.app.config[\"DATABASE_PORT\"], raise_on_warnings=True\n )\n try:\...
[ "0.848207", "0.8157445", "0.81489295", "0.8051478", "0.7992181", "0.79142934", "0.7898653", "0.77979386", "0.7699552", "0.76811045", "0.7650136", "0.7639886", "0.76104116", "0.76089835", "0.7594883", "0.75697774", "0.75696826", "0.75696826", "0.75549865", "0.7554524", "0.7539...
0.0
-1
Get the points of a user.
def get_points(self, username, new_entry=False): username = username.lower() viewer_id = self._get_user_id(username) sql_command = "SELECT amount FROM points WHERE viewer_id = ?;" cursor, connection = self.execute_command_get_connection( sql_command, (viewer_id,) ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_activity_points_by_id(self, user_id):\n return self.execute(TABELLE['activity_points']['select']['by_id'],(user_id,))['points']", "def get_points(self):\n\t\treturn self.points", "def get_points(self):\r\n return self.points", "def get_points(self):\n\t\treturn self._points", "def get...
[ "0.73348093", "0.71776253", "0.7164979", "0.69964087", "0.689828", "0.689828", "0.68397313", "0.66468936", "0.66468936", "0.66468936", "0.66468936", "0.66468936", "0.6615718", "0.64343214", "0.64081454", "0.63261306", "0.6317652", "0.62858474", "0.61869156", "0.6163786", "0.6...
0.6352058
15
Increment points of a user by a certain value. Check if the user reached legend in the process.
def increment_points(self, username, amount, bot): username = username.lower() viewer_id = self._get_user_id(username) points = int(self.get_points(username, new_entry=True)) rank = self.get_hs_rank(points) legend = "Legend" in rank points += amount sql_comman...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gain_point(self, points):\n self.points += points\n print(f\"Yay! You have gained {points} point(s)! That means you now have {self.points} points!\")", "def increment_exit_points(self):\r\n self.exit_points = self.exit_points + 1", "def l_point(self):\n self.l_score += 1\n se...
[ "0.60321903", "0.57378536", "0.5700675", "0.5686679", "0.5621175", "0.5620957", "0.55799454", "0.5561892", "0.5448379", "0.54198337", "0.54027534", "0.5397142", "0.5385536", "0.5333786", "0.5329125", "0.5329125", "0.5329125", "0.5322965", "0.53009015", "0.5288273", "0.5273257...
0.70796514
0
Get the absolute for a certain amount of points.
def get_rank(self, points): sql_command = "SELECT * FROM points WHERE amount > ?;" cursor, connection = self.execute_command_get_connection(sql_command, [points]) all = cursor.fetchall() cursor.close() connection.close() return len(all) + 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_absolute_value(x):\n return math.fabs(x)", "def absolute_value(x):\n x_star = x.clone()\n x_star[1] *= -1\n return elementwise_mult(x, x_star)[0].sqrt_()", "def absolute(x):\n return -x if x < 0 else x", "def __abs__(self):\n abspos = abs(self.pos)\n absvel = abs(self.ve...
[ "0.6745342", "0.6674263", "0.63747275", "0.6374694", "0.6294491", "0.6270209", "0.62565404", "0.6243814", "0.62288016", "0.6180154", "0.6176404", "0.611505", "0.6111611", "0.60943186", "0.60571975", "0.6046836", "0.6038694", "0.5969677", "0.59634477", "0.5955579", "0.59534305...
0.0
-1
Get the n top spammers.
def get_top_spammers(self, n): sql_command = "SELECT * FROM points ORDER BY amount DESC;" cursor, connection = self.execute_command_get_connection(sql_command, []) all = cursor.fetchall() return all[:n]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top_by_num_of_ratings(self, n):\n return top_movies", "def test_top_n_counts():\n ngrams = NgramFrequencies()\n new_dic = {\n \"a\": 1,\n \"b\": 2,\n \"c\": 3,\n \"d\": 4\n }\n top_list = ngrams.top_n_counts(new_dic)\n assert top_list == [(\"d\", 4), (\"c...
[ "0.6869077", "0.6804007", "0.6788999", "0.6788999", "0.6694118", "0.6691008", "0.667423", "0.6663724", "0.66617", "0.66360414", "0.6616579", "0.6606422", "0.6540506", "0.6503402", "0.6503402", "0.64988184", "0.64909893", "0.6450828", "0.6448978", "0.64452827", "0.6418813", ...
0.8310816
0
Return spam rank of a user in hearthstone units.
def get_hs_rank(self, points): p = points rank = self.RANKS while p > 0 and rank > 0: p = p - self.BASE * math.pow(self.FACTOR, (self.RANKS - rank)) rank = rank - 1 if rank > 0: return str(rank) else: return str(self.get_rank(point...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_reputation_score(self):\n self._extract()\n if self.user_type == 0:\n for key in BitBucketEnum.USER_NEW_REPUTATION_MAPPING:\n if key.high >= self.no_of_followers >= key.low:\n return BitBucketEnum.USER_NEW_REPUTATION_MAPPING[key]\n elif self...
[ "0.63216615", "0.6012072", "0.5899204", "0.5830125", "0.5814504", "0.5808026", "0.5796414", "0.5766243", "0.5745717", "0.5739884", "0.5719251", "0.57058805", "0.5705769", "0.5676966", "0.5672292", "0.5654651", "0.5644436", "0.56103396", "0.55852926", "0.5585148", "0.5561976",...
0.4951804
95
Execute a command and return the cursor and connection. Use this if you need the output of the command, or need the cursor and connection. Since different threads will try to access this method, a connection has to be reopened everytime.
def execute_command_get_connection(self, sql_command, args): connection = sqlite3.connect(DATABASE_PATH.format(self.bot.root)) cursor = connection.cursor() cursor.execute(sql_command, args) connection.commit() return cursor, connection
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute(self, command, *args, **kw):\n conn, address = self.get_connection(command, args)\n if conn is not None:\n fut = conn.execute(command, *args, **kw)\n return self._check_result(fut, command, args, kw)\n else:\n coro = self._wait_execute(address, comm...
[ "0.6711291", "0.66315925", "0.65280336", "0.65198976", "0.6265124", "0.6210378", "0.6199773", "0.61896217", "0.61482316", "0.614579", "0.61115587", "0.6105831", "0.6026215", "0.60134554", "0.60089606", "0.5982857", "0.59786767", "0.59691954", "0.5958951", "0.5946281", "0.5945...
0.7270666
0
Execute an sql command and closes all connections. Does not return output.
def execute_command(self, sql_command, args): cursor, connection = self.execute_command_get_connection(sql_command, args) cursor.close() connection.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_sql_call(self):\n c_data = {'db_host': self.server,\n 'db_user': self.user,\n 'db_password': self.password,\n 'db_database': self.database}\n db_conn = self.SH.sql.helper.sql_conn_obj(c_data)\n result, detail = db_conn.connect()\n self.print_to_...
[ "0.67657375", "0.6543867", "0.65374744", "0.65250635", "0.64901483", "0.6467374", "0.645544", "0.64353216", "0.6412571", "0.63929516", "0.6277691", "0.6272989", "0.6255919", "0.61555314", "0.6154794", "0.61303073", "0.6090869", "0.6063971", "0.6056591", "0.6034455", "0.603163...
0.8129482
0
Grouping sequences by names. All big sequences (genomes) with minsog <= size <= maxsog form separate group 'cds'
def grouping(filename, outdir, minsog, maxsog): records = Records(Extractor.extract_records(filename)) groups = records.group(minsog, maxsog) for key in groups: rw = RecordsWriter(groups[key]) rw.write_to_dir(key + ".fasta", outdir)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matched_gc_bedfile(bedfile, matchfile, genome, number, size=None, min_bin_size=100):\n g = Genome(genome)\n genome_fa = g.filename\n try:\n fa = Fasta(matchfile)\n gc = [\n (seq.upper().count(\"C\") + seq.upper().count(\"G\")) / len(seq)\n for seq in fa.seqs\n ...
[ "0.5756112", "0.56828934", "0.56537175", "0.5610272", "0.55583954", "0.5548302", "0.55069", "0.5499959", "0.5468516", "0.5450044", "0.5367102", "0.5361176", "0.53204", "0.52715933", "0.5266514", "0.52597445", "0.52575517", "0.5232715", "0.5223918", "0.52147275", "0.5207131", ...
0.667695
0
Filtrating NODES by depth of coverage
def node_filtrating(filename, out_file, min_cov): records = Records(Extractor.extract_records(filename)) fseqs = records.filtr_by_coverage(min_cov) RecordsWriter(fseqs).write_to(out_file)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_depth(self):\n # Filter min depth\n self._process_depth()\n self.variant_df = (\n self.variant_df[self.variant_df['depth'].astype(int) >= self.filter_min_depth]\n )\n self.filter_min_depth_count = self.variant_df.shape[0]\n \n # Which varia...
[ "0.5648252", "0.5573355", "0.5384248", "0.5363099", "0.5359775", "0.5296323", "0.5294423", "0.52645", "0.52515733", "0.5226289", "0.52007014", "0.5170509", "0.51680034", "0.51554215", "0.5151492", "0.5124049", "0.5122216", "0.5121461", "0.5120011", "0.5100876", "0.50957423", ...
0.0
-1
Choosing 'number_of_random_seqs' sequences from input file
def get_random(filename, out_file, number_of_random_seqs): records = Records(Extractor.extract_records(filename)) random_seqs = records.get_random_seqs(number_of_random_seqs) RecordsWriter(random_seqs).write_to(out_file)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate(infile, stype, Nmax, Sratio):\n seqnum = 0\n in_hdl = open(infile, 'rU')\n for i, rec in enumerate(seq_iter(in_hdl, stype)):\n head, seq, qual = split_rec(rec, stype)\n if Sratio < random.random():\n continue\n seqnum += 1\n for i in range(0, min(len(seq), Nmax)):\n if seq[i] ...
[ "0.66573983", "0.62153924", "0.6068362", "0.5974636", "0.5897258", "0.5821891", "0.5799525", "0.572137", "0.56889385", "0.5580425", "0.5575385", "0.5526401", "0.54891187", "0.5488105", "0.5463505", "0.5462464", "0.54535687", "0.54473186", "0.54237014", "0.5419824", "0.5417817...
0.57209414
8
Returns a path traversed as a list of nodes >>> find_path(graph, 'A', 'D') ['A', 'B', 'C', 'D']
def find_path(graph, current, destination, path=[]): # add the current node to the path (make a new list) path = path + [current] # base case: if at destination, return path if current == destination: return path # account of finding a dead end (current node won't be in destination list)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_path_list(path):\n # Build the path from end back to beginning.\n nodes = []\n prevevt = None\n while path is not None:\n nodes.append((path.node, path.cost, prevevt))\n prevevt = path.evt\n path = path.prev\n\n nodes.reverse()\n return nodes", "def FindAllPaths(gra...
[ "0.72664684", "0.71767503", "0.7060097", "0.7012164", "0.6995081", "0.68332803", "0.6807238", "0.6789579", "0.67001647", "0.669259", "0.6689304", "0.6689304", "0.6685149", "0.66804415", "0.6647207", "0.662338", "0.66042906", "0.65960294", "0.65557605", "0.65346605", "0.649494...
0.60688424
38
Returns a path traversed as a list of nodes >>> find_all_paths(graph, 'A', 'D') [['A', 'B', 'C', 'D'], ['A', 'B', 'D'], ['A', 'C', 'D']]
def find_all_paths(graph, current, destination, path=[]): path = path + [current] if current == destination: return path # difference: instead of returning none, return an empty path if current not in graph: reutrn [] # create a list for storing the results (because there will be...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_all_paths(graph, start, end, path=[]):\n path = path + [start]\n if start == end:\n return [path]\n paths = []\n for node in graph[start]:\n newpaths = find_all_paths(graph, node, end, path)\n paths += newpaths\n return paths", "def FindAllPaths(graph, start, end, pat...
[ "0.7848282", "0.78397405", "0.769525", "0.74181104", "0.732631", "0.7273335", "0.6806417", "0.67008454", "0.66901296", "0.6683576", "0.66729164", "0.6576661", "0.6574547", "0.65722877", "0.648524", "0.6438637", "0.64270836", "0.6400001", "0.63869977", "0.63869977", "0.6379887...
0.7405575
4
Returns the shortest path from current to destination >>> find_shortest_path(graph, 'A', 'D') ['A', 'C', 'D']
def find_shortest_path(graph, current, destination, path=[]): # create a new list so not to mess up the old ones in the stack path = path + [current] # base case: reached destination if current == destination: return path # base case: dead end if current not in graph: reutrn ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_shortest_path(graph, origin, destination):\n visited, paths = dijkstra(graph, origin)\n full_path = deque()\n if destination in paths: \n _destination = paths[destination]\n \n while _destination != origin:\n full_path.appendleft(_destination)\n _destinat...
[ "0.795193", "0.78015375", "0.7790324", "0.77879363", "0.7745128", "0.74809974", "0.7458702", "0.7440121", "0.74135613", "0.7371713", "0.7323594", "0.72594124", "0.72040826", "0.71902996", "0.7157731", "0.71473294", "0.71439856", "0.71418667", "0.7102424", "0.709848", "0.70925...
0.8252375
0
Convert a DAO action into a minimised cacheable action for running
def getRunable(action): if action == None: return None logger = logging.getLogger(ActionRunner.__name__) runners = ActionManager._getRunners() actionType = action.get('type', None) if type(action) == dict else action.type actionName = action.get('name', None) if type...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dbAction(tableName, action, data = None):\n return dbAction(tableName, action, data)", "def _make_get_action(self, problem: 'fpg.SingleProblem'):\n get_action = problem.policy.get_action\n\n # each get_action has an ephemeral cache (lasts only as long as the\n # closure does)\n ...
[ "0.61101186", "0.5683322", "0.5515421", "0.5402062", "0.5352329", "0.53427994", "0.530842", "0.51842004", "0.5183829", "0.5096476", "0.5076576", "0.5063152", "0.50524193", "0.5038725", "0.5029937", "0.50102973", "0.5001575", "0.5001575", "0.49974373", "0.4952946", "0.49526516...
0.0
-1
loads all modules from the specified path or the location of this file if none
def loadModules(path=None, ofType=None): """returns a dictionary of loaded modules {name: type}""" import os import re import sys import inspect if path == None: path = os.path.dirname(__file__) path = os.path.realpath(path) modules = [] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_all_from_path(self, path):\n\t\tshutit_global.shutit_global_object.yield_to_draw()\n\t\t#111: handle expanded paths\n\t\tpath = os.path.abspath(path)\n\t\t#http://stackoverflow.com/questions/301134/dynamic-module-import-in-python\n\t\tif os.path.abspath(path) == self.shutit_main_dir:\n\t\t\treturn\n\t\tif...
[ "0.6750016", "0.67261887", "0.66822255", "0.66168684", "0.6574759", "0.65597624", "0.652163", "0.6457934", "0.6347715", "0.6310861", "0.62701684", "0.62701684", "0.6229594", "0.6152436", "0.6144667", "0.61306804", "0.6123538", "0.610158", "0.6096284", "0.60883266", "0.6086696...
0.57231194
46
Convert a DAO action into a minimised cacheable action for running
def getRunable(self, action): with self.__cacheLock: if action.id not in self.__actionCache: runable = ActionRunner.getRunable(action) if runable: self.__actionCache[action.id] = runable else: return None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dbAction(tableName, action, data = None):\n return dbAction(tableName, action, data)", "def _make_get_action(self, problem: 'fpg.SingleProblem'):\n get_action = problem.policy.get_action\n\n # each get_action has an ephemeral cache (lasts only as long as the\n # closure does)\n ...
[ "0.6115393", "0.56830525", "0.54044443", "0.5355007", "0.5342594", "0.53098637", "0.51872104", "0.51862574", "0.50932115", "0.50800616", "0.5063965", "0.5054337", "0.50376827", "0.502614", "0.501315", "0.5004947", "0.5004947", "0.49987936", "0.49563733", "0.49554613", "0.4936...
0.5515059
2
Read CSV of real values, discard header, and return np.array.
def read_csv(path): rows = [] with open(path) as csv_file: reader = csv.reader(csv_file) header = reader.next() if header[0].isdigit(): print "Warning: Discarding header that looks like numbers." for line in reader: rows.append(map(float, line)) return...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_csv(fn):\n def iter_func():\n with open(fn, 'r') as infile:\n for line in infile:\n line = line.rstrip().split(',')\n for item in line:\n yield float(item)\n load_csv.rowlength = len(line)\n data = np.fromiter(iter_func(), dty...
[ "0.74260634", "0.73615754", "0.73608273", "0.7234256", "0.71963465", "0.71692055", "0.7078709", "0.7071126", "0.70160156", "0.69875634", "0.6977693", "0.69723463", "0.6876044", "0.6843938", "0.68314666", "0.6830467", "0.6777699", "0.67618006", "0.67560637", "0.674022", "0.672...
0.7816146
0
Compute error between trajectories, in the same way as the evaluator does.
def compute_error(ground_traj, my_traj): # Times should match. if ground_traj.shape != my_traj.shape: raise ValueError("ground_traj and my_traj must have the same shape") if np.max(np.abs(ground_traj[:, 0] - my_traj[:, 0])) > 1e-2: raise ValueError("ground_traj and my_traj must have the same...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_error(self):\n self.network.index_nodes()\n self._calculate_dist()\n _, relative_error = self._relative_error()\n _, absolute_error = self._absolute_error()\n\n return absolute_error, relative_error", "def error_compute(self):\n self.tt_error = np.linalg.no...
[ "0.6950507", "0.67691797", "0.67502916", "0.67078394", "0.67011106", "0.66048974", "0.659607", "0.6542348", "0.65378225", "0.65197235", "0.6489393", "0.64892244", "0.64224684", "0.63903004", "0.63893247", "0.638688", "0.63164365", "0.62759715", "0.6271543", "0.62648964", "0.6...
0.6239897
22
The default function used to render files. Could be modified to change the way files are generated, like using another template language or transforming css...
def add_url_rules(self): self.app.add_url_rule("/", "root", lambda: self.file_renderer("index.html"), methods=["GET", "POST", "PUT", "DELETE"]) self.app.add_url_rule("/<path:path>", "all_files", lambda path: self.f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __html__(self, file_path:str):\n raise NotImplementedError", "def _render_file(\n self,\n abs_fpath: Text,\n template_name: Text,\n context: Dict,\n style_config: Dict = None\n ) -> None:\n try:\n say(f'rendering {abs_fpath[1+len(self.embryo.dest...
[ "0.6522621", "0.64203477", "0.63753915", "0.63064194", "0.63041025", "0.6298991", "0.61129564", "0.6083517", "0.6083517", "0.6083517", "0.6083517", "0.6083517", "0.6083517", "0.60774666", "0.60395956", "0.60296714", "0.59988284", "0.5988884", "0.5949167", "0.5932408", "0.5927...
0.0
-1
Sets the folder where the files to serve are located.
def set_folder(self, folder): self.folder = folder self.templates.directories[0] = folder self.app.root_path = folder
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_source_path(self, folder):\n self.source_path = folder", "def set_path(self, directory):\n self.directory = directory", "def set_folders(self):\n self._tst_dir = self._val_dir = self._trn_dir = self._ds_root\n self._lbl_dir = f\"{self._ds_root}/flow\"\n self._pred_lbl...
[ "0.66856587", "0.655048", "0.63288397", "0.62536454", "0.61302406", "0.6127417", "0.6106902", "0.6060303", "0.6058627", "0.602844", "0.5978206", "0.5976438", "0.5973507", "0.5962767", "0.59565043", "0.5955999", "0.594277", "0.59424734", "0.59265566", "0.59138876", "0.5892181"...
0.75043386
0
Launch a development web server.
def run(self, host="0.0.0.0", port=8080): self.app.run(host=host, port=port, debug=True, use_reloader=False, use_evalex=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def webserver_start():\n run(_webserver_command())", "def simple_serve(self, host='0.0.0.0', port=8000):\n from wsgiref.simple_server import make_server\n srv = make_server(host, port, self)\n print \"Development server is running at http://%s:%d/\" % (\n host, port\n ...
[ "0.7795172", "0.7794163", "0.77848685", "0.7511417", "0.73983884", "0.7384723", "0.7367317", "0.7326459", "0.7192222", "0.7148261", "0.7135434", "0.71101505", "0.7082086", "0.70665", "0.70603186", "0.70330197", "0.69989824", "0.6959967", "0.69555545", "0.69486344", "0.6909088...
0.64000684
74
Get the content of a file, identified by its path relative to the folder configured in PyGreen. If the file extension is one of the extensions that should be processed through Mako, it will be processed.
def get(self, path): data = self.app.test_client().get("/%s" % path).data return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_content_from_file(path):\n\n\t\tPathUtil.ensure_path_exists(path)\n\t\twith open(path) as file:\n\t\t\tfile_content = file.read()\n\t\treturn file_content", "def get_content(self, file_path:str):\n raise NotImplementedError", "def get_file(self, path):\n return self.client._perform_raw(\n...
[ "0.71196485", "0.65549153", "0.64946806", "0.6434018", "0.6413258", "0.6390974", "0.63395375", "0.6319829", "0.62987125", "0.6274472", "0.6264581", "0.625992", "0.6251346", "0.61457205", "0.61426616", "0.61313736", "0.61120045", "0.6101976", "0.60994655", "0.60993254", "0.608...
0.0
-1
Generates a complete static version of the web site. It will stored in output_folder.
def gen_static(self, output_folder): files = [] for l in self.file_listers: files += l() for f in files: _logger.info("generating %s" % f) content = self.get(f) loc = os.path.join(output_folder, f) d = os.path.dirname(loc) i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_static_site(self, output_root=None, extra_context=None):\n self.app.config['BUILD_PATH'] = output_root\n\n # use this hook for registering URLs to freeze\n self.call_hook(\"generate\", self, output_root, extra_context)\n\n if output_root is not None:\n # realpath...
[ "0.75036", "0.6963644", "0.6765069", "0.65228844", "0.6497136", "0.6364944", "0.62506604", "0.604287", "0.603249", "0.60303116", "0.5984128", "0.5968583", "0.59599876", "0.5941046", "0.592738", "0.59084713", "0.58983976", "0.5872566", "0.58616793", "0.58607596", "0.5845612", ...
0.72529495
1
The command line interface of PyGreen.
def cli(self, cmd_args=None): logging.basicConfig(level=logging.INFO, format="%(message)s") parser = argparse.ArgumentParser(description="PyGreen, micro web" "framework/static web site generator") subparsers = parser.add_subparsers(dest="action") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n log(\"NGG CLI\", color=\"green\", figlet=True)\n log(\"Welcome to NGG CLI!\", \"yellow\")", "def cli(args): # noqa; pylint: disable=unused-argument", "def cli():\n pass", "def cli():\r\n pass", "def cli():\n\n pass", "def cli():", "def cli():", "def cli():", "def c...
[ "0.71764106", "0.71015185", "0.7090273", "0.70492554", "0.70333487", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853", "0.7025853",...
0.0
-1
Create a new plans connection.
def __init__(self, cookiejar=None, base_url="https://www.grinnellplans.com", server_tz='US/Central'): self.base_url = base_url self.server_tz = server_tz if cookiejar is None: self.cookiejar = LWPCookieJar() else: self.cookiejar =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(cls, **kwargs):\n return cls().requests.post('plan', data=kwargs)", "def create_braintree():\n\n #TODO: plan_id and user_id should be unique, I should be updating \n # old plans if they get reactivated. Implement logic to check this in future.\n # otherwise you can end up w...
[ "0.69688904", "0.6421147", "0.6183206", "0.6174355", "0.6007265", "0.59455025", "0.5826983", "0.5819598", "0.58150625", "0.5782099", "0.57642585", "0.5752312", "0.5740514", "0.569669", "0.5691675", "0.5687894", "0.5668671", "0.5652751", "0.56519735", "0.56460345", "0.563512",...
0.0
-1
Retrieve an HTML page from plans.
def _get_page(self, name, get=None, post=None): method = 'GET' if post is None else 'POST' url = '/'.join((self.base_url, name)) req = requests.Request(method, url, params=get, data=post) prepped = self.session.prepare_request(req) try: handle = self.session.send(prep...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_page(self):\n self.browser.get(self.url)", "def request_html_page(self):\n try:\n response = requests.get('http://www.indeed.com/jobs?', params=self.payload)\n except:\n print \"got error for \", self.payload\n self.page = response.content", "def read_p...
[ "0.67057174", "0.6517088", "0.6384331", "0.62347746", "0.6232917", "0.61664104", "0.61631536", "0.6113468", "0.60962486", "0.60706925", "0.6066584", "0.60514754", "0.6013905", "0.600338", "0.600326", "0.5969021", "0.595881", "0.5953506", "0.5936332", "0.59244865", "0.5920143"...
0.66219044
1
Scrape details from an infomessage or alertmessage div. Returns a dictionary of the message parameters.
def _parse_message(self, soup): kind, = soup.attrs[u'class'] title = soup.findChild().text body = ''.join(t.text for t in soup.findChildren()[1:]) message = dict(kind=kind, title=title, body=body) for val in message.values(): assert type(val) == str return mes...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_information(self):\n info_dict = {}\n table = self._tab.find('table', class_='details')\n for row in table.find_all('tr'):\n row_key, row_value = row.find(class_='key'), row.find(class_='value')\n key_with_emoji, value = self._get_key(row_key), self._get_value(ro...
[ "0.58449465", "0.5690405", "0.5635112", "0.5574967", "0.5535075", "0.55201256", "0.54977244", "0.54909134", "0.54823315", "0.5447042", "0.53833103", "0.53693163", "0.5342092", "0.5276265", "0.52326083", "0.5221449", "0.5215469", "0.52002853", "0.51924163", "0.5170039", "0.515...
0.69118416
0
Modify reserialized plan text to match what was served. For consistency, we want to return plan text exactly how it is formatted when served. However, variants of certain tags (e.g. vs ) are syntactically equivalent in HTML, and may be interchanged when parsed and reserialized. This function manually changes the format...
def _canonicalize_plantext(self, plan): # Our parser will correct <hr> and <br> to self closing tags plan = plan.replace('<br/>', '<br>') plan = plan.replace('<hr/>', '<hr>') # put attributes in the right order because I have OCD plan = re.sub(r'<a class="([^\s]*)" href="([^\s]*)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _format_plan(plan, server_root=None):\n formatted_plan = {}\n \n formatted_plan['url'] = plan['details_link']\n \n # special emphasizing for some statuses\n if plan['status'] in [u'פרסום ההפקדה', u'פרסום בעיתונות להפקדה']:\n formatted_plan['status'] = u'»»%s««' % plan['status']\n ...
[ "0.58597666", "0.5456841", "0.54195154", "0.53886324", "0.5373414", "0.519596", "0.5175126", "0.51720506", "0.50811565", "0.50582194", "0.5008377", "0.49972737", "0.49566457", "0.49039185", "0.48758507", "0.48473752", "0.48365143", "0.483133", "0.48018774", "0.47815216", "0.4...
0.70790404
0
Replaces certain characters with html escape sequences. Meant to be passed to the BS4 'decode' method as kwarg 'formatter'. By default, BS4 only replaces angle brackets and ampersands with the html escape sequence, but text served by plans also replaces double quotes. This function as BS4's decoding formatter reproduce...
def _html_esc(string): repls = { '<': 'lt', '>': 'gt', '&': 'amp', '"': 'quot', } def repl(matchobj): return "&%s;" % repls[matchobj.group(0)] regex = "([%s])" % ''.join(repls.keys()) return re.sub(regex, repl, str...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _encode_html(data: str) -> str:\n return html.escape(data)", "def escape(cls, html):\n return (\"%s\" % (html)).replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('\"', '&quot;').replace(\"'\", '&#39;')", "def html_escape(text):\n return escape(text, escape_table)", "def...
[ "0.6041999", "0.6001357", "0.5937263", "0.5928207", "0.5897953", "0.5887988", "0.5655075", "0.5641861", "0.56185764", "0.5613647", "0.5609032", "0.5598732", "0.5588397", "0.5527701", "0.5468966", "0.54454094", "0.5407489", "0.53922653", "0.5390489", "0.5390489", "0.5384055", ...
0.55243915
14
Log into plans. Returns True on success, False on failure. Leave username and password blank to check an existing login.
def plans_login(self, username='', password=''): # the provided username and password ONLY get checked # by the plans server if our cookie is expired. # hence, if we've logged in recently, this will return True even # if un/pw are not provided or are otherwise bad. login_info = {...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login(self, **kwargs):\n\tusername = kwargs.get('username', self.username)\n\tif not username:\n\t raise RuntimeError, 'no username provided'\n\n\tpassword = kwargs.get('password', self.password)\n\tif not password:\n\t raise RuntimeError, 'no password provided'\n\tself.call('login', username=username, p...
[ "0.7139568", "0.6889871", "0.67902976", "0.6775025", "0.6765618", "0.6733587", "0.67126477", "0.67060435", "0.66989684", "0.6696499", "0.6692889", "0.6689874", "0.66540337", "0.664666", "0.66113514", "0.6604015", "0.658291", "0.6582731", "0.65772784", "0.6559419", "0.65449303...
0.8137354
0
Retrieve contents of the edit plan field. Returns the edit_text of the plan and its md5 hash, as computed on the server side.
def get_edit_text(self): # grab edit page response = self._get_page('edit.php') html = response.text # parse out existing plan soup = bs4.BeautifulSoup(html, 'html5lib') plan = soup.find('textarea') if plan is None: raise PlansError("Couldn't get edit ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_edit_text(self, newtext, md5):\n # convert to CRLF line endings\n newtext = convert_endings(newtext, 'CRLF')\n newtext = newtext.encode('utf8')\n edit_info = {'plan': newtext,\n 'edit_text_md5': md5,\n 'submit': 'Change Plan'}\n res...
[ "0.6568089", "0.5453729", "0.54037726", "0.5280627", "0.5272245", "0.52441514", "0.52441514", "0.5230294", "0.52111316", "0.51553506", "0.5128909", "0.5118174", "0.5097198", "0.508127", "0.5076953", "0.50690055", "0.50560534", "0.5046793", "0.5027376", "0.5024969", "0.5024644...
0.8520785
0
Update plan with new content. To prevent errors, the server does a hash check on the existing plan before replacing it with the new one. We provide an md5 sum to confirm that yes, we really want to update the plan. Returns info message.
def set_edit_text(self, newtext, md5): # convert to CRLF line endings newtext = convert_endings(newtext, 'CRLF') newtext = newtext.encode('utf8') edit_info = {'plan': newtext, 'edit_text_md5': md5, 'submit': 'Change Plan'} response = self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(cls, plan_id, **kwargs):\n return cls().requests.put(f\"plan/{plan_id}\", data=kwargs,)", "def put(self):\n request_data = request.get_json()\n plan = request_data[\"plan\"]\n\n user = get_authenticated_user()\n if not user.stripe_id:\n raise InvalidReques...
[ "0.6790178", "0.59503996", "0.59245706", "0.5458895", "0.5327665", "0.5283632", "0.5098079", "0.50921404", "0.50861126", "0.50642353", "0.504313", "0.5035372", "0.5021408", "0.4985128", "0.4948604", "0.4918588", "0.48822698", "0.48791012", "0.4851006", "0.4837955", "0.483735"...
0.66878754
1
Retrieve all levels of the autofinger (autoread) list. Returns a dictionary where the keys are the group names "Level 1", "Level 2", etc. and the values are a list of usernames waiting to be read.
def get_autofinger(self): # this actually doesn't scrape; there's a function for it # in the old JSON API. get = {'task': 'autofingerlist'} response = self._get_page('api/1/index.php', get=get) data = json.loads(response.text) # the returned JSON is crufty; clean it up ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_levels(self):\n return self.levels[self.game]", "def get_all_game_levels(self):\n\n self._katakana_database.create_katakana_database_connection()\n\n raw_game_levels = self._katakana_database.katakana_db.execute(\n \"\"\"SELECT game_level FROM Games\"\"\").fetchall()\n\n ...
[ "0.58031774", "0.57258826", "0.5678139", "0.5663194", "0.55516225", "0.5483187", "0.54111844", "0.53925604", "0.5388561", "0.53229", "0.5307335", "0.52984476", "0.5274611", "0.52675277", "0.52212065", "0.5218664", "0.52143294", "0.519101", "0.5178574", "0.51685023", "0.516397...
0.7340584
0
Retrieve the contents of the specified plan.
def read_plan(self, plan): get = {'searchname': plan} response = self._get_page('read.php', get=get) soup = bs4.BeautifulSoup(response.text, 'html5lib') header = soup.find('div', {'id': 'header'}) text = soup.find('div', {'class': 'plan_text'}) if text is None or header i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(cls, plan_id):\n return cls().requests.get(f\"plan/{plan_id}\")", "def get_plan(self):\n\t\tresponse = self.client.get(self._endpoint + \"/plan\")\n\t\tplan = response.json['plans']\n\t\tplan = list(plan.items())[0][1]\n\t\treturn Plan(plan['plan_id'],data=plan)", "def plan(self):\n retur...
[ "0.7595697", "0.68826216", "0.6555645", "0.6532035", "0.6414922", "0.6344742", "0.6237968", "0.6152344", "0.6084125", "0.58835685", "0.5860761", "0.5853679", "0.57456356", "0.57375413", "0.5712769", "0.5614542", "0.559101", "0.5515008", "0.547179", "0.54412735", "0.535815", ...
0.74009657
1
Search plans for the provided ``term``. If ``planlove`` is ``True``, ``term`` is a username, and the search will be for incidences of planlove for that user.
def search_plans(self, term, planlove=False): get = {'mysearch': term, 'planlove': int(bool(planlove))} response = self._get_page('search.php', get=get) soup = bs4.BeautifulSoup(response.text, 'html5lib') results = soup.find('ul', {'id': 'search_results'}) if resul...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_plan(self, plan_id, term=None):\n\t\tdata = {\"plan_id\":plan_id}\n\t\tif term:\n\t\t\tdata.update({\"term\":term})\n\t\tresponse = self.client.post(self._endpoint + \"/plan\", content=data)\n\t\treturn bool(response.json[\"success\"])", "def search(self, term):", "def find_by_plan_name(cls, name, exac...
[ "0.56900036", "0.54435796", "0.5083996", "0.5057897", "0.50346243", "0.50073344", "0.48131078", "0.48111796", "0.4802479", "0.47961777", "0.47269177", "0.47260118", "0.46963114", "0.46709058", "0.46331495", "0.45926642", "0.45773494", "0.45730287", "0.45207572", "0.44550562", ...
0.71705884
0
Return plans updated in the last ``hours`` hours. The result is a list of (username, timestamp) 2tuples.
def planwatch(self, hours=12): post = {'mytime': str(hours)} response = self._get_page('planwatch.php', post=post) soup = bs4.BeautifulSoup(response.text, 'html5lib') results = soup.find('ul', {'id': 'new_plan_list'}) new_plans = results.findAll('div', {'class': 'newplan'}) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_last_x_hours(*, db_session, hours: int = 24) -> List[Optional[Feedback]]:\n return (\n db_session.query(Feedback)\n .filter(Feedback.created_at >= datetime.utcnow() - timedelta(hours=hours))\n .all()\n )", "def wholasthr(sock, request):\n users = set()\n for s in hist...
[ "0.57179016", "0.55829984", "0.54386723", "0.5415785", "0.53141874", "0.5197795", "0.5095239", "0.5065263", "0.5055699", "0.5026268", "0.49488553", "0.49171332", "0.4909176", "0.48759073", "0.48730665", "0.485017", "0.4826249", "0.4817359", "0.47765937", "0.47737122", "0.4742...
0.6832343
0
takes no arguments Shows the status of the Mojang servers.
def mcstatus(self, irc, msg, args): prefix = self.registryValue('prefix') suffix = self.registryValue('suffix') separator = self.registryValue('separator') svprefix = self.registryValue('service.prefix') svsuffix = self.registryValue('service.suffix') stonline = self.r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sipserver_status(self) -> str:", "def status(server: str):\n\n if isUp(server):\n log.info(f'{server} is running.')\n else:\n log.info(f'{server} is not running.')", "def get_status(self):\n if self.status:\n print(f\"Server '{self.server_name}' is online\")\n e...
[ "0.70075613", "0.6895697", "0.6858163", "0.68047506", "0.68031174", "0.6404232", "0.63945913", "0.62851596", "0.6235976", "0.6235821", "0.61945754", "0.61489874", "0.6148637", "0.61408997", "0.6126328", "0.6122078", "0.6113205", "0.61028606", "0.6089987", "0.6089973", "0.6087...
0.6651979
5
Return the list of locations described by the given string.
def get_location_list(loc): if loc == 'all': return Locations.region_list elif loc == 'hhs': return Locations.hhs_list elif loc == 'cen': return Locations.cen_list elif loc in Locations.region_list: return [loc] else: raise UnknownLocationException('unknown location: %s' % str(loc))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locations(self, text):\n\n response = self._send_request(\"locations\", dict(text=text))\n return response[self._layer]['locations']", "def __parse_uri_and_location(cls, uri_loc_str):\n # type: (str) -> List[str]\n split_uri_location = uri_loc_str.split('//') # type: List[str, st...
[ "0.7137194", "0.64971626", "0.61824524", "0.61119884", "0.6105019", "0.6089954", "0.60780364", "0.60548824", "0.60450953", "0.602286", "0.5991559", "0.5972784", "0.5936607", "0.5890959", "0.58109415", "0.5796555", "0.57864577", "0.5785032", "0.5761079", "0.57338774", "0.57248...
0.68343097
1
Simple function to compute the dot product for any number of arguments.
def dot(*Ms): N = Ms[0] for M in Ms[1:]: N = np.dot(N, M) return N
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dotProduct(v1, v2):\n return sum((a * b) for a, b in zip(v1, v2))", "def dotproduct(v1, v2):\n\treturn sum(imap(operator.mul, v1, v2))", "def dot_product(a, b):\n a1, a2, a3 = a\n b1, b2, b3 = b\n return a1 * b1 + a2 * b2 + a3 * b3", "def dotproduct(vec1, vec2):\n return sum((a*b) for a, b...
[ "0.78134674", "0.7769241", "0.77504635", "0.7745433", "0.77197284", "0.77065027", "0.7691163", "0.7675378", "0.76714635", "0.7669843", "0.76356405", "0.7633193", "0.7629635", "0.7625092", "0.7574043", "0.74101996", "0.7398503", "0.7380813", "0.7374599", "0.73743266", "0.73453...
0.7135117
35
This function gives the weight between two given
def get_weight(ew1, ew2): dw = flu.delta_epiweeks(ew1, ew2) yr = 52.2 hl1, hl2, bw = yr, 1, 4 a = 0.05 #b = (np.cos(2 * np.pi * (dw / yr)) + 1) / 2 b = np.exp(-((min(dw % yr, yr - dw % yr) / bw) ** 2)) c = 2 ** -(dw / hl1) d = 1 - 2 ** -(dw / hl2) return (a + (1 - a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weight(self):", "def get_weight(self, val1, val2):\n\n\t\tnode1 = self.get_node(val1)\n\t\tnode2 = self.get_node(val2)\n\n\t\treturn node1.get_weight(node2)", "def get_weights(self):", "def weight(fragment_one, fragment_two):\n return overlap(fragment_one, fragment_two)[\"weight\"]", "def getWeight(...
[ "0.7597948", "0.749667", "0.7428421", "0.7412348", "0.74093145", "0.7255503", "0.7182084", "0.7080902", "0.7044499", "0.7044499", "0.7021739", "0.6966589", "0.6966368", "0.6955854", "0.68491995", "0.68452686", "0.68178153", "0.6802609", "0.6730282", "0.67078024", "0.66917276"...
0.75268966
1
Return a map from sensor names to sensor implementations.
def get_sensor_implementations(): return { 'cdc': SensorGetter.get_cdc, 'gft': SensorGetter.get_gft, 'ght': SensorGetter.get_ght, 'ghtj': SensorGetter.get_ghtj, 'twtr': SensorGetter.get_twtr, 'wiki': SensorGetter.get_wiki, 'epic': SensorGetter.get_epic, 'sar3': Sensor...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sensor_classes(self):\n raise NotImplementedError", "def data_setup_sensors():\n sensor_list = []\n sensor_list.append(helper_setup_sensors(factory_type_constant=SENSOR_TYPE_NAME_BASIC, sensor_name=\"Sensor1\",\n interval_between_readings=0.5, gpio_pin_...
[ "0.6515089", "0.6204054", "0.6149236", "0.6029666", "0.58729976", "0.5745948", "0.56258994", "0.5501529", "0.5487855", "0.5483462", "0.5429596", "0.5414457", "0.5409554", "0.5395443", "0.5390384", "0.5390307", "0.537485", "0.536558", "0.53442913", "0.53433913", "0.5331139", ...
0.78985685
0
Return a new instance under the default configuration. If `test_mode` is True, database changes will not be committed. If `valid` is True, be punctilious about hiding values that were not known at the time (e.g. run the model with preliminary ILI only). Otherwise, be more lenient (e.g. fall back to final ILI when preli...
def new_instance(valid, test_mode): database = SensorsTable(test_mode=test_mode) implementations = SensorGetter.get_sensor_implementations() return SensorUpdate(valid, database, implementations, Epidata)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_init_sets_new_record_true(self):\n t = self.Test({'id': 1})\n self.assertEqual(t.new_record, True)", "def test_should_allow_override_new_record(self):\n t = self.Test({'id': 1}, False)\n self.assertEqual(t.new_record, False)", "def test_without_localsite_and_instance(self):...
[ "0.5668509", "0.5581067", "0.5511822", "0.54761374", "0.544532", "0.5387868", "0.51298994", "0.50898963", "0.50549924", "0.5037492", "0.5034233", "0.50265735", "0.50178486", "0.5004177", "0.49780762", "0.49308074", "0.4918332", "0.49153453", "0.48976803", "0.48928562", "0.488...
0.63489234
0
Compute sensor readings and store them in the database.
def update(self, sensors, first_week, last_week): # most recent issue if last_week is None: last_issue = get_most_recent_issue(self.epidata) last_week = flu.add_epiweeks(last_issue, +1) # connect with self.database as database: # update each sensor for (name, loc) in sensors: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_sensors():\n previous_time = datetime.datetime.now()\n while True:\n now = datetime.datetime.now()\n delta = now - previous_time\n if delta.seconds >= sample_frequency:\n previous_time = now\n \n # Read SGP30.\n eCO2_data = sgp30.eCO2\...
[ "0.6982229", "0.65869653", "0.6440083", "0.6241772", "0.6178187", "0.61286074", "0.61118394", "0.61036783", "0.60655683", "0.5961161", "0.5933579", "0.5907834", "0.58470625", "0.5843758", "0.58304673", "0.5827662", "0.5827526", "0.58233434", "0.58143485", "0.5812172", "0.5811...
0.5543317
50
Define command line arguments and usage.
def get_argument_parser(): parser = argparse.ArgumentParser() parser.add_argument( 'names', help=( 'list of name-location pairs ' '(location can be nat/hhs/cen/state or specific location labels)')) parser.add_argument( '--first', '-f', type=int, help='first epiw...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cli(*args, **kwargs):\n logger.debug('Global options: %s %s', args, kwargs)", "def command_line_arguments():\n\n try:\n parser = argparse.ArgumentParser(description='Log Handler/Cleaner/Copier for Idemia DocAuth')\n\n # Add required arguments.\n parser.add_argument('action', choice...
[ "0.7006882", "0.6948284", "0.69385046", "0.68831253", "0.68324584", "0.6808746", "0.6782646", "0.6782646", "0.67756796", "0.6771529", "0.6764597", "0.67637885", "0.6752061", "0.6752036", "0.6728036", "0.6728036", "0.6719274", "0.67192507", "0.6690765", "0.6690158", "0.6685729...
0.0
-1
Validate and return command line arguments.
def validate_args(args): # check epiweek specification first, last, week = args.first, args.last, args.epiweek for ew in [first, last, week]: if ew is not None: flu.check_epiweek(ew) if week is not None: if first is not None or last is not None: raise ValueError('`week` overrides `first` an...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_args(self):\n\n parser = argparse.ArgumentParser()\n\n parser.add_argument(\"-v\", \"--verbose\", help=\"Verbose output\", action=\"store_true\")\n parser.add_argument(\"-u\", \"--user\", help=\"Google user email\", default=\"none\")\n parser.add_argument(\"-p\", \"--passwo...
[ "0.74674934", "0.7430625", "0.7324546", "0.7099893", "0.70423096", "0.70077944", "0.699008", "0.69539267", "0.69271064", "0.6921724", "0.68958116", "0.68878037", "0.6875644", "0.68630856", "0.68599313", "0.6855719", "0.6851292", "0.68397874", "0.6805709", "0.6797193", "0.6786...
0.0
-1
Run this script from the command line.
def main(names, first, last, valid, test): sensors = parse_sensor_location_pairs(names) SensorUpdate.new_instance(valid, test).update(sensors, first, last)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cli():\n config, auth, execute_now = read_command_line_arguments()\n main(config, auth, execute_now)", "def cli(args): # noqa; pylint: disable=unused-argument", "def cli():\n pass", "def main(args):\n cli = CLI()\n # Check arguments\n cli.parse_arguments(args)", "def main():\n ...
[ "0.7775219", "0.7535169", "0.74355435", "0.73831856", "0.7328765", "0.7328765", "0.72032243", "0.72032243", "0.71506023", "0.71403795", "0.71403795", "0.71139437", "0.7071265", "0.7071265", "0.70711195", "0.70711195", "0.70711195", "0.70711195", "0.70711195", "0.70711195", "0...
0.0
-1
list permissions used in templates
def list_perms(request): perms = {} if request.user.is_authenticated(): perms['add_topic'] = True perms['add_post'] = True perms['is_authenticated'] = True perms['is_staff'] = request.user.is_staff else: perms['add_topic'] = False perms['add_post'] = False perms['is_staff'] = False return perms
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def permission_list(**kwargs):\n print(AppPermissionSchema(many=True).dumps(\n get_protected_routes(ignored_methods=[\"HEAD\", \"OPTIONS\"]), indent=4))", "def permissions():\n pass", "def permissions(self) -> str:\n return pulumi.get(self, \"permissions\")", "def get_all_permissions(self...
[ "0.7330155", "0.73252463", "0.6927797", "0.67907023", "0.66946787", "0.6682144", "0.66767126", "0.66701114", "0.66510206", "0.6643761", "0.6621216", "0.6604725", "0.6581306", "0.6578102", "0.6531585", "0.65114266", "0.64841914", "0.64747757", "0.6425503", "0.63908136", "0.638...
0.71656454
2
show all categories and their topics
def category_list(request): categories = Category.objects.all().order_by('cat_order') for c in categories: c.forums = c.forum_set.all().order_by('forum_order') return render_to_response( 'myghtyboard/category_list.html', {'categories': categories, 'perms': list_perms(request)}, context_instance=RequestContex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def showCategories():\n\n categories = session.query(Category).order_by(asc(Category.name))\n if 'user_id' in login_session:\n return render_template('categories.html',\n categories=categories,\n user=getUserInfo(login_session['user_id']))\n ...
[ "0.74436486", "0.73301286", "0.7237427", "0.7130857", "0.711074", "0.70704", "0.7024587", "0.65996", "0.6590475", "0.65062934", "0.6494746", "0.64839023", "0.6467843", "0.64467144", "0.631909", "0.63165766", "0.6301418", "0.62555647", "0.6252903", "0.620064", "0.61931735", ...
0.7048116
6
list of topics in a forum forum_id id of a Forum record
def topic_list(request, forum_id, pagination_id=1): try: topics = Topic.objects.order_by('-is_global', '-is_sticky', '-topic_modification_date').filter(Q(topic_forum=forum_id) | Q(is_global='1')) forum_name = Forum.objects.get(id=forum_id) forum_name = forum_name.forum_name except: return HttpResponseRedirect...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_topics(project_id):\n project_path = f\"projects/{project_id}\"\n for topic in PUBLISHER_CLIENT.list_topics(request={\"project\": project_path}):\n print(topic)", "def get_teacher_topic_all():\n topic_data = query_db(\n \"SELECT topics.id, topics.name, classes.name FROM topics JOI...
[ "0.71958566", "0.7154457", "0.7141806", "0.70193803", "0.68313867", "0.68131095", "0.6796887", "0.67777157", "0.66847396", "0.6667825", "0.6666503", "0.658895", "0.65878844", "0.64640737", "0.64293224", "0.64095646", "0.63564235", "0.6342142", "0.63283175", "0.6324823", "0.62...
0.8021172
0
list my topics show_user if not set will show current user topics
def my_topic_list(request, show_user=False): if not show_user: show_user = str(request.user) if request.user.is_authenticated(): topics = Topic.objects.order_by('-topic_modification_date').filter(topic_author=show_user)[:50] forum_name = _('User Topics') return render_to_response( 'myghtyboard/mytopics_lis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_posttopic_list(request, show_user=False):\n\tif not show_user:\n\t\tshow_user = str(request.user)\n\ttry:\n\t\ttopics = Post.objects.order_by('-post_date').filter(post_author=show_user).values('post_topic').distinct()[:50]\n\t\tposts = []\n\t\tfor i in topics:\n\t\t\tposts.append(int(i['post_topic']))\n\t\t...
[ "0.7587987", "0.68615746", "0.6584963", "0.6520831", "0.6474204", "0.641011", "0.6235148", "0.6221391", "0.621017", "0.61582536", "0.61340994", "0.61294705", "0.6119274", "0.6069664", "0.60405356", "0.5981129", "0.59676176", "0.59621197", "0.5931718", "0.59281045", "0.5925600...
0.8401827
0
list last active topics
def last_topic_list(request): topics = Topic.objects.order_by('-topic_modification_date')[:50] for i in topics: pmax = i.post_set.all().count()/10 pmaxten = i.post_set.all().count()%10 if pmaxten != 0: i.pagination_max = pmax+1 else: i.pagination_max = pmax forum_name = _('Last Active Topics') retur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_topics(self):\r\n return [x[0] for x in get_published_topics()]", "def topics(ctx):\n pass", "def get_topics(self):\n try:\n with self.__db_lock:\n sql = \"SELECT * FROM 'topics' ORDER BY 'name' ASC\"\n self.__cursor.execute(sql)\n ...
[ "0.705034", "0.64365596", "0.64050555", "0.6391744", "0.6317153", "0.6284976", "0.6268085", "0.6266705", "0.6239917", "0.6173365", "0.61572224", "0.6146802", "0.6092059", "0.60849684", "0.60842997", "0.60330325", "0.5987122", "0.59789485", "0.59581673", "0.5916904", "0.588488...
0.790725
0
list topics with my posts show_user if not set will show current user topics
def my_posttopic_list(request, show_user=False): if not show_user: show_user = str(request.user) try: topics = Post.objects.order_by('-post_date').filter(post_author=show_user).values('post_topic').distinct()[:50] posts = [] for i in topics: posts.append(int(i['post_topic'])) topics = Topic.objects.order...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_topic_list(request, show_user=False):\n\tif not show_user:\n\t\tshow_user = str(request.user)\n\tif request.user.is_authenticated():\n\t\ttopics = Topic.objects.order_by('-topic_modification_date').filter(topic_author=show_user)[:50]\n\t\tforum_name = _('User Topics')\n\t\treturn render_to_response(\n\t\t\t...
[ "0.79176843", "0.68020207", "0.67652315", "0.6761055", "0.63410634", "0.6285622", "0.6211213", "0.61485666", "0.61334693", "0.61277074", "0.6119535", "0.61154777", "0.5989955", "0.5977707", "0.5962294", "0.5931599", "0.59149337", "0.5904821", "0.5894907", "0.58528423", "0.584...
0.803661
0
list post in topic with a generic pagination view topic_id id of a Topic entry
def post_list(request, topic_id, pagination_id): try: topic = Topic.objects.get(id=topic_id) except Topic.DoesNotExist: return HttpResponseRedirect('/forum/') if topic.is_locked: opened = False else: opened = True return object_list( request, topic.post_set.all().order_by('post_date'), paginate_by =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def topic(request, topic_id):\n posts = Post.objects.filter(topic=topic_id).order_by(\"created\")\n posts = mk_paginator(request, posts, DJANGO_SIMPLE_FORUM_REPLIES_PER_PAGE)\n topic = Topic.objects.get(pk=topic_id)\n return render_to_response(\"forum/topic.html\", add_csrf(request, posts=posts, pk=top...
[ "0.73865634", "0.7367165", "0.7171377", "0.69603044", "0.6776185", "0.6757272", "0.6622475", "0.66060674", "0.656054", "0.6419013", "0.6396373", "0.6345073", "0.6312444", "0.6294844", "0.6284002", "0.6277948", "0.62343496", "0.61232275", "0.60641515", "0.60380805", "0.6028233...
0.7904134
0
add topic forum_id ID of a Forum entry
def add_topic(request, forum_id): if request.POST: page_data = request.POST.copy() page_data['topic_author'] = str(request.user) tags = findall( r'(?xs)\[code\](.*?)\[/code\]''', page_data['text']) for i in tags: page_data['text'] = page_data['text'].replace(u'[code]'+i+u'[/code]', u'[code]'+base64.enco...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(self, project_id, forum):\n url = base_url + 'portal/' + str(self.portal_id) + '/projects/' + str(project_id) + '/forums/' \n data = parser.to_json(forum)\n if forum.get_upload_file():\n file_list = []\n for value in forum.get_upload_file():\n attac...
[ "0.6570903", "0.6472428", "0.6250559", "0.62304735", "0.6184321", "0.60586286", "0.60568684", "0.6007388", "0.6006287", "0.6000936", "0.5944206", "0.5922772", "0.58859265", "0.5834617", "0.5823592", "0.5787207", "0.57700557", "0.57238126", "0.5704046", "0.5689148", "0.5668062...
0.770152
0
add post topic_id id of a Topic entry post_id id of a Post entry to be quoted
def add_post(request, topic_id, post_id = False): topic = Topic.objects.values('is_locked').get(id=topic_id) if topic['is_locked']: return render_to_response('pages/bug.html', {'bug': _('Topic is closed')}, context_instance=RequestContext(request)) # check who made the last post. lastpost = Post.objects.order_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inputPostFormatter(post):\n\n post[\"ttl\"] = from_decimal(post[\"ttl\"])\n post[\"workToProve\"] = from_decimal(post.get(\"workToProve\", 0))\n post[\"priority\"] = from_decimal(post[\"priority\"])\n\n if not is_array(post.get(\"topics\")):\n post[\"topics\"] = [post[\"topics\"]] if post.ge...
[ "0.56744564", "0.558241", "0.5538942", "0.5525987", "0.55021226", "0.54626447", "0.5433334", "0.54127514", "0.5382309", "0.5327841", "0.5323823", "0.53021455", "0.528666", "0.5278014", "0.52204454", "0.51643574", "0.5163705", "0.5158911", "0.5143387", "0.51425105", "0.5131639...
0.61425745
0
edit post post_id id of a Post entry
def edit_post(request, post_id): post = Post.objects.get(id=post_id) topic = Topic.objects.values('is_locked').get(id=post.post_topic.id) if topic['is_locked']: return render_to_response('pages/bug.html', {'bug': _('Topic is closed')}, context_instance=RequestContext(request)) # locked topic! if str(request.u...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_edit_post(post_id):\n edited_post = Post.query.get_or_404(post_id)\n\n edited_post.title = request.form['post-title']\n edited_post.content = request.form['post-content']\n\n db.session.add(edited_post)\n db.session.commit()\n\n return redirect(f\"/users/{edited_post.user_id}\")", "d...
[ "0.76939523", "0.7685592", "0.76800567", "0.7660965", "0.7545497", "0.7489035", "0.741149", "0.7384065", "0.7377361", "0.73677427", "0.73311186", "0.72992307", "0.72097", "0.71882075", "0.7129946", "0.7089798", "0.7078886", "0.70416814", "0.7023432", "0.6977628", "0.6803881",...
0.6180274
45
delete a post post_id ID of a Post entry topic_id Topic entry ID that contain the Post entry
def delete_post(request, post_id, topic_id): if request.user.is_authenticated() and request.user.is_staff: Post.objects.get(id=post_id).delete() topic = Topic.objects.get(id=topic_id) topic.topic_posts = topic.topic_posts -1 topic.save() return HttpResponseRedirect("/forum/topic/1/" + topic_id +"/") else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_post(self, postid, publish=True):\n return self.execute('metaWeblog.deletePost', self.appkey, postid, self.username, self.password, publish)", "def deletePost(post_id):\n\n cur, con = initialise(1, True)\n cur.execute(\"DELETE FROM posts WHERE id = ?\", [post_id])\n finish(con)", "de...
[ "0.7290854", "0.71813744", "0.707189", "0.70144165", "0.6734157", "0.6705272", "0.66744095", "0.66170305", "0.65778816", "0.6540325", "0.6527792", "0.65232277", "0.6492486", "0.6463847", "0.6436576", "0.64360607", "0.6435728", "0.6426961", "0.64227504", "0.64221185", "0.63968...
0.7708023
0
delete a topic with all posts topic_id ID of a Topic entry forum_id ID of a Forum entry that contain the Topic entry
def delete_topic(request, topic_id, forum_id): if request.user.is_authenticated() and request.user.is_staff: posts = Post.objects.filter(post_topic=topic_id).count() Topic.objects.get(id=topic_id).delete() Post.objects.filter(post_topic=topic_id).delete() forum = Forum.objects.get(id=forum_id) forum.forum_to...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_forum_delete_with_user_and_topic(topic, user):\n assert user.post_count == 1\n\n topic.forum.delete([user])\n\n forum = Forum.query.filter_by(id=topic.forum_id).first()\n\n assert forum is None\n\n assert user.post_count == 0", "def test_topic_delete(topic):\n assert topic.user.post_co...
[ "0.73016423", "0.7203841", "0.6963431", "0.69614524", "0.67349267", "0.67126554", "0.64723164", "0.646823", "0.64286953", "0.63918406", "0.6367718", "0.61540616", "0.6082416", "0.59594494", "0.5956341", "0.5948439", "0.59352607", "0.5894316", "0.5869952", "0.58637923", "0.582...
0.7847929
0
move topic topic_id ID of a Topic entry forum_id ID of a Forum entry that contain the Topic entry
def move_topic(request, topic_id, forum_id): if request.user.is_authenticated() and request.user.is_staff: if request.POST and len(request.POST['forum']) > 0: topic = Topic.objects.get(id=topic_id) topic.topic_forum=Forum.objects.get(id=request.POST['forum']) topic.save() t = Topic( topic_forum=Forum...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_topic_move(topic):\n forum_other = Forum(title=\"Test Forum 2\", category_id=1)\n forum_other.save()\n\n forum_old = Forum.query.filter_by(id=topic.forum_id).first()\n\n assert topic.move(forum_other)\n\n assert forum_old.topics.all() == []\n assert forum_old.last_post_id is None\n\n ...
[ "0.7131075", "0.6714556", "0.6159936", "0.58648306", "0.560254", "0.54284686", "0.5379261", "0.53368664", "0.5330624", "0.52451175", "0.5174865", "0.5153713", "0.5137819", "0.5133269", "0.5069009", "0.49978033", "0.49439996", "0.49279928", "0.49038643", "0.4900711", "0.487935...
0.7425224
0
close topic topic_id ID of a Topic entry forum_id ID of a Forum entry that contain the Topic entry
def close_topic(request, topic_id, forum_id): if request.user.is_authenticated() and request.user.is_staff: topic = Topic.objects.get(id=topic_id) topic.is_locked=True topic.save() return HttpResponseRedirect("/forum/forum/" + forum_id +"/") else: return render_to_response('pages/bug.html', {'bug': _('You a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CloseForum(self, event):\n pass", "def delete_topic(request, topic_id, forum_id):\n\tif request.user.is_authenticated() and request.user.is_staff:\n\t\tposts = Post.objects.filter(post_topic=topic_id).count()\n\t\tTopic.objects.get(id=topic_id).delete()\n\t\tPost.objects.filter(post_topic=topic_id).dele...
[ "0.69265425", "0.62713945", "0.60562444", "0.5694666", "0.5645075", "0.5537677", "0.5536338", "0.5399221", "0.53810674", "0.53675985", "0.5337655", "0.5310567", "0.52487916", "0.51788086", "0.5140474", "0.5059159", "0.505236", "0.50319016", "0.5029529", "0.50178045", "0.49900...
0.7385165
0
open topic topic_id ID of a Topic entry forum_id ID of a Forum entry that contain the Topic entry
def open_topic(request, topic_id, forum_id): if request.user.is_authenticated() and request.user.is_staff: topic = Topic.objects.get(id=topic_id) topic.is_locked=False topic.save() return HttpResponseRedirect("/forum/forum/" + forum_id +"/") else: return render_to_response('pages/bug.html', {'bug': _('You a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close_topic(request, topic_id, forum_id):\n\tif request.user.is_authenticated() and request.user.is_staff:\n\t\ttopic = Topic.objects.get(id=topic_id)\n\t\ttopic.is_locked=True\n\t\ttopic.save()\n\t\treturn HttpResponseRedirect(\"/forum/forum/\" + forum_id +\"/\")\n\telse:\n\t\treturn render_to_response('pages...
[ "0.64089066", "0.61834556", "0.608341", "0.59609735", "0.592506", "0.5805181", "0.5580653", "0.555434", "0.5401649", "0.53877735", "0.5352653", "0.5329012", "0.5293954", "0.52889127", "0.52800125", "0.5265754", "0.5243257", "0.5208003", "0.5203939", "0.517839", "0.5164468", ...
0.73087126
0
Generate a request and store it for a given proxy Chain
def generateDelegationRequest( self, proxyChain, userDN ): retVal = self._getConnection() if not retVal[ 'OK' ]: return retVal connObj = retVal[ 'Value' ] retVal = proxyChain.generateProxyRequest() if not retVal[ 'OK' ]: return retVal request = retVal[ 'Value' ] retVal = request....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_request(self, key):\n params = {'requestedKey': key}\n res = requests.get(url=self.proxy_url, params=params)\n return res", "def CraftREQ(target, data=None, method=\"\", cookies=None, proxy=None):\n\n if method == \"POST\":\n\n req = requests.post\n \n else:\n\n ...
[ "0.5822375", "0.5781705", "0.5694862", "0.56335956", "0.56069195", "0.5526165", "0.55199844", "0.55183387", "0.5507352", "0.5470857", "0.54103893", "0.54103893", "0.53639096", "0.5351645", "0.53144705", "0.5304702", "0.5300411", "0.5286486", "0.52729994", "0.5258008", "0.5246...
0.7016759
0
Retrieve a request from the DB
def retrieveDelegationRequest( self, requestId, userDN ): cmd = "SELECT Pem FROM `ProxyDB_Requests` WHERE Id = %s AND UserDN = '%s'" % ( requestId, userDN ) retVal = self._query( cmd ) if not retVal[ 'OK' ]: return retV...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_request(req_id: int, db: Session = Depends(get_db)):\n db_req = crud.get_request(db, req_id=req_id)\n if db_req is None:\n raise HTTPException(status_code=404, detail=\"Request not found\")\n return db_req", "def get(self, request):\n return self.execute_query()", "def get_reque...
[ "0.76747227", "0.73057044", "0.70532966", "0.68029195", "0.66520727", "0.65405095", "0.653808", "0.64921767", "0.64763325", "0.6450212", "0.6447622", "0.6435447", "0.6435447", "0.64057696", "0.6342955", "0.63421524", "0.63219273", "0.6316459", "0.6292448", "0.6269452", "0.625...
0.5558788
89
Purge expired requests from the db
def purgeExpiredRequests( self ): cmd = "DELETE FROM `ProxyDB_Requests` WHERE ExpirationTime < UTC_TIMESTAMP()" return self._update( cmd )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _purge_expired_user_tokens():\n expired = models.Token.query.filter_by(\n _user_fk=current_user.id).filter(\n models.Token.expiration_date <= datetime.utcnow()\n ).all()\n if expired:\n for token in expired:\n db.session.delete(token)\n db.session.commit()", "d...
[ "0.72050285", "0.7127917", "0.71021295", "0.7098698", "0.6926186", "0.6905672", "0.6820967", "0.6804602", "0.67834455", "0.6764798", "0.67552555", "0.6708928", "0.67059666", "0.67030096", "0.6676758", "0.6637986", "0.6602445", "0.6478992", "0.64710385", "0.6464518", "0.639524...
0.84799945
0
Delete a request from the db
def deleteRequest( self, requestId ): cmd = "DELETE FROM `ProxyDB_Requests` WHERE Id=%s" % requestId return self._update( cmd )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self, request_id):\n request = RequestModel.select_by_id(request_id)\n if request:\n request.delete_from_db()\n return {'message': 'Request deleted'}, 200\n return {'message': 'Request not found'}, 404", "def delete(cls, request_id):\n try:\n ...
[ "0.8229804", "0.76968706", "0.76622194", "0.7454429", "0.72938126", "0.72398186", "0.7220319", "0.72123843", "0.7180326", "0.7139766", "0.7105021", "0.70788395", "0.69926", "0.692311", "0.6867637", "0.6867637", "0.6867637", "0.6867637", "0.6867637", "0.6867637", "0.6867637", ...
0.80820704
1
Complete a delegation and store it in the db
def completeDelegation( self, requestId, userDN, delegatedPem ): retVal = self.retrieveDelegationRequest( requestId, userDN ) if not retVal[ 'OK' ]: return retVal request = retVal[ 'Value' ] chain = X509Chain( keyObj = request.getPKey() ) retVal = chain.loadChainFromString( delegatedPem ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete(self):\n\t\tres = getattr(self._client, \"complete_\" + self.method)(self)\n\t\tself._create_fields(res)", "def done(self):\n self.status = 'completed'\n self.end = datetime.datetime.now()\n self.save()", "def complete(self):\n self.completed = peewee.datetime.date.toda...
[ "0.61047965", "0.5578747", "0.55091995", "0.55080706", "0.54306924", "0.5422218", "0.5386395", "0.53751755", "0.5360327", "0.5323545", "0.5306802", "0.5294053", "0.52203256", "0.5201263", "0.51974523", "0.51766515", "0.51766515", "0.5162817", "0.51593214", "0.51593214", "0.51...
0.5949987
1
Store user proxy into the Proxy repository for a user specified by his DN and group.
def storeProxy( self, userDN, userGroup, chain ): #Get remaining secs retVal = chain.getRemainingSecs() if not retVal[ 'OK' ]: return retVal remainingSecs = retVal[ 'Value' ] if remainingSecs < self._minSecsToAllowStore: return S_ERROR( "Cannot store proxy, remaining secs %s is less than...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proxy_user(self, proxy_user):\n\n self._proxy_user = proxy_user", "def set_proxy(self, proxy, user=None):\n proxy_handler = urllib2.ProxyHandler({'http':proxy})\n proxy_auth_handler = urllib2.ProxyBasicAuthHandler()\n if user:\n proxy_auth_handler.add_password('realm', ...
[ "0.59217805", "0.58081776", "0.55733275", "0.5563239", "0.5543035", "0.5453733", "0.53007734", "0.52942115", "0.5285648", "0.5189838", "0.5182187", "0.5122461", "0.5121389", "0.50961834", "0.5095189", "0.50855327", "0.5082368", "0.5074877", "0.5065176", "0.5018182", "0.500882...
0.7082033
0
Purge expired requests from the db
def purgeExpiredProxies( self ): cmd = "DELETE FROM `ProxyDB_Proxies` WHERE ExpirationTime < UTC_TIMESTAMP() and PersistentFlag = 'False'" return self._update( cmd )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def purgeExpiredRequests( self ):\n cmd = \"DELETE FROM `ProxyDB_Requests` WHERE ExpirationTime < UTC_TIMESTAMP()\"\n return self._update( cmd )", "def _purge_expired_user_tokens():\n expired = models.Token.query.filter_by(\n _user_fk=current_user.id).filter(\n models.Token.expiration_date...
[ "0.84799945", "0.72050285", "0.7127917", "0.71021295", "0.7098698", "0.6926186", "0.6905672", "0.6820967", "0.6804602", "0.6764798", "0.67552555", "0.6708928", "0.67059666", "0.67030096", "0.6676758", "0.6637986", "0.6602445", "0.6478992", "0.64710385", "0.6464518", "0.639524...
0.67834455
9