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
evolve the timedependent parameter of a lattice and generate effective Floquet Hamiltonian.
def evolve(self, k_vec, Nt,**kwargs): M_eff = np.eye((self.Nd), dtype=complex) # aux matrix T = 1. for it in range(Nt): # update the Hamiltonian for time-inteval self.updateH(k_vec, it) # return eigenenergies and vectors E_k, U...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fixed_time_trajectories(self, ll=1, distributions=None, discrete=False, noise=0):\n\n self.time_uniform = np.linspace(0, self.nsteps, self.nsteps * self.padding)\n\n for t in tqdm.tqdm(range(self.ntraj)):\n\n if distributions is not None:\n\n if self.dwell_distribution =...
[ "0.58629954", "0.5750387", "0.57404524", "0.5549065", "0.55443007", "0.5536246", "0.54893523", "0.54871595", "0.5463197", "0.54461116", "0.5366601", "0.5366318", "0.5358426", "0.53489166", "0.5338671", "0.5337355", "0.53291744", "0.52639544", "0.52473766", "0.5245468", "0.522...
0.0
-1
a Hamiltonian in (kx,ky) is given, evaluate the bandstructire of a static Hamiltonian E(kx,ky)
def band_structure_static(self, kx_range, ky_range, N_res): kxR = np.linspace(kx_range[0], kx_range[1], N_res) kyR = np.linspace(ky_range[0], ky_range[1], N_res) E_arr = np.zeros((2,N_res,N_res), float) # mesh over area in k-space # Kx, Ky = np.meshgrid(kx,ky) f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Ham_eigvals(self,kx,ky):\n tHam=self.Ham_gen(kx,ky)\n eigval=np.linalg.eigvals(tHam)\n sidc=eigval.argsort()\n eigval=eigval[sidc]\n return eigval.real", "def Hamiltonian(self):\n U = self.U.flatten()\n Vmat = sparse.spdiags([U], [0], len(U), len(U))\n ...
[ "0.6993806", "0.6351405", "0.631668", "0.6173396", "0.6048931", "0.5919147", "0.59026694", "0.5856373", "0.5856373", "0.5840797", "0.58045894", "0.5798676", "0.57981175", "0.57474506", "0.5734695", "0.57284135", "0.5721163", "0.5689188", "0.5662637", "0.56574494", "0.5643961"...
0.63015884
3
a Hamiltonian in (kx,ky,t) is given, evaluate the quasienergy bandstructire of a dynamic Hamiltonian E(kx,ky)
def band_structure_dynamic(self, kx_range, ky_range, N_res): kxR = np.linspace(kx_range[0], kx_range[1], N_res) kyR = np.linspace(ky_range[0], ky_range[1], N_res) Nt = 3 E_arr = np.zeros((2,N_res,N_res), float) # mesh over area in k-space # Kx, Ky = np.meshgrid(k...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def band_energy(k,t=1.0,e0=0.2,a=1.0):\n return e0-t*np.exp(1j*k*a)-t*np.exp(-1j*k*a)", "def eval_H_QQ(psi, times, args, options=0):\n n = args['n']\n ad = create(n)\n a = destroy(n)\n # the following string describes the time dependant frequency\n strWQQ = 'w0 + dw1*exp(-0.5*(t/dt1)**2) + dw2*...
[ "0.6612545", "0.65755147", "0.65446347", "0.6436535", "0.63812095", "0.6202196", "0.61459804", "0.61459804", "0.6124098", "0.6100168", "0.609041", "0.6084095", "0.6073878", "0.6059432", "0.59335494", "0.59044564", "0.5862369", "0.5858024", "0.5854256", "0.5809938", "0.579559"...
0.57978314
20
To calculate the Chern number of the Hamiltonian (or the Floquet Hamiltonian) over its Brillouin zone (BZ).
def chernNum(self, kx_Bz=np.array([0,4*np.pi/3]), ky_Bz=np.array([0,2*np.pi/np.sqrt(3)]), N_res=30): x_eps = 0.3 # shift from Dirac point x_res = 20 kx_int = 0 + x_eps # -np.pi kx_fin = 4*np.pi/3 + x_eps Dx = (kx_fin - kx_in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chibar(z):\n return chi(z)", "def king(r, n0, rc, b):\n return n0 * (1. + (r/rc)**2)**b", "def Z(n):\n count5 = 0\n i = 1\n while 1:\n a = pow(5, i)\n if a > n:\n return count5\n else:\n count5 += n/a\n i += 1", "def schmidt_number(self...
[ "0.6322738", "0.5849933", "0.58299345", "0.58136356", "0.5776217", "0.575044", "0.5717144", "0.5632605", "0.56096643", "0.5605452", "0.5583257", "0.5583257", "0.5566679", "0.5551885", "0.5551387", "0.5535313", "0.5525047", "0.551542", "0.55070794", "0.55008334", "0.5497203", ...
0.68269795
0
Runs the given command via subprocess.check_output. Exits with 1 if the command wasn't successfull.
def run(self, command): try: print(f"RUNNING: {command}") print("-" * 80) print(subprocess.check_output(command, shell=True).decode('utf-8')) except subprocess.CalledProcessError as e: print(f"ERROR calling '{command}'") print("-" * 20) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_output(command):\n process = Popen(command, shell=True, stdout=PIPE)\n output, err = process.communicate()\n if process.returncode == 0: # success\n return output\n else:\n raise RuntimeError(\"Command {0} running unsuccessfully\".format(command))", "def checked_subprocess_run...
[ "0.83655596", "0.80366087", "0.80346185", "0.780396", "0.76619476", "0.7643515", "0.762701", "0.755357", "0.7551432", "0.75476485", "0.7536367", "0.7521697", "0.75196725", "0.74670756", "0.7415259", "0.7365865", "0.7332744", "0.73258364", "0.7289348", "0.7279483", "0.72791225...
0.7235263
23
Runs Pyinstaller producing a binary for every platform arch.
def dist(self): for arch, python in self.python: # Build the binary build_path = os.path.join("dist", f"safety-{arch}") self.run(f"{python} -m PyInstaller safety.spec" f" --distpath {build_path}") # There seems to be no way to tell pyinstall...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n\n parser = argparse.ArgumentParser(prog='Build', description='Python script for building apps for Pyinstaller')\n # Flag arguments\n parser.add_argument('--version', action='version', version='%(prog)s 1.0.0')\n parser.add_argument('--clean', '-c', action='store_true', default=False, help...
[ "0.6310259", "0.5789505", "0.5693444", "0.5510755", "0.55103916", "0.5497933", "0.5497933", "0.54874897", "0.54428", "0.54246897", "0.5419463", "0.5417989", "0.5384044", "0.53545874", "0.5292452", "0.5261924", "0.52568054", "0.5245243", "0.52441704", "0.51907384", "0.517166",...
0.6888925
0
Runs tests for every available arch on the current platform.
def test(self): for arch, python in self.python: self.run(f"{python} -m pytest")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_platform():\n build()\n sh(\"%s psutil\\\\tests\\\\test_windows.py\" % PYTHON)", "def test_system_platform():\n accepted_values = ['windows', 'linux']\n output = sh.system_platform()\n assert output in accepted_values", "def test_all_envs(func):\n register_tests(func, [func.__name__ ...
[ "0.638114", "0.63241595", "0.62285227", "0.614223", "0.5939137", "0.585725", "0.5821105", "0.57821816", "0.5781692", "0.5748923", "0.56621426", "0.5645789", "0.56325114", "0.5582712", "0.55822486", "0.5556149", "0.554905", "0.5544548", "0.5525121", "0.5525121", "0.5525121", ...
0.7169691
0
Check if all elements present in the descending diagonal starting from position (i, j) in the matrix are all the same or not.
def checkDiag(mat, i, j): res = mat[i][j] i += 1 j += 1 while i < col and j < row: if mat[i][j] != res: return False i += 1 j += 1 return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkMatrix(i,j):\n # print(i,j)\n counter = Counter([grid[di][dj] for di in range(i,i+3) for dj in range(j,j+3)])\n for k in range(1,10):\n if counter[k] != 1:\n return False\n\n rows_sum = [sum(grid[k][j:j+3]) for k in range(i,i+3)...
[ "0.7221507", "0.72052103", "0.70935583", "0.7079611", "0.6919874", "0.6859481", "0.6859481", "0.6692153", "0.66862524", "0.6574057", "0.65542644", "0.6525075", "0.64994526", "0.64286137", "0.6414612", "0.6412978", "0.6392789", "0.63825876", "0.63576436", "0.6351419", "0.63253...
0.7580794
0
Check whether the matrix is Toeplitz using our routine.
def isToeplitz(mat): for j in range(row): if not checkDiag(mat, 0, j): return False for i in range(1, col): if not checkDiag(mat, i, 0): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_invertible(matrix: np.ndarray) -> bool:\n return matrix.shape[0] == matrix.shape[1] and np.linalg.det(matrix) != 0", "def check_matrix(self, matrix):\n for i in range(self.size):\n if (matrix[0][i] + matrix[-1][i] == i % 2 or matrix[0][i] + matrix[-1][i] == (i + 1) % 2) and (\n ...
[ "0.62021834", "0.6143656", "0.6061478", "0.58724177", "0.5847098", "0.5835416", "0.579894", "0.57757217", "0.5651579", "0.564704", "0.56339616", "0.5586131", "0.5580269", "0.55736345", "0.55596083", "0.5545253", "0.5520429", "0.5501175", "0.5497774", "0.5475992", "0.546678", ...
0.8034812
0
Try to locate the most frontfacing instance of the specified number in the given image.
def locate_number( pipeline: Pipeline, num: int, img: ImageBGR, ) -> Optional[Tuple[int, int]]: box = locate_front_facing_text(pipeline, str(num), img) if box is None: return None (cx, cy) = center_of_box(box) return (round(cx), round(cy))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_best_face(self, image):\n\t\ttry:\n\t\t\treturn max(self.get_faces(image),\n\t\t\t key = (lambda f: f[1]))\n\t\texcept ValueError:\n\t\t\treturn None", "def locate_face(image, minNeighbors=5, scaleFactor=1.05):\n rects = cc_face.detectMultiScale(image, scaleFactor=scaleFactor, minNeighbors=m...
[ "0.6109257", "0.5968454", "0.55990577", "0.5586432", "0.5545742", "0.5542052", "0.5507893", "0.54844373", "0.54029626", "0.53532827", "0.5300011", "0.52998513", "0.52698857", "0.52682185", "0.5256586", "0.5255363", "0.51983386", "0.5198194", "0.5178408", "0.51701695", "0.5156...
0.6024551
1
Try to locate the most frontfacing instance of the specified text in the given image.
def locate_front_facing_text( pipeline: Pipeline, text: str, img: ImageBGR, ) -> Optional[ndarray]: boxes = locate_all_text(pipeline, text, img) return None if not boxes else max(boxes, key=width_of_box)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(image):\n keypoint, description = describe(image)\n # load keypoints, descriptions from mongodb\n\n bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)\n\n best_match_size = float(\"inf\")\n best_match_index = -1\n match_index = 0\n best_matches = 0\n\n for desc in descriptions:\n matches = b...
[ "0.6584374", "0.5994109", "0.5930117", "0.5808667", "0.5791923", "0.5733024", "0.57220936", "0.56743777", "0.5612249", "0.559422", "0.5520388", "0.5518373", "0.55104786", "0.5501395", "0.5458008", "0.5457504", "0.5452925", "0.5452155", "0.54426736", "0.5430474", "0.5422574", ...
0.7968446
0
Locate all instances of the specified text in the given image.
def locate_all_text(pipeline: Pipeline, text: str, img: ImageBGR) -> List[ndarray]: predictions = recognize(pipeline, img) return [box for (txt, box) in predictions if txt == text]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_image_search(image_name, saved_image, text):\n with Image(filename=image_name) as img:\n with img.clone() as cloned:\n cloned.format = 'png'\n with Drawing() as draw:\n draw.font_family = 'Liberation Mono'\n draw.font_...
[ "0.7133031", "0.6248851", "0.62018156", "0.6122685", "0.5983066", "0.59805745", "0.5944735", "0.5919284", "0.5852322", "0.5812584", "0.5805259", "0.57655126", "0.57553184", "0.57473385", "0.5714805", "0.56760997", "0.566809", "0.5653277", "0.5649725", "0.5605669", "0.5579515"...
0.73533505
0
Recognize characters in the given image.
def recognize(pipeline: Pipeline, img: ImageBGR) -> List[Prediction]: groups: List[List[Prediction]] = pipeline.recognize([img.data]) return [] if not groups else groups[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_letters(line_image):\r\n\r\n\tif line_image.shape[0] < 40:\r\n\t\tline_image = cv2.resize(line_image, (line_image.shape[1] * 2, line_image.shape[0] * 2))\r\n\r\n\t#binary\r\n\tret,thresh = cv2.threshold(line_image, 109, 255, cv2.THRESH_BINARY_INV)\r\n\r\n\tif cv2.__version__.startswith('3.'):\r\n\t\tim2, ...
[ "0.69676256", "0.6598435", "0.6543282", "0.6519579", "0.6401202", "0.63549", "0.63313323", "0.6326261", "0.630656", "0.6189315", "0.6133044", "0.61307913", "0.61281866", "0.6122168", "0.61140376", "0.60912144", "0.6071114", "0.6069808", "0.6067123", "0.59948766", "0.59657794"...
0.0
-1
Compute the width of a bounding box.
def width_of_box(box: ndarray) -> float: (w, _) = dimensions_of_box(box) return w
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getWidth(self):\n return _libsbml.BoundingBox_getWidth(self)", "def width(self) -> int:\r\n return self.rect_uv.w", "def _get_pad_width(self, bbox):\r\n if isinstance(bbox, shapely.geometry.polygon.Polygon):\r\n bbox = bbox.bounds\r\n elif isinstance(bbox, tuple):\r\n...
[ "0.78384995", "0.7405333", "0.72103524", "0.71854645", "0.71309066", "0.698792", "0.69232786", "0.69125646", "0.68847704", "0.68847704", "0.681629", "0.6795641", "0.67908436", "0.67605865", "0.6724223", "0.67201644", "0.6717353", "0.66922086", "0.6662561", "0.6651283", "0.663...
0.7852812
0
Compute the dimensions of a bounding box.
def dimensions_of_box(box: ndarray) -> Tuple[float, float]: (top_left, _, bottom_right, _) = box (x1, y1) = top_left (x2, y2) = bottom_right return (x2 - x1, y2 - y1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getDimensions(self):\n return _libsbml.BoundingBox_getDimensions(self)", "def bounding_box_size(self):\n return self.subset.bounding_box_size()", "def box_size(self) -> np.ndarray:\n return self.upper - self.lower + 1", "def box_size(self) -> np.ndarray:\n return self.upper - ...
[ "0.7809096", "0.74935055", "0.71321684", "0.71321684", "0.7028061", "0.7028061", "0.7006185", "0.69137424", "0.6838827", "0.67754894", "0.67039317", "0.66390294", "0.6636376", "0.66180444", "0.6617061", "0.66104996", "0.65931004", "0.65841496", "0.6548105", "0.653331", "0.652...
0.7216003
2
Compute the center coordinates of a bounding box.
def center_of_box(box: ndarray) -> Tuple[float, float]: return np.average(box, axis=0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def center(self):\n return np.sum(self.bbox, 0) / 2", "def getBoundingBoxCenter(self, shell=False, *args, **kwargs):\n if shell:\n self.grabShell()\n uvBB = pm.polyEvaluate(boundingBoxComponent2d=True)\n uvCenter = [((uvBB[0][1] + uvBB[0][0]) / 2), ((uvBB[1][1] + uvBB[1][0]...
[ "0.83376604", "0.79774463", "0.7929507", "0.78889424", "0.7875013", "0.77640754", "0.7762866", "0.7758551", "0.76668495", "0.75822484", "0.7577398", "0.7468743", "0.74314386", "0.73990625", "0.73919564", "0.7388721", "0.7360475", "0.73129874", "0.731186", "0.728058", "0.71837...
0.7129428
28
Return the last commit hash that appears to have been committed by gerrit.
def get_upstream_commit(): return check_output(_GET_UPSTREAM_COMMIT_SCRIPT).strip().decode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_commit_hash():\n git_dir = get_git_root()\n args = [\"git\", \"-C\", git_dir, \"rev-parse\", \"--short\", \"--verify\", \"HEAD\"]\n return subprocess.check_output(args).strip().decode()", "def commit_hash(self):\n return self._commit_hash", "def _get_git_hash(self):\n try:\n ...
[ "0.7975856", "0.78311783", "0.77943695", "0.76531535", "0.7602308", "0.75942075", "0.75930107", "0.75697476", "0.755672", "0.7517278", "0.7516449", "0.75058067", "0.75035375", "0.74300647", "0.7416891", "0.7393128", "0.7353526", "0.73011035", "0.7250581", "0.7235257", "0.7216...
0.603179
74
r"""Run command with arguments and return its output as a byte string. Backported from Python 2.7 as it's implemented as pure python on stdlib. >>> check_output(['/usr/bin/python', 'version']) Python 2.6.2
def check_output(*popenargs, **kwargs): process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) output, unused_err = process.communicate() retcode = process.poll() if retcode: cmd = kwargs.get("args") if cmd is None: cmd = popenargs[0] error = subprocess.CalledProcessError(ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_output(*args):\n cmd_output = subprocess.check_output(args)\n # On Python 3, this returns bytes (from STDOUT), so we\n # convert to a string.\n cmd_output = cmd_output.decode('utf-8')\n # Also strip the output since it usually has a trailing newline.\n return cmd_output.strip()", "def...
[ "0.8171935", "0.74754685", "0.74212164", "0.73357135", "0.7299671", "0.72751886", "0.72603405", "0.72177374", "0.7188931", "0.7186452", "0.71609044", "0.7144167", "0.7137204", "0.7025727", "0.7009536", "0.6982228", "0.69801265", "0.6913437", "0.69010824", "0.6882899", "0.6862...
0.6900501
20
Issue the given prompt, and ask the user to confirm yes/no. Returns true if the user confirms.
def confirm_prompt(prompt): while True: print(prompt, end=' [Y/n]: ') if not os.isatty(sys.stdout.fileno()): print("Not running interactively. Assuming 'N'.") return False pass r = input().strip().lower() if r in ['y', 'yes', '']: return True elif r in ['n', 'no']: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirm(self, prompt=None, resp=False):\n\n if prompt is None:\n prompt = 'Confirm'\n\n if resp:\n prompt = '%s [%s]|%s: ' % (prompt, 'y', 'n')\n else:\n prompt = '%s [%s]|%s: ' % (prompt, 'n', 'y')\n\n while True:\n ans = raw_input(prompt...
[ "0.83006346", "0.8259412", "0.8020167", "0.80170214", "0.80104864", "0.8008348", "0.7993725", "0.7975639", "0.7779552", "0.7631397", "0.76128113", "0.76106507", "0.7544541", "0.7469662", "0.7433531", "0.74094915", "0.73615307", "0.7337983", "0.7299126", "0.72749245", "0.72716...
0.7963644
8
Return the email address in the user's git config.
def get_my_email(): return check_output(['git', 'config', '--get', 'user.email']).strip().decode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_email(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"user_email\")", "def account_email(self) -> str:\n return pulumi.get(self, \"account_email\")", "def email(self) -> str:\n return pulumi.get(self, \"email\")", "def email(self) -> str:\n return pulumi.get(self...
[ "0.7280318", "0.7232141", "0.7188435", "0.7188435", "0.7188435", "0.71637696", "0.71572125", "0.7076948", "0.7076948", "0.7076948", "0.7076948", "0.7075867", "0.7023382", "0.70050824", "0.6937374", "0.68804014", "0.6870833", "0.68378097", "0.68269426", "0.6818887", "0.6805280...
0.86037236
0
F1 (a.k.a. DICE) operating on two lists of offsets (e.g., character). >>> assert f1([0, 1, 4, 5], [0, 1, 6]) == 0.5714285714285714
def f1(predictions, gold): if len(gold) == 0: return 1. if len(predictions) == 0 else 0. if len(predictions) == 0: return 0. predictions_set = set(predictions) gold_set = set(gold) nom = 2 * len(predictions_set.intersection(gold_set)) denom = len(predictions_set) + len(gold_set) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def f(x0: float, x1: float) -> float:\n return 8 - (x0 - 2) ** 2 - (x1 - 2) ** 2", "def __call__(self, f1, f2):\n\n r = 0.0\n for f in f1:\n if f in f2:\n r += f1[f] * f2[f]\n\n return r", "def calculate_f1(fx, y):\n pred_idxs = fx.max(1, keepdim=True)[1]\n ...
[ "0.5610688", "0.55093515", "0.5410377", "0.52887857", "0.52255523", "0.520882", "0.5139808", "0.50946337", "0.50892437", "0.50515544", "0.50473595", "0.5026382", "0.50248957", "0.49842107", "0.49398017", "0.4938526", "0.49344835", "0.49316767", "0.4920797", "0.4916687", "0.49...
0.51370984
7
w = (xTx) 1 xTy
def standRegres(xArr, yArr): xMat = np.mat(xArr) yMat = np.mat(yArr).T xTx = xMat.T * xMat if np.linalg.det(xTx) == 0.0: print 'This matrix is singular, cannot do inverse.' return ws = xTx.I * (xMat.T * yMat) return ws
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eq(w, x):\n return (-w[1]*x - w[0]) / w[2]", "def nn(x, w):\n return np.dot(x, w)", "def applyTw(T, Wxyz=[0, 0, 0]):\n return (T * sp.Matrix([Wxyz[0], Wxyz[1], Wxyz[2], 0]))[:3, 0]", "def applyTx(T, xyz=[0, 0, 0]):\n return (T * sp.Matrix([xyz[0], xyz[1], xyz[2], 1]))[:3, 0]", "...
[ "0.67788756", "0.6498502", "0.6414204", "0.6276771", "0.6237516", "0.62109613", "0.6204428", "0.6185558", "0.6117792", "0.61113244", "0.60975444", "0.6091444", "0.6052467", "0.6026854", "0.6024035", "0.6018883", "0.59976965", "0.59845245", "0.59813404", "0.5974722", "0.596788...
0.0
-1
Runs the unit tests without test coverage.
def test(): tests = unittest.TestLoader().discover('auth/tests', pattern='test*.py') result = unittest.TextTestRunner(verbosity=2).run(tests) if result.wasSuccessful(): return 0 return 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _run_ci_test():\n _run_install(False)\n _run_coverage_html(False)\n _run_typecheck_xml(False)\n _run_lint(True)", "def main():\n import coverage\n import nose\n import os\n from shutil import rmtree\n rmtree('./covhtml', ignore_errors=True)\n try:\n os.remove('./.coverage...
[ "0.7740198", "0.7395665", "0.73899317", "0.73077023", "0.7184236", "0.71184987", "0.7116021", "0.7049126", "0.695683", "0.6951264", "0.6858743", "0.682145", "0.6820713", "0.6819008", "0.6809791", "0.67945355", "0.6780462", "0.6756857", "0.6749489", "0.671787", "0.6669164", ...
0.0
-1
Creates the db tables.
def create_db(): db.create_all()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_tables():\n db.create_all()", "def create_tables():\n db.create_all()", "def create_tables():\n db.create_all()", "def create_db_tables():\n\n try:\n webapp.dbsql.create_all()\n webapp.dbsql.session.commit()\n except Exception as e:\n # TODO: melhorar o ...
[ "0.90999454", "0.90999454", "0.8910174", "0.86784077", "0.8614145", "0.8553592", "0.8508828", "0.845593", "0.8445083", "0.8376737", "0.83389515", "0.82984424", "0.8226738", "0.8191471", "0.81631696", "0.8158732", "0.81120193", "0.80407983", "0.7961357", "0.7934169", "0.793311...
0.7608928
63
Drops the db tables.
def drop_db(): db.drop_all()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drop_database_tables(cls):\n cursor = Database.connect_to_db()\n # drop users table\n sql_command = \"\"\" DROP TABLE IF EXISTS users CASCADE;\n \"\"\"\n cursor.execute(sql_command)\n # drop parties table\n sql_command = \"\"\" DROP TABLE IF EXISTS parties C...
[ "0.8613892", "0.85542655", "0.8401308", "0.8334024", "0.829665", "0.82727927", "0.8257214", "0.8239192", "0.8230405", "0.8215113", "0.8172018", "0.8147676", "0.8134603", "0.8033471", "0.80164933", "0.7894234", "0.7875027", "0.7873612", "0.78511506", "0.7773903", "0.7724372", ...
0.7996094
22
Germline TSV sheet without header
def tsv_sheet_germline_no_header(): f = io.StringIO( textwrap.dedent( """ patientName\tfatherName\tmotherName\tsex\tisAffected\tlibraryType\tfolderName\thpoTerms 12_345\t12_346\t12_347\tM\tY\tWGS\t12_345\tHP:0009946,HP:0009899 12_348\t12_346\t12_347\tM\tN\tWGS\t12_348\t. 12_346\t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tsv_sheet_cancer_no_header():\n f = io.StringIO(\n textwrap.dedent(\n \"\"\"\n patientName\\tsampleName\\tisTumor\\tlibraryType\\tfolderName\\tncbiTaxon\\tmycnCn\\tinssStage\\tshimada4Class\\tlohChr1p\\tpatientStatus\\ttimeToEventDays\\ttimeToDeathDays\\ttestSampleNice\\tngsLibraryNice\...
[ "0.6542757", "0.5973285", "0.58995175", "0.586946", "0.56117624", "0.5556044", "0.5453089", "0.54130244", "0.5376477", "0.53673553", "0.53632265", "0.52624077", "0.52572477", "0.52544403", "0.52472043", "0.52365565", "0.5235203", "0.5222204", "0.52163196", "0.51827556", "0.51...
0.6975893
0
Germline TSV sheet without header
def tsv_sheet_germline_no_header_hyphened_identifier(): return io.StringIO( textwrap.dedent( """ patientName\tfatherName\tmotherName\tsex\tisAffected\tlibraryType\tfolderName\thpoTerms 12-345\t12-346\t12-347\tM\tY\tWGS\t12-345\tHP:0009946,HP:0009899 12-348\t12-346\t12-347\tM\tN\tWGS\...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tsv_sheet_germline_no_header():\n f = io.StringIO(\n textwrap.dedent(\n \"\"\"\n patientName\\tfatherName\\tmotherName\\tsex\\tisAffected\\tlibraryType\\tfolderName\\thpoTerms\n 12_345\\t12_346\\t12_347\\tM\\tY\\tWGS\\t12_345\\tHP:0009946,HP:0009899\n 12_348\\t12_346\\t12_347\\tM\...
[ "0.6975893", "0.6542757", "0.58995175", "0.586946", "0.56117624", "0.5556044", "0.5453089", "0.54130244", "0.5376477", "0.53673553", "0.53632265", "0.52624077", "0.52572477", "0.52544403", "0.52472043", "0.52365565", "0.5235203", "0.5222204", "0.52163196", "0.51827556", "0.51...
0.5973285
2
Germline TSV sheet with seqPlatform name
def tsv_sheet_germline_platform_name(): f = io.StringIO( textwrap.dedent( """ patientName\tfatherName\tmotherName\tsex\tisAffected\tlibraryType\tfolderName\thpoTerms\tseqPlatform 12_347\t.\t.\tF\tN\tWGS\t12_347\t.\tIllumina 12_347\t.\t.\tF\tN\tWGS\t12_347\t.\tPacBio """.lstrip() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tsv_sheet_germline_no_header():\n f = io.StringIO(\n textwrap.dedent(\n \"\"\"\n patientName\\tfatherName\\tmotherName\\tsex\\tisAffected\\tlibraryType\\tfolderName\\thpoTerms\n 12_345\\t12_346\\t12_347\\tM\\tY\\tWGS\\t12_345\\tHP:0009946,HP:0009899\n 12_348\\t12_346\\t12_347\\tM\...
[ "0.5723765", "0.54112744", "0.5368876", "0.5364168", "0.5343656", "0.5305883", "0.52360225", "0.5199959", "0.51087195", "0.50739825", "0.4979598", "0.49793586", "0.49732012", "0.49713272", "0.49574873", "0.49445036", "0.49361375", "0.49321032", "0.49083406", "0.4893043", "0.4...
0.71251005
0
If a defined term is part of another word, don't include it
def test_calculate_offsets_word_part(self): applicable_terms = [('act', 'a')] text = "I am about to act on this transaction." t = Terms(None) matches = t.calculate_offsets(text, applicable_terms) self.assertEqual(1, len(matches)) self.assertEqual(1, len(matches[0][2]))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_unimportant(word):\n return word in ['.', '!', ',', ] or '\\'' in word or word in stop_words", "def isExcludedFromMerge(self, word):\n #print word\n return ((self.isExcludedWord(word) != False) \n or (self.isMeasure(word) != False) \n or (self.isShortWord(word) != False))", "def f...
[ "0.7129404", "0.6740497", "0.64401877", "0.64198786", "0.63028586", "0.624135", "0.6205922", "0.61960745", "0.61723465", "0.6158137", "0.6138724", "0.61333543", "0.60994077", "0.609723", "0.6095544", "0.6045487", "0.60338706", "0.6000759", "0.5976662", "0.59725183", "0.597233...
0.0
-1
Make sure we don't highlight definitions that are being defined in this paragraph.
def test_process_label_in_node(self): tree = Node(children=[ Node("Defining secret phrase.", label=['AB', 'a']), Node("Has secret phrase. Then some other content", label=['AB', 'b']) ], label=['AB']) t = Terms(tree) t.scoped_terms = { ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def no_highlight(): #py:no_highlight\n RUR._no_highlight_()", "def no_underline(): # noqa: D416", "def no_underline_and_no_description(): # noqa: D416", "def test_no_spelling_mistakes_after_docstring(self, style):\n content = \"{s}{e}\\n\\\"\\\"\\\"spelling mistake\\\"\\\"\\\")\\n\\n msspltword\...
[ "0.6509171", "0.6025568", "0.5981216", "0.57642", "0.5721412", "0.5600723", "0.5538997", "0.5533187", "0.5475859", "0.5460249", "0.5446885", "0.54421276", "0.54057634", "0.53963256", "0.53608805", "0.5352777", "0.5348464", "0.5310494", "0.53071415", "0.5304848", "0.5278344", ...
0.0
-1
if your don't wanna to destory , please return True
def judge_destroy(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_destroy(self) -> bool:\r\n raise NotImplementedError", "def destroy(self):\n return True", "def __exit__(self, exc_type, exc_val, exc_tb):\n self.delete()\n if exc_type:\n return False\n return True", "def __del__(self):\n return ...
[ "0.7112134", "0.7022832", "0.6998356", "0.68127376", "0.67740875", "0.6674167", "0.6626179", "0.6502983", "0.638146", "0.62835974", "0.6254132", "0.624675", "0.61887157", "0.61887157", "0.61887157", "0.6172241", "0.6164332", "0.61453766", "0.61254376", "0.6093295", "0.6092467...
0.56394315
79
`comment_list` must be an iterable containing Comment instances.
def wrap_comments(comment_list, cls=None): if not cls: cls = CommentDetails return [cls(d) for d in CachedCall.multicall([cmt.details for cmt in comment_list])]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_comment_list(parser, token):\n return CommentListNode.handle_token(parser, token)", "def get_all_comments(self, idList: Union[List, str]) -> None:\n\n #loads pickle list if it is one\n if type(idList) == str and \".pickle\" in idList:\n print(\"pickle load\")\n with...
[ "0.6494126", "0.6294482", "0.60200804", "0.59759414", "0.5885373", "0.58529603", "0.5835406", "0.581138", "0.5802858", "0.5801029", "0.5784154", "0.5736132", "0.57356554", "0.5729952", "0.5724823", "0.57243335", "0.5698182", "0.56944305", "0.56499034", "0.56499034", "0.564990...
0.73803866
0
Strip and redirect requests with certain trailing characters left by bad URL parsers.
def redirect_trailing(view): IGNORE_CHARS = ",./" def wrapped(request, *args, **kwargs): if request.META['PATH_INFO'][-1] in IGNORE_CHARS: return HttpResponseRedirect(request.META['PATH_INFO'].rstrip(IGNORE_CHARS)) return view(request, *args, **kwargs) return wrapped
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_drop_trailing_questionmark():\n assert normalize_url(\"http://example.com/?\") == \"http://example.com/\"\n assert normalize_url(\"http://example.com?\") == \"http://example.com/\"\n assert normalize_url(\"http://example.com/a?\") == \"http://example.com/a\"\n assert normalize_url(\"http://exa...
[ "0.6716417", "0.65329564", "0.6438808", "0.6175929", "0.6159155", "0.61399084", "0.60827553", "0.6058008", "0.60463554", "0.6016129", "0.6008326", "0.59506243", "0.59365505", "0.59365505", "0.59365505", "0.59365505", "0.59365505", "0.59365505", "0.59365505", "0.58958346", "0....
0.6691305
1
`force_show` if True will return as many top reply IDs as we have.
def top_reply_ids(self, force_show=False): num_top = min(self.num_replies / Config['posts_per_top_reply'], Config['maximum_top_replies']) min_top_replies = Config['minimum_top_replies'] top_reply_ids = [] # Avoid even hitting redis if we know we aren't going to use the data. if f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_from_top_ten(title,users,max = 3):\n \"\"\" ten prolific users \"\"\"\n \"\"\" max : number of user with related followers \"\"\"\n getAllUsers(users,all_users,users_set,proceeded_users,max,user_cpt,title)\n for data in users_set:\n print(data.id)", "def show_recommendation_pool(s...
[ "0.5378942", "0.532292", "0.52742416", "0.5210229", "0.514267", "0.5120347", "0.51002747", "0.5028869", "0.50170374", "0.49864686", "0.49803752", "0.49629715", "0.49612206", "0.49332845", "0.4932724", "0.4930099", "0.49299458", "0.49253184", "0.49134997", "0.48672706", "0.485...
0.77080315
0
Returns replies with text, sorted by id
def get_text_reply_ids(self): if not self._linked_comment: return [] replies = Comment.objects.filter(replied_comment=self._linked_comment) return [ids[0] for ids in replies.exclude(reply_text='').order_by('id').values_list('id')]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_message_replies(self, mid):\n pass", "def cmd_comment_replies(client, args):\n comment_replies = client.get_comment_replies(args.comment_id)\n data = format_comment_tree(comment_replies)\n generate_output({'comment_replies': data}, args.output_file)", "def replies(self):\n keys =...
[ "0.61649644", "0.6155298", "0.597946", "0.58901846", "0.5586778", "0.55457026", "0.55379367", "0.5525999", "0.5513527", "0.55060965", "0.5498998", "0.54371476", "0.5423341", "0.53732705", "0.53540397", "0.53385663", "0.53333944", "0.5317818", "0.53098434", "0.52878696", "0.52...
0.6619243
0
The log function with aggregation name, process id and tag integrated.
def log (self, msg, level="info", flag=None, key = ''): if flag is None: flag = level flag = flag.upper().rjust(7) flag = "[%s]" % flag title = self._name() func = getattr(self.logger, level) maxline = proc.LOG_NLINE[key] prevlog = self.lognline['prevlog'] if key == prevlog: if self.lognli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _log(log_fn, task_request, message):\n log_fn(\"{}: {}\".format(task_request.id, message))", "def log_nest(module, function, tag, subtag, info):\n global nodehost, nodeuser\n \n # determine current time. ***DO THIS FIRST***\n time1 = time.time()\n time2 = time.gmtime()\n\n # see if logging is...
[ "0.6297053", "0.62474245", "0.6157983", "0.61170477", "0.61158425", "0.60073596", "0.5902459", "0.58434343", "0.57823247", "0.57499766", "0.571752", "0.5716251", "0.5713921", "0.57046956", "0.5695376", "0.5694506", "0.5606004", "0.55924064", "0.55867314", "0.5582783", "0.5529...
0.49975112
86
Calcuate a uid for the process according to the configuration
def _suffix (self): if self.suffix: return self.suffix config = { key:val for key, val in self.config.iteritems() if key not in ['workdir', 'forks', 'cache', 'retcodes', 'echo', 'runner', 'exportdir', 'exporthow', 'exportow', 'errorhow', 'errorntry'] or key.endswith ('Runner') } config['id'] = self.id...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getuid(): # type: ignore\n return 0", "def known_uid():\n return '48ee71d9-20f0-41fc-a99f-c518121a880e'", "def getmyuid():\n raise NotImplementedError()", "def get_user_id():\n return os.getuid()", "def uid(self) -> str:\n return pulumi.get(self, \"uid\")", "def uid():\n\n ...
[ "0.73529434", "0.6904269", "0.6874896", "0.68143004", "0.6640332", "0.66186196", "0.6611936", "0.65890056", "0.6499807", "0.64870447", "0.646705", "0.646705", "0.646705", "0.6399656", "0.63789135", "0.63695127", "0.6366331", "0.63619816", "0.635309", "0.63286996", "0.63102037...
0.0
-1
Do some preparation before running jobs
def _tidyBeforeRun (self): self._buildProps () self._buildInput () self._buildProcVars () self._buildJobs ()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare(self):", "def prepare(self):\n if self.opts['verbose']:\n print(\"Preparing dataset (one-time operation)...\")\n # Create paths files and load them back in\n self._build_ID_sets()\n self._create_ID_files()\n self._load_ID_files()\n if self.opts['ve...
[ "0.7044057", "0.68709004", "0.68693995", "0.68585104", "0.68585104", "0.68585104", "0.6740922", "0.6718343", "0.6686946", "0.666077", "0.666077", "0.666077", "0.666077", "0.666077", "0.6644439", "0.6626265", "0.6626265", "0.65906596", "0.65197337", "0.6379625", "0.6327932", ...
0.71023333
0
Do some cleaning after running jobs
def _tidyAfterRun (self): failedjobs = [] for i in self.ncjobids: job = self.jobs[i] if not job.succeed(): failedjobs.append (job) if not failedjobs: self.log ('Successful jobs: ALL', 'debug') if callable (self.callback): self.log('Calling callback ...', 'debug') self.callback (self)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean(self, args):\n for j in self.jobs:\n j.clean(args)", "def cleanup():", "def clean_up(self) -> None:\n print('Doing some clean-up work...')", "def clean(self):\n self._raw_execute(\"clean\", {\"job_id\": self.job_id})", "def cleanup(self):", "def cleanup(self):", ...
[ "0.78071237", "0.77039135", "0.7624755", "0.74840623", "0.74488914", "0.74488914", "0.74488914", "0.7341595", "0.7322051", "0.7322051", "0.7322051", "0.7322051", "0.7322051", "0.7322051", "0.7322051", "0.7322051", "0.7322051", "0.7322051", "0.7322051", "0.7302214", "0.7296591...
0.65145636
92
Get my name include `aggr`, `id`, `tag`
def _name (self, incAggr = True): aggrName = "@%s" % self.aggr if self.aggr and incAggr else "" tag = ".%s" % self.tag if self.tag != "notag" else "" return "%s%s%s" % (self.id, tag, aggrName)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_name():", "def get_name() -> str:", "def get_name(self):", "def get_name(self):", "def get_name_tag(obj):\n if 'Name' in obj.tags:\n return obj.tags['Name']\n else:\n return \"\"", "def get_name_tag(obj):\n if 'Name' in obj.tags:\n return obj.tags['Na...
[ "0.6776478", "0.6571145", "0.64042926", "0.64042926", "0.6375301", "0.6357653", "0.63202906", "0.6207927", "0.6207927", "0.6207927", "0.6207927", "0.6207927", "0.6207927", "0.62068367", "0.61977625", "0.61679345", "0.6132641", "0.6104459", "0.60582983", "0.6038414", "0.603841...
0.73647666
0
Run the jobs with a configuration
def run (self, config = None): timer = time() if config is None: config = {} self.logger.info ('[ START] ' + utils.padBoth(' ' + self._name() + ' ', 80, '-')) # log the dependencies self.log ("%s => %s => %s" % ([p._name() for p in self.depends] if self.depends else "START", self._name(), [p._name() for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(config):\n for section in config.sections():\n if 'module' in [tuple[0] for tuple in config.items(section)]:\n read_metric = Process(target=worker.start_worker,\n args=(config[section]['module'], config[section]['worker'],\n ...
[ "0.6929816", "0.69011277", "0.66671133", "0.6641401", "0.6581517", "0.64800954", "0.6476801", "0.64720464", "0.64445555", "0.64079905", "0.6249662", "0.6244178", "0.62345445", "0.6228042", "0.62246597", "0.6196507", "0.6164982", "0.6157132", "0.61275566", "0.60870254", "0.607...
0.5928229
26
Build the input data
def _buildInput (self): indata = self.config['input'] if not isinstance (indata, dict): indata = ','.join(utils.alwaysList (indata)) depdchan = channel.fromChannels (*[d.channel for d in self.depends]) indata = {indata: depdchan if self.depends else channel.fromArgv()} # expand to one key-chan...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(self, data: dict):", "def build_data(self):\n\n _header_ = self._header_ + 'build_data(): '\n\n if self.verbose:\n print(_header_ + 'Building data for %s ...' % self.p_data)\n\n self.read_data()\n self.map_data()\n self.partition_data()\n self.compos...
[ "0.7103907", "0.7050694", "0.66928786", "0.66268075", "0.6621313", "0.65265703", "0.65073645", "0.64411193", "0.64387316", "0.6423669", "0.6376527", "0.63698995", "0.63683873", "0.63594806", "0.6341443", "0.6325721", "0.6296348", "0.62902075", "0.6282229", "0.62391293", "0.62...
0.6791348
2
also add proc.props, mostly scalar values
def _buildProcVars (self): alias = {val:key for key, val in proc.ALIAS.iteritems()} for prop in sorted(self.props.keys()): val = self.props[prop] if not prop in ['id', 'tag', 'tmpdir', 'forks', 'cache', 'workdir', 'echo', 'runner', 'errorhow', 'errorntry', 'defaultSh', 'exportdir', 'exporthow', 'export...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_proc_attr_order(self):\n jobad = classad.ClassAd()\n for attr, val in [(x, condor_meter.PROC_ATTRS.index(x)) for x in reversed(condor_meter.PROC_ATTRS)]:\n jobad[attr] = val\n self.assertEqual(condor_meter.get_num_procs(jobad), val)", "def props(self):\r\n retu...
[ "0.5752733", "0.56328917", "0.56328917", "0.56328917", "0.5615482", "0.5577076", "0.5544038", "0.54323864", "0.5425881", "0.54114395", "0.53192484", "0.52942336", "0.52895135", "0.5284507", "0.52701503", "0.52666897", "0.5265208", "0.52173996", "0.52003396", "0.5196597", "0.5...
0.63126945
0
Tell whether the jobs are cached
def _isCached (self): self.props['ncjobids'] = range(self.length) if self.cache == False: self.log ('Not cached, because proc.cache is False', 'debug') return False if self.cache == True: for depend in self.depends: if depend.cached: continue self.log ('Not cached, my dependent "%s" is not cac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_cached(self):\n return False", "def getCacheable(self):\n return False", "def mark_if_cached(self, args):\n pass", "def is_cached(name, typ=\"pkl\"):\n return os.path.exists(cache_name(name, typ))", "def enable_caching_acts_data() -> bool:\n return True", "def cached(s...
[ "0.760183", "0.7193296", "0.7158146", "0.7049321", "0.6945171", "0.69392574", "0.67610794", "0.67602086", "0.6705713", "0.66986024", "0.66811", "0.6526449", "0.6522423", "0.6519703", "0.65172327", "0.65119636", "0.64544183", "0.6348132", "0.633575", "0.6330356", "0.6327569", ...
0.7973835
0
Run the `beforeCmd` or `afterCmd`
def _runCmd (self, key): if not self.props[key]: return 0 cmd = utils.format(self.props[key], self.procvars) self.log ('Running <%s>: %s' % (key, cmd), 'info') p = Popen (cmd, shell=True, stdin=PIPE, stderr=PIPE, stdout=PIPE) if self.echo: for line in iter(p.stdout.readline, ''): self.logger.inf...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_cmd(self):\r\n self.run = True", "def at_pre_cmd(self):\n pass", "def normal(self):\n self.run_command('normal')", "def run_command_check(self):\n pass", "def test_run_command(self):\n self.build()\n self.data_formatter_commands()", "def do_before(self):\r\n ...
[ "0.6794517", "0.65953815", "0.641636", "0.6380787", "0.62030005", "0.61738706", "0.6168429", "0.61490905", "0.6098857", "0.6054008", "0.6047767", "0.60379046", "0.6029685", "0.6021883", "0.6005523", "0.59682816", "0.5947254", "0.59307516", "0.59238434", "0.591363", "0.5903428...
0.0
-1
Submit and run the jobs
def _runJobs (self): # submit jobs def sworker (q): """ The worker to run jobs """ while True: (run, i) = q.get() sleep (i) if run.isRunning(): self.log ("Job #%s is already running, skip submitting." % run.job.index, 'info') else: run.submit() run.wait() run.finish() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n self.submit()\n self.start()", "def submit(self):\n self.keep_data = False\n ManagedJob.submit(self)", "def submit(self, **kwargs):\n pwd = curdir\n wd = dirname(self.logFile)\n chdir(wd)\n d = OrderedDict()\n #d['universe'] = 'van...
[ "0.7423292", "0.7267833", "0.71237546", "0.69903475", "0.6716146", "0.67021185", "0.6673676", "0.6648856", "0.66117823", "0.6582873", "0.6563722", "0.65595084", "0.6535261", "0.65330726", "0.6530133", "0.6523355", "0.6512174", "0.65109503", "0.65062904", "0.6478821", "0.64662...
0.74873537
0
The worker to run jobs
def sworker (q): while True: (run, i) = q.get() sleep (i) if run.isRunning(): self.log ("Job #%s is already running, skip submitting." % run.job.index, 'info') else: run.submit() run.wait() run.finish() q.task_done()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getWorker(self):\n pass", "def work(self, job):\n pass", "def _worker(self, args):\n pass", "def worker(self, **options):\n pass", "def worker(self):\n return self._worker", "def run_worker(self):\n # TODO(xiejw): To allow execution framework to add train hooks.\...
[ "0.80843735", "0.78820264", "0.7827158", "0.782191", "0.767357", "0.7649135", "0.74996334", "0.7405024", "0.7321206", "0.72851163", "0.7198679", "0.7160309", "0.7145514", "0.7112629", "0.70511824", "0.70066136", "0.69530994", "0.69140154", "0.6912274", "0.6886605", "0.6870932...
0.67186964
29
Checks if the digits in a UPC is consistent with checksum
def checksum (upc): # check type of input # raise TypeError if not string # xxxxxxxxxxx x # check length of string # raise ValueError if not 12 # convert string to array # generate checksum using the first 11 digits provided # check against the the twelfth digit # result of fir...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checksum(upc):\n\n # check type of input\n if type(upc) != str:\n # raise TypeError if not string\n raise TypeError(\"Input must be a string\")\n # check length of string\n elif len(upc) != 12:\n # raise ValueError if not 12\n raise ValueError(\"Invalid UPC length\")\n ...
[ "0.76931924", "0.7153059", "0.6873011", "0.6843878", "0.6791563", "0.67721796", "0.67342436", "0.6706044", "0.66468424", "0.6590527", "0.65206844", "0.651262", "0.64882284", "0.64793825", "0.6446997", "0.643259", "0.64238644", "0.6422077", "0.6409033", "0.63966155", "0.639355...
0.7522875
1
Checks if any execute sent from this function creates a table.
def test_create_staging_table_should_sends_create_table_sql(db_connection): loader = PostgresLoader("local", 5432, "db", "user", "pass") loader.create_staging_table() execute_params = [] for name, args, _ in db_connection.mock_calls: if name.endswith("execute"): for arg in args: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self):\n try:\n _ = self.engine.table_names()\n except OperationalError:\n return False\n else:\n return True", "def check_table(self, table_name: str) -> bool:\n try:\n if self.engine.dialect.has_table(self.engine.connect(), ta...
[ "0.723119", "0.67749983", "0.6705648", "0.6699322", "0.6656466", "0.6656466", "0.6647835", "0.66467416", "0.6632517", "0.6606211", "0.6589696", "0.6562214", "0.65404904", "0.65256304", "0.65187347", "0.6497645", "0.6485021", "0.6475742", "0.6475169", "0.6461142", "0.646054", ...
0.0
-1
This function is used to get results from elasticsearch response
def get_source(self, results): if results: json_results = [book['_source'] for book in results] return json_results
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_es_response(self, index_name, lucene_query=False):\n body = dict()\n lucene_query = self.build_lucene_query() if lucene_query else None\n if lucene_query is None:\n if self.fetch_querydict():\n body[\"query\"] = self.fetch_querydict()\n if self.fe...
[ "0.7462794", "0.73649436", "0.6880637", "0.6855493", "0.68401885", "0.6836686", "0.67950594", "0.6596483", "0.65936184", "0.6456584", "0.64349544", "0.643421", "0.6362724", "0.63475496", "0.6272457", "0.62275684", "0.62275684", "0.6222748", "0.61975014", "0.6183554", "0.61835...
0.0
-1
This function saves elastic search results to file.
def save_results(self, results, file_name, file_type): if file_type == 'csv': csv_filename = '{}.csv'.format(file_name) with open(csv_filename, 'w', newline='') as file: writer = csv.writer(file) writer.writerows(results)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_results_to_disk(self, result_path,results):\n with open(result_path+\"/results.txt\",\"w+\") as out:\n\n for query_num in results:\n for doc_num in results[query_num]:\n out.write(str(query_num)+\" 0 \"+doc_num+\" 1 42.38 mt\\n\")\n out.close...
[ "0.72657835", "0.69508463", "0.6894959", "0.67859924", "0.6658391", "0.642102", "0.6414044", "0.64095086", "0.63856673", "0.6371732", "0.63349044", "0.6330079", "0.62855315", "0.6249051", "0.62146336", "0.6207243", "0.6203761", "0.61993134", "0.6197115", "0.619168", "0.618454...
0.6300343
12
This function is used to fetch elastic search results based on action parameter
def command(self, action, payload): try: if action == 'append_book': self.client.create_book_doc( title=payload['title'], authors=payload['authors'], summary=payload['summary'], publisher=payload['publis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_action(self):\n #TODO: No access control checks for dataproxy resources!\n request_data = self._get_request_data(try_url_params=True)\n resource = Resource.get(request_data['resource_id'])\n if resource is not None and resource.url_type == 'dataproxy':\n pylons.res...
[ "0.69977385", "0.6270674", "0.6155154", "0.6091651", "0.60744435", "0.6063062", "0.60566103", "0.60520285", "0.60469556", "0.6026246", "0.601409", "0.5985297", "0.5985294", "0.59679466", "0.5951445", "0.5915874", "0.59071684", "0.59010565", "0.58931863", "0.58861864", "0.5877...
0.0
-1
Return the value associated to the label name in the nearest context that contains it. (search in context then context's parent and then parents of context's parent...)
def __getitem__(self, item): current = self while current is not None: if item in current.locals: return current.locals[item] current = current.parent
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _findLabel(self, label):\n if self.label == label:\n return self\n else:\n for i in range(self.nChildren()):\n found = self.children[i]._findLabel(label)\n if found:\n return found\n return None", "def findLabel(s...
[ "0.6732785", "0.6472502", "0.63983274", "0.6362595", "0.6354665", "0.6187552", "0.5988228", "0.5817141", "0.5763987", "0.57545006", "0.565232", "0.5647036", "0.56420135", "0.5641238", "0.5640664", "0.5623526", "0.56224996", "0.5612701", "0.5604131", "0.5601643", "0.5600807", ...
0.0
-1
Override 'in' operator, search the label in the local dict and all the parents dicts.
def __contains__(self, item): current = self while current is not None: if item in current.locals: return True current = current.parent return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deepin(self, key):\n \n if DEBUG:\n print(repr(self))\n if '.' in key:\n top, rest = key.split('.', 1)\n return self[top].deepin(rest)\n else:\n return key in self", "def in_(self, other):\n if hasattr(other, 'cypher'):\n ...
[ "0.61111313", "0.6106368", "0.6081639", "0.597423", "0.5954512", "0.5913556", "0.5911842", "0.59089094", "0.58900696", "0.58285034", "0.58161646", "0.5758629", "0.5724211", "0.5722771", "0.5711671", "0.5666077", "0.56355524", "0.56164795", "0.5580589", "0.5564229", "0.5564229...
0.5927448
5
Add a new instance.
def add_instance(self, context): self.instance_contexts.append(context) self.total_count += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_instance(self,name):\n new = self.create_instance(name)\n self.model.append(new)\n return new", "def add(self, *args, **kwargs):\n obj = self._class(*args, **kwargs)\n self._items.append(obj)", "def add(self):\n pass", "def add_instance(instance_class, instance):\n ...
[ "0.76611966", "0.7174424", "0.70480835", "0.70297074", "0.67531794", "0.67020816", "0.67020816", "0.66728026", "0.6642528", "0.66386175", "0.6512499", "0.6512499", "0.6508215", "0.64572376", "0.6341272", "0.6316406", "0.63124824", "0.63124824", "0.63124824", "0.63124824", "0....
0.70086604
4
Reset the current_instance counter.
def reset_current_instance(self): self.current_instance = 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_counter(self) -> None:", "def reset (self):\n self.counter = 0", "def reset(self):\n self.counter = 0", "def reset(cls):\n cls.__instance = None", "def reset_count(self):\n self.count = 0", "def reset_counter(self):\n if hasattr(self._id_generator, \"reset_cou...
[ "0.75970316", "0.7579666", "0.7566452", "0.73800683", "0.7352367", "0.73349226", "0.722008", "0.7206008", "0.7027615", "0.69778574", "0.69737387", "0.6953763", "0.69374794", "0.6844482", "0.6788848", "0.678196", "0.6729615", "0.6675882", "0.66605294", "0.6637174", "0.6578837"...
0.8937279
0
Get the last instance added.
def get_last_instance(self): return self.instance_contexts[-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_my_last_event(self):\r\n return self._handler.get_my_last_event()", "def at_last(self):\n return self._collection.at_last()", "def last(self):\n return self.last and self.last.value or None", "def last(self):\n return self.deque[-1]", "def getLastWorker(self):\n r...
[ "0.68711853", "0.6810386", "0.6726944", "0.66564316", "0.66301244", "0.6626313", "0.66114026", "0.65852886", "0.65747017", "0.6562729", "0.6555281", "0.655031", "0.6537491", "0.65363795", "0.6502471", "0.6441597", "0.6427053", "0.6420172", "0.640018", "0.6364432", "0.63504106...
0.7894895
0
Get the current instance, then increment the current_instance value.
def get_next_instance(self): self.current_instance += 1 return self.instance_contexts[self.current_instance - 1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_current_instance(self):\r\n self.current_instance = 0", "def inc(self):\n with self.mutex:\n self.value += 1\n return self.value", "def updateCounter(self):\n self.counter = self.counter + 1\n self.syncDataStructure[\"+\"][str(self.instanceID)] = self...
[ "0.690823", "0.68347883", "0.6701055", "0.66770405", "0.66295475", "0.64652735", "0.6456468", "0.64496535", "0.6416826", "0.6364535", "0.63558865", "0.625179", "0.6242719", "0.62325436", "0.6130614", "0.61168027", "0.6098057", "0.608348", "0.60704607", "0.60397077", "0.603596...
0.8085299
0
Add a label to the current context. Override [] assignment.
def __setitem__(self, name: str, address: int): if self.loaded: return if address is None: address = self.mem_offset elif address.bit_length() > 32: raise ValueError("Label address should be 32 bits long!") self.current_context[name] = addre...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addLabel(*args):", "def add_label(self, label):\n if not self.has_label(label):\n self.add_category(scheme=LABELS_SCHEME,\n term='%s#%s' % (LABELS_NS, label),\n label=label)", "def add_label(self, label):\n status = self.ocp.add_label(resource_na...
[ "0.70385796", "0.6876934", "0.6845709", "0.6823565", "0.6769882", "0.6705551", "0.6681595", "0.64906585", "0.64906585", "0.64906585", "0.64906585", "0.64906585", "0.64906585", "0.64906585", "0.64906585", "0.64906585", "0.64906585", "0.64906585", "0.6435672", "0.63145304", "0....
0.5952216
48
Get address associated to the label name in current_context.
def __getitem__(self, name): if name not in self.current_context: raise KeyError("Trying to use an undefined label!") return self.current_context[name]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addr(label_name):\n\n if not utils.is_string_type(label_name):\n return None\n\n return labelmanager.addr(label_name)", "def label(self):\n return self.address.label", "def get_label(self):\r\n return _(\"Address:\")", "def get_current_address(self):\n pass", "def addr...
[ "0.8102275", "0.74246526", "0.69652647", "0.69573796", "0.68766636", "0.67406845", "0.66722447", "0.662005", "0.6568933", "0.6568933", "0.6568933", "0.6543465", "0.64369625", "0.6348741", "0.6345188", "0.6335663", "0.6335663", "0.6301542", "0.62912315", "0.62291235", "0.62291...
0.5937727
47
Register a new macro in the macros dict.
def register_macro(self, name: str): self.macros.setdefault(name, Macro())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_macro_context(self, name: str, context: dict = None):\r\n if context is None:\r\n context = dict()\r\n self.macros[name].add_instance(dict())", "def _expand_macros(tokdict,macrodict):\r\n def macro_value(m):\r\n return '(?:%s)' % macrodict[m.groupdict()['macro']]\r\n ...
[ "0.667128", "0.6386615", "0.6171267", "0.5982367", "0.59769773", "0.58068347", "0.57270074", "0.5714279", "0.5649475", "0.56381917", "0.5628102", "0.5482599", "0.5440994", "0.5368773", "0.5367753", "0.5353264", "0.53425723", "0.5309798", "0.5293307", "0.52802014", "0.52768517...
0.8195985
0
Add a new instance/context to a Macro object
def add_macro_context(self, name: str, context: dict = None): if context is None: context = dict() self.macros[name].add_instance(dict())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_instance(self, context):\r\n self.instance_contexts.append(context)\r\n self.total_count += 1", "def add(self, context):\n self._contexts.add(context)", "def __init__(self, macro_name, macro_content):\n self._macro_name = process_for_latex(macro_name)\n self._macro_co...
[ "0.64550906", "0.5815178", "0.581206", "0.57343155", "0.56727946", "0.565651", "0.56156", "0.5564796", "0.5564684", "0.5454445", "0.536506", "0.5324165", "0.53177595", "0.5314927", "0.5123087", "0.5122237", "0.508866", "0.50394654", "0.5033408", "0.5000955", "0.49768367", "...
0.8081105
0
Switch the current context.
def switch_context(self, context): self.context_stack.append(self.current_context) self.current_context = context
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def switch(self, context):\n return", "def _set_context(self, ctx):\n try:\n current_engine_name = self.parent.engine.name \n if sgtk.platform.current_engine(): \n sgtk.platform.current_engine().destroy()\n sgtk.platform.start_engine(curren...
[ "0.7744432", "0.7199943", "0.71186477", "0.69892776", "0.68974406", "0.68526095", "0.68338317", "0.68338317", "0.678041", "0.6674753", "0.66629636", "0.66492593", "0.6548222", "0.6524813", "0.6431893", "0.61897355", "0.6144941", "0.6088508", "0.60671574", "0.60372967", "0.594...
0.8493895
0
Restore the previous context.
def restore_context(self): self.current_context = self.context_stack.pop()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def context_reset(self):\n self._context_state = None\n logging.info('Resetting the context')", "def restore_context(self, filepath):\n\n raise NotImplementedError()", "def reset(self, *_):\n with self._context.lock:\n super().reset()\n self.__context_init()", "def r...
[ "0.7633371", "0.71010125", "0.7044028", "0.6811748", "0.6767361", "0.6687625", "0.66691613", "0.6668881", "0.65513235", "0.6521201", "0.6511832", "0.6501799", "0.65001637", "0.6458619", "0.6444411", "0.6437519", "0.64000064", "0.6383079", "0.6379866", "0.63735694", "0.6261989...
0.8610675
0
The macro function decorator.
def macro(self, func): self.register_macro(func.__name__) def wrapper(*args, **kwargs): old = func.__globals__.copy() for key in self.current_context.keys(): del func.__globals__[key] if not self.loaded: self.add_macro_contex...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_macro(extension):\n def macro(body, args, kwargs, is_block, environ):\n if extension.is_void and body:\n return wrap(MarkupErrorElement(\n _(u'Macro “%s” was passed a body but does not '\n u'support it.') % extension.name))\n # ensure the body is...
[ "0.6746005", "0.65535325", "0.65420234", "0.6394286", "0.630091", "0.62976325", "0.6149211", "0.6125098", "0.6049065", "0.5981956", "0.5956665", "0.5904848", "0.5892715", "0.5882666", "0.58784175", "0.5797652", "0.5781429", "0.5764209", "0.5754016", "0.57075137", "0.5688477",...
0.6873393
0
Creates four plotly visualizations
def return_figures(): graph_one = [] df = cleanparrisdf('data/Salem-Village-Data-Set.csv') sources = [0,0,0,1,1,1] targets = [2,3,4,2,3,4] values = df["petition_count"].tolist() data_one = dict( type = 'sankey', node = dict( pad = 10, thickness = 30, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_four_subplots():\n pass", "def _dump_plotly(objs, images, func):\n l = len(objs)\n #print(l)\n titles = []\n for i,x in enumerate(objs):\n if 'id' in x:\n titles.append('shape id %d' % x.id)\n else:\n titles.append('item %d' % i)\n fig = tools.make...
[ "0.67787457", "0.67741823", "0.6709394", "0.66095567", "0.6584778", "0.6558427", "0.65149283", "0.65014064", "0.6490014", "0.6450255", "0.64477116", "0.64458466", "0.6433457", "0.64264965", "0.63953656", "0.63761175", "0.6325457", "0.6275925", "0.6252392", "0.62307435", "0.62...
0.65156674
6
Called once for each new DBAPI connection or Pool's ``creator()``.
def connect(self, dbapi_connection, connection_record):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_db(self):", "def __post_init__(self):\n self.dbase = databases.Database(\n self.dsn,\n min_size=self.min_size,\n max_size=self.max_size\n )\n self.engine, self.meta = self.get_engine_metadata()", "def __init__(self):\r\n self.conn = create...
[ "0.67084223", "0.6569219", "0.6454597", "0.6436407", "0.63408655", "0.6325389", "0.6321908", "0.6320368", "0.6276563", "0.6123838", "0.6116719", "0.60971427", "0.60663396", "0.6058905", "0.6053489", "0.60504884", "0.6048023", "0.60348487", "0.6015557", "0.60084504", "0.600389...
0.5790405
43
Called exactly once for the first DBAPI connection.
def first_connect(self, dbapi_connection, connection_record):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self._connection = get_db_connection()", "def connect(self, dbapi_connection, connection_record):", "def _db_connection(self):\n pass", "def init(self):\n self.conn = None\n\n return True", "def __init__(self):\n\t\tself.obtainDatabaseConnection()", "def ...
[ "0.67195183", "0.6715476", "0.656256", "0.6527683", "0.65126604", "0.6497691", "0.64863473", "0.6459973", "0.64582694", "0.6446564", "0.6421492", "0.64208746", "0.64178276", "0.6338431", "0.63314486", "0.63314486", "0.63314486", "0.63299924", "0.6309114", "0.62960386", "0.627...
0.82037026
0
Called when a connection is retrieved from the Pool.
def checkout(self, dbapi_connection, connection_record, connection_proxy):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connection_handler(self):\n\t\tyield", "def connection(self):\n pass", "def handle_connect(self):\n pass", "def onConnect(self, fetcher, connectionRespInfo): #$NON-NLS-1$\r", "def on_connection_closed(self):", "def _get_pool (self, event):\n return self.pool", "def connectionMade(s...
[ "0.68182594", "0.65938705", "0.65584147", "0.6508858", "0.6370177", "0.63244736", "0.631224", "0.625429", "0.61409163", "0.61398953", "0.61378413", "0.61329424", "0.6114277", "0.6067553", "0.6044404", "0.6031086", "0.6023959", "0.5957651", "0.5946259", "0.59285915", "0.58868"...
0.0
-1
Called when a connection returns to the pool. Note that the connection may be closed, and may be None if the connection has been invalidated. ``checkin`` will not be called for detached connections. (They do not return to the pool.)
def checkin(self, dbapi_connection, connection_record):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _connect_ping_listener(connection, branch):\n if branch:\n return\n\n save_should_close_with_result = connection.should_close_with_result\n connection.should_close_with_result = False\n try:\n connection.scalar(select([1]))\n except Exception as ex:\n connection.scalar(selec...
[ "0.60195", "0.5795708", "0.5717088", "0.5673639", "0.5561772", "0.5525928", "0.5447038", "0.54178834", "0.53633946", "0.53565466", "0.53255045", "0.5321494", "0.5262716", "0.5241045", "0.5227323", "0.5221151", "0.5160429", "0.5118911", "0.5092049", "0.5090331", "0.507445", ...
0.566654
4
Create the response for a resource. Note this will only be called on a GET request, or on a POST request if always_return_data is True
def create_response(self, *args, **kwargs): response = super(BaseCorsResource, self).create_response(*args, **kwargs) response['Access-Control-Allow-Origin'] = '*' response['Access-Control-Allow-Headers'] = 'Content-Type' return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_response(self, request, data, response_class=HttpResponse, **response_kwargs):\n desired_format = self.determine_format(request)\n serialized = self.serialize(request, data, desired_format)\n return response_class(content=serialized, content_type=build_content_type(desired_format), ...
[ "0.684795", "0.67284703", "0.65661", "0.65661", "0.6558773", "0.6552452", "0.65262616", "0.64544326", "0.6433191", "0.64107007", "0.6401898", "0.6400182", "0.6398697", "0.6370619", "0.63630956", "0.6340539", "0.63312286", "0.63245285", "0.63164157", "0.6306914", "0.62642473",...
0.5979391
38
In case of POST make sure we return the AccessControlAllow Origin regardless of returning data
def post_list(self, request, **kwargs): response = super(BaseCorsResource, self).post_list(request, **kwargs) response['Access-Control-Allow-Origin'] = '*' response['Access-Control-Expose-Headers'] = 'Location' return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allow_cors(response):\n response.headers['Access-Control-Allow-Origin'] = '*'\n return response", "def set_allow_origin(resp):\r\n\r\n h = resp.headers\r\n\r\n # Allow crossdomain for other HTTP Verbs\r\n if request.method != 'OPTIONS' and 'Origin' in request.headers:\r\n h['Access-Cont...
[ "0.7086852", "0.69381195", "0.6836254", "0.66719115", "0.6659176", "0.6654634", "0.6618818", "0.6615156", "0.66011363", "0.6375704", "0.63684464", "0.63684464", "0.63429356", "0.63429356", "0.63219905", "0.6309055", "0.63040024", "0.6261309", "0.62494254", "0.62150615", "0.61...
0.6290511
17
Check for an OPTIONS request. If so return the Allow headers
def method_check(self, request, allowed=None): if allowed is None: allowed = [] request_method = request.method.lower() allows = ','.join(map(lambda s: s.upper(), allowed)) if request_method == 'options': response = HttpResponse(allows) response['A...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def OPTIONS(self, req):\r\n resp = req.get_response(self.app)\r\n return resp", "def option_autoreply():\r\n\r\n if request.method == 'OPTIONS':\r\n resp = app.make_default_options_response()\r\n\r\n headers = None\r\n if 'ACCESS_CONTROL_REQUEST_HEADERS' in request.headers:\...
[ "0.71109694", "0.69889754", "0.6984551", "0.6971069", "0.6924216", "0.66727746", "0.6659201", "0.66527027", "0.66407734", "0.66034204", "0.6574077", "0.6539291", "0.6531127", "0.6491254", "0.6491254", "0.6483288", "0.6477986", "0.6375473", "0.63449395", "0.6335919", "0.632943...
0.6661477
6
This function returns a Pyramid WSGI application.
def main(global_config, **settings): session_factory = UnencryptedCookieSessionFactoryConfig('ent85an') config = Configurator(settings=settings, session_factory=session_factory) config.include('pyramid_chameleon') config.add_static_view('static', 'test2:static') config.add_route('home', '/') con...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wsgi_app():\n return bottle.default_app()", "def wsgi_app():\n return bottle.default_app()", "def bootstrap_wsgi():\n return get_wsgi_application()", "def app():\n return create_app()", "def app():\n app = create_app()\n return app", "def create_app():\n from server.web import cr...
[ "0.7845448", "0.7845448", "0.77415055", "0.77049613", "0.7661403", "0.7531494", "0.7400627", "0.72649485", "0.7240864", "0.7236693", "0.71695787", "0.7167029", "0.7141517", "0.7115303", "0.7102023", "0.7096362", "0.7059266", "0.7029423", "0.7027549", "0.7004948", "0.70026654"...
0.0
-1
update a client entry
def set(self, client): if not client: raise SurvoxAPIMissingParameter('client') c = self.get() if not c: raise SurvoxAPIRuntime('No client available named: {name}'.format(name=self.name)) return self.api_put(endpoint=self.url, data=client)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_client(client_name, updated_client_name): # Operacion modificar\n global clients\n\n if client_name in clients:\n index = clients.index(client_name)\n clients[index] = updated_client_name\n else:\n print(\"Client isn\\'t in the client list\")", "def update(self, klient):...
[ "0.7091264", "0.68076223", "0.66998833", "0.631657", "0.6194887", "0.6194887", "0.61497957", "0.61200696", "0.61006886", "0.60602057", "0.603199", "0.6016784", "0.60054356", "0.597109", "0.5959419", "0.5959419", "0.5959419", "0.5945082", "0.5945082", "0.5945082", "0.5945082",...
0.61617506
6
Creates an HTML file with given template and content.
def create_html(text, template, output): # TODO uncomment this for orginal DMP format (right now difficult with differing section sizes) #templateLoader = jinja2.FileSystemLoader(searchpath="../templates/new") templateLoader = jinja2.FileSystemLoader(searchpath="../templates") templateEnv = jinja2.Envi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def provide_html_template():\n get_content = str(input(\"Paste the content you want to see displayed in the browser here. \\n\"))\n get_name = input(\"I am going to create an html file with your content. What do you want to call your file? \\n\")\n \n new_html_file = open(str(get_name) + '.html', 'w')\...
[ "0.76947534", "0.70680845", "0.6908305", "0.68400776", "0.68179643", "0.6798371", "0.6737883", "0.67168546", "0.6636704", "0.655709", "0.65269643", "0.646904", "0.6464826", "0.64504373", "0.6447081", "0.64354914", "0.6418375", "0.6408326", "0.640207", "0.63944256", "0.6386369...
0.7549857
1
Converts a given HTML file into a PDF.
def create_pdf(html, options): # TODO: we will change this path, or use an other library for converting PDF! # TODO: otherwise just say that wkhtmltopdf needs to be pre-installed (and how) and added to windows path path_wkthmltopdf = "C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe" config = pdfkit.co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html2pdf(html_filename, output_filename=None, **options):\n\n if not output_filename:\n output_filename = newTempfile(suffix='.pdf')\n\n if not pdfreactor_available:\n raise RuntimeError(\"The external 'pdfreactor' converter isn't available\")\n\n cmd = '%s \"pdfreactor\" \"%s\" \"%s\"' ...
[ "0.7248246", "0.7169749", "0.71362674", "0.6948476", "0.6708248", "0.6610215", "0.658075", "0.6533911", "0.6426139", "0.642575", "0.63720566", "0.63564223", "0.61420655", "0.6088606", "0.60696626", "0.6064924", "0.6037568", "0.6029076", "0.6007931", "0.5998022", "0.59935737",...
0.756505
0
Return list of groups (id) for requested projects flag groups declared as projects owner
def get_project_groups_id(self, names): assert isinstance(names, list) # Getting access rules for all projects hosted # is done by one request specifiying multiple # project names inside the query string. To act safer # bulk limits the amount of projects requested in one shot ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_groups(self, obj):\n groupsForCompany = get_groups_with_perms(obj)\n return [x.id for x in groupsForCompany]", "def get_groups(id_project):\n data = sql.list_groups(id_project)\n names = [(d['id'], d['name']) for d in data]\n return names", "def list_projects(ctx):\n pprint(ct...
[ "0.66103697", "0.6584689", "0.6564444", "0.6420417", "0.6404506", "0.63974404", "0.6299866", "0.627742", "0.62102056", "0.6117552", "0.61089313", "0.60776865", "0.60669416", "0.60601676", "0.60473305", "0.6034015", "0.6022365", "0.59869814", "0.5985959", "0.5977469", "0.59712...
0.66556174
0
Request the group endpoint to get details of multiple groups
def get_groups_details(self, groups): assert isinstance(groups, list) # It may be require we request the API by splitting the names list # If the list is too long to be handled by the Gerrit server (URI) query_args = "?%s" % "&".join(["q=%s" % g for g in groups]) query_args += "&...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def groups(self):\n #return self.get('{}/groups'.format(ApiVersion.A1.value))\n return self.get('{}/groups'.format(ApiVersion.CM1.value))", "def test_api_v1_groups_get(self):\n pass", "def get_groups():\r\n if 'username' not in flask.session:\r\n return flask.jsonify(**{'message': 'Forbi...
[ "0.7579643", "0.7527016", "0.7344905", "0.7330088", "0.72096586", "0.7103131", "0.70869297", "0.70068043", "0.7004014", "0.69652194", "0.69452596", "0.6931994", "0.6902277", "0.6881346", "0.6832857", "0.6832857", "0.679868", "0.6796173", "0.6764522", "0.6754042", "0.6751882",...
0.72024137
5
Update a gerrit account. Only 'full_name' and 'email' can be updated.
def update_account(self, id=None, username=None, **kwargs): if not (bool(id) != bool(username)): raise TypeError('account id OR username needed') if 'full_name' in kwargs.keys(): try: self.g.put('accounts/%s/name' % id or username, data=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account_update(request):\r\n params = request.params\r\n json_body = request.json_body\r\n user_acct = request.user\r\n\r\n if 'name' in params and params['name'] is not None:\r\n name = params.get('name')\r\n user_acct.name = name\r\n\r\n if 'name' in json_body and json_body['name...
[ "0.7108805", "0.6938995", "0.6783032", "0.65848964", "0.6567411", "0.6345919", "0.63428134", "0.63318664", "0.6312359", "0.6220183", "0.6206186", "0.6164123", "0.60568076", "0.60517806", "0.60360813", "0.60136294", "0.60079366", "0.59596103", "0.5938938", "0.5931337", "0.5928...
0.74522334
0
Add a group as a member of targetgroup
def add_group_group_member(self, targetgroup, groupname): try: targetgroup = self.quote(targetgroup) groupname = self.quote(groupname) self.g.put('groups/%s/groups/%s' % (targetgroup, groupname), headers={...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def target_add():\r\n try:\r\n target_id = request.post_vars[\"target\"]\r\n group_id = request.post_vars[\"group\"]\r\n except KeyError:\r\n pass\r\n\r\n result = gl.add_to_targetgroup(target_id, group_id)\r\n\r\n if result:\r\n return response.json({'success': 'true'})\r\n...
[ "0.7717108", "0.7391383", "0.71136713", "0.7108314", "0.7095311", "0.7065485", "0.701168", "0.7006552", "0.70005846", "0.6773371", "0.67148256", "0.66208655", "0.65720075", "0.6564292", "0.6531716", "0.65001243", "0.63495827", "0.6329787", "0.62838423", "0.6272301", "0.626889...
0.7701457
1
Get members (only groups) from a group
def get_group_group_members(self, group_id): try: group_id = self.quote(group_id) return self.g.get('groups/%s/groups/' % group_id) except HTTPError as e: return self._manage_errors(e)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetGroupMembers(self, group):\n return []", "def get_group_members(self, group):\n members = []\n result = self.search('ou=groups,dc=mozilla',\n filterstr='cn=%s' % (group))\n if result == False:\n raise self.SearchError\n elif result == []:\n ...
[ "0.83936936", "0.8045745", "0.79308033", "0.78087026", "0.76893365", "0.7658868", "0.7603729", "0.741923", "0.7283984", "0.7239289", "0.71412396", "0.7121257", "0.7118644", "0.7051566", "0.6994696", "0.69646496", "0.69614774", "0.6901935", "0.6875227", "0.68618", "0.68494815"...
0.73979783
8
Delete a group from targetgroup
def delete_group_group_member(self, targetgroup, groupname): try: targetgroup = self.quote(targetgroup) groupname = self.quote(groupname) self.g.delete('groups/%s/groups/%s' % (targetgroup, groupname), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_targetgroup(self, group_id):\r\n result = False\r\n if self._db(self._db.targetgroup.id==group_id).select():\r\n result = True\r\n self._db(self._db.targetgroup.id==group_id).delete()\r\n self._db.commit()\r\n return result", "def delete_group(self, gr...
[ "0.8396896", "0.8185979", "0.7967666", "0.7891638", "0.77520156", "0.77520156", "0.77403957", "0.7690325", "0.76890093", "0.7616403", "0.7475202", "0.7426562", "0.7398512", "0.7395208", "0.7328195", "0.72837687", "0.7269247", "0.7232773", "0.720851", "0.7190769", "0.71823627"...
0.7907041
3
Query and report the OSP version installed.
def version(version_file=default_version_file, osp_package=default_osp_package): if os.path.exists(version_file): (version_string, version_name) = version_from_file(version_file) else: package_info = get_package_info(osp_package) repo_name = get_package_repo_name(package_info) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_version(self):\n verxml = self._ncc.nxoscli('show version')\n self.logger.debug(verxml)\n verparsed = _begin_parse(verxml)\n sysmgrclischema = parse_get_nsmap(verparsed)\n self.logger.debug(\"NSMAP: {}\".format(sysmgrclischema))\n showversion = find_element(['sys_v...
[ "0.62560534", "0.62320054", "0.61539745", "0.6118965", "0.6067751", "0.6008523", "0.60057247", "0.5996084", "0.5991579", "0.5935117", "0.59256303", "0.58937836", "0.58934015", "0.58901566", "0.58520997", "0.58439976", "0.5840832", "0.58345205", "0.579143", "0.5719222", "0.570...
0.0
-1
From OSP 13 on the version release and build numbers are reported in a
def version_from_file(version_filename): version_pattern = "Red Hat OpenStack Platform release ([\d.]+) \((.*)\)" version_re = re.compile(version_pattern) # should try and check. A single line with a newline version_file = open(version_filename) release_string = version_file.read().strip...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getBuild(number):", "def getBuild(number):", "def getBuild():", "def test_get_build_number(self):\n pass", "def _get_version(self):", "def Version(self) -> _n_0_t_12:", "def Version(self) -> _n_0_t_12:", "def get_comp_versions (component):\n vprint (\"Detecting current version for \" + ...
[ "0.7062167", "0.7062167", "0.68922627", "0.6604141", "0.6483877", "0.6466972", "0.6466972", "0.6383637", "0.6371243", "0.6340458", "0.62917477", "0.62903494", "0.6287496", "0.62805766", "0.62408024", "0.6207156", "0.6180137", "0.6142765", "0.6140882", "0.60793465", "0.6038238...
0.0
-1
Query the system for package information of a specified RPM Query the package information only for the installed package and work from cached data to avoid side effects to the host. Return a list of lines from the response STDOUT
def get_package_info(package_name): info_command_template = "yum info installed --cacheonly {}" info_command = info_command_template.format(package_name) # subprocess wants a list of arguments, not a single string try: package_info = subprocess.check_output(info_command.split(), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_packages(module, repo_mgr, list_type, package):\n rc_code, out, err = module.run_command(\"/usr/bin/%s -q list %s %s\"\n % (repo_mgr, list_type, package), environ_update=ENV_LOCALE)\n if rc_code is 0:\n return out.splitlines()\n else:\n if rc...
[ "0.6890891", "0.6458352", "0.6417518", "0.6267885", "0.61134464", "0.6095884", "0.60921556", "0.60532266", "0.6008601", "0.59963685", "0.59829915", "0.594374", "0.59393394", "0.5866107", "0.5844895", "0.58440983", "0.56793255", "0.5670345", "0.5658176", "0.5651326", "0.563908...
0.66073734
1
The source repo name is stored with the package. The "From repo" line indicates where the package came from. Return the repo name or None if not found
def get_package_repo_name(package_info): # should check that there is EXACTLY one line repo_lines = \ [line for line in package_info if line.startswith("From repo ")] # "From repo : <repo name>" # Get the value and remove white space. if len(repo_lines) > 0: repo_name = repo_lin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def source_repo_name(vcs):\n return 'source'", "def repo_of_package(self, package_name: str) -> str:\n if package_name not in self.all_packages_dict:\n return Colors.BOLD(Colors.LIGHT_MAGENTA(\"local/\") + package_name)\n package = self.all_packages_dict[package_name]\n if pack...
[ "0.7836136", "0.7142839", "0.6934166", "0.6934166", "0.6934166", "0.66367394", "0.6576414", "0.6525963", "0.64376867", "0.6327674", "0.6325919", "0.631426", "0.6271193", "0.62525576", "0.62364066", "0.6220603", "0.6095599", "0.6084242", "0.6082746", "0.6072888", "0.6054819", ...
0.78646374
0
Get the repo name for an OSP package That name should indicate the major version of OSP from a table. Return the version matching the repo name or None if not found
def get_version_from_repo_name(package_repo_name): version_string = yum_repos[package_repo_name] \ if package_repo_name in yum_repos.keys() \ else None return version_string
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_package_repo_name(package_info):\n\n # should check that there is EXACTLY one line\n repo_lines = \\\n [line for line in package_info if line.startswith(\"From repo \")]\n\n # \"From repo : <repo name>\"\n # Get the value and remove white space.\n if len(repo_lines) > 0:\n r...
[ "0.69046545", "0.66761976", "0.64646137", "0.6194541", "0.61512", "0.61512", "0.61512", "0.61041784", "0.6055042", "0.6055042", "0.60245675", "0.6001156", "0.59974265", "0.59744567", "0.59740454", "0.5970664", "0.59664947", "0.5939434", "0.5933307", "0.5932706", "0.591309", ...
0.7307918
0
Given xyz coordinates & dimensions of array, returns the vector index
def ravel_index(x, dims): i = 0 for dim, j in zip(dims, x): i *= dim i += j return i
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _index(tensor_3d, tensor_2d):\n x, y, z = tensor_3d.size()\n t = tensor_3d.reshape(x * y, z)\n tt = tensor_2d.reshape(x * y)\n v = t[torch.arange(x * y), tt]\n v = v.reshape(x, y)\n return v", "def get_ind(self,*q):\n try:\n if( len(q) == 1 ):\n x = q[0][:,0...
[ "0.6535142", "0.6418414", "0.63375473", "0.62212586", "0.60786873", "0.6034432", "0.6029652", "0.60194445", "0.6014285", "0.5993988", "0.5975879", "0.59538525", "0.59294975", "0.5920307", "0.5894706", "0.58881086", "0.58801156", "0.5853542", "0.5853542", "0.58395815", "0.5832...
0.6307502
3
Each of the columns in X will be correlated with each of the columns in Y. Each column represents a variable, with the rows containing the observations.
def custom_corrcoef(X, Y=None): if Y is None: Y = X if X.shape[0] != Y.shape[0]: raise Exception("X and Y must have the same number of rows.") X = X.astype(float) Y = Y.astype(float) X -= X.mean(axis=0)[np.newaxis,...] Y -= Y.mean(axis=0) xx = np.sum(X**2,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correlateX(X, y, corr=\"spearman\"):\n \n X = np.array(X)\n y = np.array(y)\n ## Force... just in case\n \n checkX(X)\n\n if corr == \"pearson\":\n corrf = pearsonr\n elif corr == \"spearman\":\n corrf = spearmanr\n else:\n raise ValueError(\"stat was not val...
[ "0.7245431", "0.69604236", "0.68757576", "0.64894485", "0.6477084", "0.6451335", "0.6428377", "0.63228226", "0.63146174", "0.62669325", "0.6253946", "0.623037", "0.62075186", "0.6185182", "0.61833954", "0.61788404", "0.6172652", "0.61705166", "0.6142473", "0.613695", "0.61175...
0.6433049
6
Takes an input and converts it into a float number
def main(): try: x = input("Type in a number to be converted to a float: ") floatnum = float(x) print(floatnum) except(ValueError): print("Could not convert the string to a float")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_float(self, prompt=\"> \"):\n\t\twhile True:\n\t\t\tans = raw_input(prompt)\n\t\t\ttry: \t\n\t\t\t\tans = float(ans)\n\t\t\t\treturn ans\n\t\t\texcept ValueError:\n\t\t\t\tif ans == \"quit\": quit()\n\t\t\t\telse: print \"Please enter a number using decimal notation.\"", "def char_float(inp_char):\n try...
[ "0.7609443", "0.75654024", "0.7514502", "0.74880666", "0.73692375", "0.73636425", "0.7316602", "0.72737426", "0.7193005", "0.7177591", "0.71387315", "0.70654273", "0.7059681", "0.70422375", "0.7035431", "0.7034577", "0.7033259", "0.7026536", "0.69930553", "0.6986892", "0.6977...
0.80235124
0
Loads a human readable English name for each softmax node.
def load(self, label_lookup_path, uid_lookup_path): if not tf.gfile.Exists(uid_lookup_path): tf.logging.fatal('File does not exist %s', uid_lookup_path) if not tf.gfile.Exists(label_lookup_path): tf.logging.fatal('File does not exist %s', label_lookup_path) # Loads mapping from string UID to hu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name(self):\n return \"Softmax. T=\" + str(self.temperature)", "def get_name():\n return \"SVM\"", "def get_name():\n return \"SVM+\"", "def get_name():\n return \"SVMd+\"", "def get_name():\n return \"SVMd+ - simplified approach\"", "def _generate_node_name(self):\...
[ "0.6529055", "0.60038584", "0.5878624", "0.5807888", "0.5711545", "0.55374044", "0.5468764", "0.54467833", "0.5432578", "0.54321104", "0.5411982", "0.54081184", "0.5389949", "0.5364748", "0.53441465", "0.5273549", "0.5242557", "0.5232287", "0.52074456", "0.5201877", "0.520096...
0.0
-1
Runs inference on an image.
def run_inference_on_image(image): if not tf.gfile.Exists(image): tf.logging.fatal('File does not exist %s', image) image_data = tf.gfile.FastGFile(image, 'rb').read() # Creates graph from saved GraphDef. #create_graph() with tf.Session() as sess: # Some useful tensors: # 'softmax:0': A tensor c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_inference_on_image(image):\n if not gfile.Exists(image):\n tf.logging.fatal('File does not exist %s', image)\n image_data = gfile.FastGFile(image, 'rb').read()\n\n # Creates graph from saved GraphDef.\n create_graph()\n\n with tf.Session() as sess:\n # Runs the softmax tensor by feeding the imag...
[ "0.80876434", "0.76775897", "0.7585265", "0.7361889", "0.72406197", "0.7163995", "0.70659184", "0.69971216", "0.69961894", "0.69929576", "0.69677186", "0.6897145", "0.68879974", "0.6879423", "0.6831557", "0.68114525", "0.67840654", "0.6757619", "0.67368376", "0.6732527", "0.6...
0.7535307
3
Download and extract model tar file.
def maybe_download_and_extract(): dest_directory = FLAGS.model_dir if not os.path.exists(dest_directory): os.makedirs(dest_directory) filename = DATA_URL.split('/')[-1] filepath = os.path.join(dest_directory, filename) if not os.path.exists(filepath): def _progress(count, block_size, total_size): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_and_unpack_model(model_name, model_date='20200711'):\n\n # pretrained models\n pretrained_models_dir = os.path.join(ROOT_DIR, 'pre-trained-models')\n create_directory_if_not_exists(pretrained_models_dir)\n\n # pretrained model archives\n model_archive_dir = os.path.join(pretrained_model...
[ "0.783391", "0.77010363", "0.7660963", "0.7633819", "0.7511147", "0.7439116", "0.7427492", "0.73181266", "0.71618634", "0.70268524", "0.700018", "0.6992704", "0.6983917", "0.6976861", "0.68549454", "0.6840488", "0.68346643", "0.6769262", "0.67121315", "0.67109853", "0.6683404...
0.7627266
4
Builds a random function of depth at least min_depth and depth at most max_depth (see assignment writeup for definition of depth in this context)
def build_random_function(min_depth, max_depth): listoffunctions = [ ["x"] , ["y"] , [""] ] var = random.randrange(0,7) #this is not inclusive at the upper end halfvar = random.randrange(0,2) otherhalfvar = random.randrange(0,2) if max_depth == 0: # if you get the the max depth...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_random_function(min_depth, max_depth):\n depth = random.randint(min_depth, max_depth)\n return build_random_function_helper(depth)", "def build_random_function(min_depth, max_depth):\n\n # your code goes here", "def build_rand_func(min_depth, max_depth):\n\n\toptions = [['prod'],['sin_pi'],[...
[ "0.89440006", "0.87607706", "0.8079794", "0.801927", "0.79594904", "0.78108656", "0.7484326", "0.64881915", "0.6170833", "0.6011024", "0.5912187", "0.5898084", "0.5888185", "0.57918245", "0.5591146", "0.55420274", "0.550629", "0.54398507", "0.541542", "0.532502", "0.53238696"...
0.7593185
6
Evaluate the random function f with inputs x,y Representation of the function f is defined in the assignment writeup
def evaluate_random_function(f, x, y): # this section actually evaluates the functions if f[0] == "x": return x elif f[0] == "y": return y elif f[0] == "sin_pi": return math.sin(math.pi*evaluate_random_function(f[1], x, y )) elif f[0] == "cos_pi": return math.co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_random_function(f, x, y):\n\n # your code goes here", "def evaluate_random_function(f, x, y):\n\n if f[0] == \"prod\":\n return evaluate_random_function(f[1],x,y) * evaluate_random_function(f[2],x,y)\n elif f[0] == \"sin_pi\":\n return sin(evaluate_random_function(f[1],x,y) * ...
[ "0.8462733", "0.8068793", "0.8034158", "0.7850618", "0.7745526", "0.76073825", "0.7115134", "0.6986317", "0.66636187", "0.6654048", "0.64210814", "0.63877445", "0.6360093", "0.6220911", "0.6102655", "0.6082553", "0.60335815", "0.60012615", "0.5903432", "0.57977605", "0.579170...
0.7887029
3
Given an input value in the interval [input_interval_start, input_interval_end], return an output value scaled to fall within the output interval [output_interval_start, output_interval_end].
def remap_interval(val, input_interval_start, input_interval_end, output_interval_start, output_interval_end): inputrange = float(input_interval_end) - float(input_interval_start) #finds length or original interval outputrange = float(output_interval_end) - float(output_interval_start) #finds length of t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remap_interval(val, input_interval_start, input_interval_end, output_interval_start, output_interval_end):\n convert = float (val - input_interval_start) / float ( input_interval_end - input_interval_start)\n output1 = output_interval_start + convert* (output_interval_end - output_interval_start)\n re...
[ "0.79932183", "0.7901168", "0.7887289", "0.7876046", "0.7751076", "0.7288981", "0.7237463", "0.7120831", "0.7019347", "0.6851704", "0.68007386", "0.66910595", "0.6677727", "0.6569077", "0.6418457", "0.62758476", "0.625303", "0.6198374", "0.6172267", "0.616496", "0.616496", ...
0.8289255
0
Maps input value between 1 and 1 to an integer 0255, suitable for use as an RGB color code.
def color_map(val): # NOTE: This relies on remap_interval, which you must provide color_code = remap_interval(val, -1, 1, 0, 255) return int(color_code)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def color_map(val):\n color_code = remap_interval(val, -1, 1, 0, 255)\n return int(color_code)", "def c_map(val):\n return int(remap(val, -1, 1, 0, 255))", "def get_color(self, value):\n value = min(max(0,value), 1) * 510\n\n if value < 255:\n redValue = 255\n green...
[ "0.7930761", "0.7340916", "0.6859213", "0.6619156", "0.6548862", "0.6361467", "0.62869173", "0.61980194", "0.6166142", "0.60413206", "0.60389495", "0.5965779", "0.5909593", "0.58895975", "0.5883732", "0.586125", "0.5825624", "0.58123803", "0.5805797", "0.58012986", "0.5790884...
0.7823721
3
Generate test image with random pixels and save as an image file.
def test_image(filename, x_size=350, y_size=350): # Create image and loop over all pixels im = Image.new("RGB", (x_size, y_size)) pixels = im.load() for i in range(x_size): for j in range(y_size): x = remap_interval(i, 0, x_size, -1, 1) y = remap_interval(j, 0, y_size, -1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_image(filename, x_size=350, y_size=350):\n # Create image and loop over all pixels\n im = Image.new(\"RGB\", (x_size, y_size))\n pixels = im.load()\n for i in range(x_size):\n for j in range(y_size):\n pixels[i, j] = (random.randint(0, 255), # Red channel\n ...
[ "0.7916328", "0.73138684", "0.7276964", "0.72279763", "0.6833925", "0.67390573", "0.6636539", "0.6577365", "0.6552666", "0.654833", "0.6493901", "0.64547956", "0.6446572", "0.6445794", "0.6444757", "0.6440958", "0.6415097", "0.6344109", "0.63346565", "0.6326465", "0.6290015",...
0.7180069
6
Generate computational art and save as an image file.
def generate_art(filename, x_size=1920, y_size=1080): # Functions for red, green, and blue channels - where the magic happens! red_function = build_random_function(7,8) green_function = build_random_function(4,6) blue_function = build_random_function(3,5) # Create image and loop over all pixels ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_art(filename, x_size=350, y_size=350):\n # Functions for red, green, and blue channels - where the magic happens!\n r_lb = random.randint(6, 10)\n g_lb = random.randint(6, 10)\n b_lb = random.randint(6, 10)\n red_function = build_random_function(r_lb, r_lb+1)\n green_function = build...
[ "0.71219194", "0.69798446", "0.68660295", "0.6794313", "0.6750983", "0.66667235", "0.6619679", "0.64958155", "0.6475446", "0.6467824", "0.6457414", "0.6439815", "0.6421548", "0.64128166", "0.64050144", "0.6403127", "0.63413537", "0.6339301", "0.63320214", "0.63320214", "0.633...
0.6785918
4