query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Justified (name, value, units, doc) strings for active parameters. | def param_strs(self):
name_len = max(len(p.name) for p in self)
value_len = max(len(p.value_str) for p in self.params.values())
units_len = max(len(p.units) for p in self.params.values())
return [(p.name.ljust(name_len), p.value_str.ljust(value_len),
p.units.ljust(units_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n num_active = len([p for p in self if p])\n summary = \"%s has %d parameters with %d active (non-default)\" % \\\n (self.__class__.__name__, len(self), num_active)\n if num_active == 0:\n return summary\n return summary + ':\\n' + '\\n'.jo... | [
"0.7582478",
"0.6667753",
"0.65951604",
"0.6493384",
"0.64455795",
"0.64114326",
"0.63715106",
"0.62896985",
"0.6242153",
"0.62383384",
"0.62208116",
"0.62207097",
"0.61746264",
"0.6109571",
"0.61072844",
"0.6098375",
"0.60816747",
"0.6051815",
"0.6050969",
"0.60330296",
"0.6... | 0.7280672 | 1 |
Base hash on description string, just like equality operator. | def __hash__(self):
return hash(self.description) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(self) -> str:\r\n ...",
"def __hash__(self):\n\n return hash((str(self.type) + str(self.value)))",
"def __hash__(self):\n return hash(self.text)",
"def hash(self) -> bytes:",
"def hash(self, string):\n return self.__scaffydb.hash(string)",
"def __hash__(self):\n ... | [
"0.72970223",
"0.70238286",
"0.6990711",
"0.68921405",
"0.6877547",
"0.6868672",
"0.6868672",
"0.6868672",
"0.6853107",
"0.6853107",
"0.6853107",
"0.6853107",
"0.6820892",
"0.68152857",
"0.67963797",
"0.67854613",
"0.67854613",
"0.67854613",
"0.6765069",
"0.67579234",
"0.6742... | 0.8038765 | 0 |
Convert 2D alignment parameters (alpha, sx, sy, mirror) into 3D alignment parameters (phi, theta, psi, s2x, s2y, mirror) | def params_2D_3D(alpha, sx, sy, mirror):
phi = 0
psi = 0
theta = 0
alphan, s2x, s2y, scalen = compose_transform2(0, sx, sy, 1, -alpha, 0, 0, 1)
if mirror > 0:
phi = (540.0 + phi)%360.0
theta = 180.0 - theta
psi = (540.0 - psi + alphan)%360.0
else:
psi = (psi + alphan)%360.0
return phi, theta, ps... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_3D_2D(phi, theta, psi, s2x, s2y):\n\tif theta > 90.0:\n\t\tmirror = 1\n\t\talpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 540.0-psi, 0, 0, 1.0)\n\telse:\n\t\tmirror = 0\n\t\talpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 360.0-psi, 0, 0, 1.0)\n\treturn alpha, sx, sy, mirror"... | [
"0.75017375",
"0.6478277",
"0.647607",
"0.63587636",
"0.60074914",
"0.5803451",
"0.5758167",
"0.5752519",
"0.5700443",
"0.5646637",
"0.56198543",
"0.5572641",
"0.5455936",
"0.54369533",
"0.5418458",
"0.5403827",
"0.539565",
"0.5376442",
"0.53718555",
"0.53706646",
"0.53607404... | 0.78717786 | 0 |
Convert 3D alignment parameters (phi, theta, psi, s2x, s2y) there is no mirror in 3D! into 2D alignment parameters (alpha, sx, sy, mirror) | def params_3D_2D(phi, theta, psi, s2x, s2y):
if theta > 90.0:
mirror = 1
alpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 540.0-psi, 0, 0, 1.0)
else:
mirror = 0
alpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 360.0-psi, 0, 0, 1.0)
return alpha, sx, sy, mirror | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_2D_3D(alpha, sx, sy, mirror):\n\tphi = 0\n\tpsi = 0\n\ttheta = 0\n\talphan, s2x, s2y, scalen = compose_transform2(0, sx, sy, 1, -alpha, 0, 0, 1)\n\tif mirror > 0:\n\t\tphi = (540.0 + phi)%360.0\n\t\ttheta = 180.0 - theta\n\t\tpsi = (540.0 - psi + alphan)%360.0\n\telse:\n\t\tpsi = (psi + alphan)... | [
"0.76915425",
"0.6404001",
"0.6382034",
"0.6108902",
"0.6060465",
"0.6017704",
"0.57541436",
"0.5705645",
"0.5625745",
"0.5595656",
"0.5591025",
"0.55300176",
"0.5473145",
"0.53983897",
"0.53954655",
"0.5385849",
"0.53646827",
"0.53643596",
"0.536235",
"0.5350919",
"0.5346317... | 0.7371874 | 1 |
Commented by Zhengfan Yang on 05/01/07 I made some change to the original amoeba so that it can now pass out some values calculated by func other than the criteria. This is important in multilevel amoeba refinement because otherwise, upper level refinement will lose the information of lower level refinement. | def amoeba_multi_level(var, scale, func, ftolerance=1.e-4, xtolerance=1.e-4, itmax=500, data=None):
#print " ENTER AMOEBA MULTI LEVEL"
nvar = len(var) # number of variables in the minimization
nsimplex = nvar + 1 # number of vertices in the simplex
# first set up the simplex
simplex = [0]*(nvar+1) # set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fit_amoeba(self, kwargs, verbose):\n\n args_init = self._param_class.kwargs_to_args(kwargs)\n\n options = {\n \"adaptive\": True,\n \"fatol\": self._tol_simplex_func,\n \"maxiter\": self._simplex_n_iterations * len(args_init),\n }\n\n method = \"Nel... | [
"0.5649461",
"0.56487626",
"0.5537902",
"0.55107564",
"0.5501089",
"0.54266936",
"0.5403812",
"0.53776634",
"0.5360801",
"0.5356619",
"0.5301135",
"0.52775687",
"0.5269604",
"0.5262089",
"0.52313644",
"0.5223302",
"0.5188832",
"0.5179477",
"0.516795",
"0.51599634",
"0.5152701... | 0.599668 | 0 |
Fit the histogram of the input image under mask with the reference image. | def ce_fit(inp_image, ref_image, mask_image):
hist_res = Util.histc(ref_image, inp_image, mask_image)
args = hist_res["args"]
scale = hist_res["scale"]
data = [hist_res['data'], inp_image, hist_res["ref_freq_bin"], mask_image, int(hist_res['size_img']), hist_res['hist_len']]
res = amoeba(args, scale, hist_func, 1.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hist2d(x,y,nbins = 50 ,maskval = 0,saveloc = '',labels=[],slope = 1,sloperr = 0):\n\t# Remove NANs and masked values\n\tgood = where((isnan(x) == False) & (isnan(y) == False) & (x != maskval) & (y != maskval))\n\tx = x[good]\n\ty = y[good]\n\n\t# Create histogram\n\tH,xedges,yedges = histogram2d(x,y,bins=nbins... | [
"0.5717073",
"0.55807126",
"0.5528441",
"0.55023885",
"0.54681766",
"0.54579365",
"0.54448426",
"0.54230475",
"0.54140556",
"0.5352749",
"0.53307045",
"0.5266392",
"0.52623886",
"0.5244729",
"0.52365315",
"0.52273583",
"0.52006847",
"0.52000165",
"0.5193751",
"0.5170942",
"0.... | 0.57911646 | 0 |
Find the position of the commone line in 3D Formula is (RB^T zhat) cross (RA^T zhat) Returns phi, theta of the common line in degrees. theta always < 90 Notice you don't need to enter psi's; they are irrelevant | def common_line_in3D(phiA,thetaA,phiB,thetaB):
from math import pi, sqrt, cos, sin, asin, atan2
piOver=pi/180.0;
ph1 = phiA*piOver;
th1 = thetaA*piOver;
ph2 = phiB*piOver;
th2 = thetaB*piOver;
#nx = cos(thetaBR)*sin(thetaAR)*sin(phiAR) - cos(thetaAR)*sin(thetaBR)*sin(phiBR) ;
#ny = cos(thetaAR)*sin(thet... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def theta_finder(theta, point_a, point_b, point_c, point_c_new):\n x, y, z = parametrized_circle(point_a, point_b, point_c, theta)\n residual = (x - point_c_new[0])**2 + (y - point_c_new[1])**2 + (z - point_c_new[2])**2\n return residual",
"def cart2spheric(x, y, z):\n # doesn't compute r because cho... | [
"0.6163923",
"0.6056872",
"0.6046275",
"0.60347825",
"0.59408677",
"0.5916736",
"0.58936423",
"0.5829221",
"0.58063835",
"0.57062423",
"0.57015944",
"0.56956786",
"0.5686689",
"0.56826967",
"0.56771237",
"0.5673097",
"0.56674886",
"0.56646484",
"0.56586415",
"0.56585634",
"0.... | 0.68433595 | 0 |
Combine 2D alignent parameters including mirror | def combine_params2(alpha1, sx1, sy1, mirror1, alpha2, sx2, sy2, mirror2):
t1 = Transform({"type":"2D","alpha":alpha1,"tx":sx1,"ty":sy1,"mirror":mirror1,"scale":1.0})
t2 = Transform({"type":"2D","alpha":alpha2,"tx":sx2,"ty":sy2,"mirror":mirror2,"scale":1.0})
tt = t2*t1
d = tt.get_params("2D")
return d[ "alpha" ],... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_align_invert(self):\n al = align(self.amp1, self.amp2, inverse=False)\n\n al_inv = align(self.amp2, self.amp1, inverse=True)\n\n print(al.R)\n print(al_inv.R)\n\n print(al.T)\n print(al_inv.T)",
"def coord_space(\n a0: numpy.ndarray, a1: numpy.ndarray, a2: nu... | [
"0.6219051",
"0.6053582",
"0.5752545",
"0.57426506",
"0.5725641",
"0.5692372",
"0.5691541",
"0.5664221",
"0.56270707",
"0.5618279",
"0.5603235",
"0.5593693",
"0.5545809",
"0.545052",
"0.5446854",
"0.5441767",
"0.54299045",
"0.54238695",
"0.54219955",
"0.5421373",
"0.5344707",... | 0.6524807 | 0 |
Convert a text file that is composed of columns of numbers into spider doc file | def create_spider_doc(fname,spiderdoc):
from string import atoi,atof
infile = open(fname,"r")
lines = infile.readlines()
infile.close()
nmc = len(lines[0].split())
table=[]
for line in lines:
data = line.split()
for i in xrange(0,nmc):
data[i] = atof(data[i])
table.append(data)
drop_spider_doc(spiderdo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_docs(filename):\n \n # open word doc\n word = win32.gencache.EnsureDispatch('Word.Application')\n doc = word.Documents.Open(os.getcwd() + '/' + filename + \".doc\")\n doc.Activate()\n \n # read word doc as list of lists\n data = [doc.Tables(i).Range.Text for i in range(1,5)]\n... | [
"0.5493499",
"0.54529065",
"0.5267102",
"0.52564555",
"0.5165884",
"0.5158104",
"0.5139018",
"0.5111768",
"0.50976145",
"0.5082693",
"0.50638324",
"0.50472414",
"0.5038567",
"0.5021236",
"0.5013941",
"0.5003135",
"0.49983117",
"0.49895382",
"0.49807015",
"0.49714673",
"0.4959... | 0.6535076 | 0 |
Output the data in slice iz, row ix of an image to standard out. | def dump_row(input, fname, ix=0, iz=0):
fout = open(fname, "w")
image=get_image(input)
nx = image.get_xsize()
ny = image.get_ysize()
nz = image.get_zsize()
fout.write("# z = %d slice, x = %d row)\n" % (iz, ix))
line = []
for iy in xrange(ny):
fout.write("%d\t%12.5g\n" % (iy, image.get_value_at(ix,iy,iz)))
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_image_row(input, iy=0, iz=0):\n\timage=get_image(input)\n\tnx = image.get_xsize()\n\tny = image.get_ysize()\n\tnz = image.get_zsize()\n\tprint \"(z = %d slice, y = %d col)\" % (iz, iy)\n\tline = []\n\tfor ix in xrange(nx):\n\t\tline.append(\"%12.5g \" % (image.get_value_at(ix,iy,iz)))\n\t\tif ((ix + 1) ... | [
"0.71635914",
"0.70319664",
"0.7031056",
"0.6987682",
"0.68559015",
"0.6734682",
"0.6646704",
"0.64677995",
"0.6236939",
"0.60654515",
"0.59142405",
"0.56288266",
"0.5549433",
"0.5510461",
"0.5490116",
"0.5405265",
"0.54043865",
"0.5386131",
"0.5378602",
"0.53766",
"0.5349916... | 0.7089794 | 1 |
Create a list of Euler angles suitable for projections. method is either 'S' for Saff algorithm or 'P' for Penczek '94 algorithm 'S' assumes phi1> delta ; symmetry if this is set to pointgroup symmetry (cn or dn) or helical symmetry with pointgroup symmetry (scn or sdn), it will yield angles from the asymmetric unit, n... | def even_angles(delta = 15.0, theta1=0.0, theta2=90.0, phi1=0.0, phi2=359.99, method = 'S', phiEqpsi = "Minus", symmetry='c1'):
from math import pi, sqrt, cos, acos, tan, sin
from utilities import even_angles_cd
from string import lower,split
angles = []
symmetryLower = symmetry.lower()
symmetry_string =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def even_angles_cd(delta, theta1=0.0, theta2=90.0, phi1=0.0, phi2=359.99, method = 'P', phiEQpsi='Minus'):\n\tfrom math import pi, sqrt, cos, acos\n\tangles = []\n\tif (method == 'P'):\n\t\ttemp = Util.even_angles(delta, theta1, theta2, phi1, phi2)\n\t\t#\t\t phi, theta... | [
"0.63690925",
"0.59872353",
"0.5834576",
"0.5605631",
"0.5481775",
"0.5450778",
"0.5426255",
"0.5415383",
"0.540476",
"0.54044795",
"0.53929913",
"0.5386991",
"0.5379755",
"0.53729224",
"0.5372181",
"0.5360525",
"0.53372157",
"0.5305089",
"0.53043467",
"0.5274299",
"0.5256057... | 0.616338 | 1 |
Create a list of Euler angles suitable for projections. method is either 'S' for Saff algorithm or 'P' for Penczek '94 algorithm 'S' assumes phi1> delta ; phiEQpsi set this to 'Minus', if you want psi=phi; | def even_angles_cd(delta, theta1=0.0, theta2=90.0, phi1=0.0, phi2=359.99, method = 'P', phiEQpsi='Minus'):
from math import pi, sqrt, cos, acos
angles = []
if (method == 'P'):
temp = Util.even_angles(delta, theta1, theta2, phi1, phi2)
# phi, theta, psi
for i in xr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def even_angles(delta = 15.0, theta1=0.0, theta2=90.0, phi1=0.0, phi2=359.99, method = 'S', phiEqpsi = \"Minus\", symmetry='c1'):\n\n\tfrom math import pi, sqrt, cos, acos, tan, sin\n\tfrom utilities import even_angles_cd\n\tfrom string import lower,split\n\tangles = []\n\tsymmetryLower = symmetry.lower()\... | [
"0.6162403",
"0.60886765",
"0.5816294",
"0.5785667",
"0.5628353",
"0.5463198",
"0.54578865",
"0.5440061",
"0.5435098",
"0.5419207",
"0.53673875",
"0.53652376",
"0.5361059",
"0.5337354",
"0.5325969",
"0.53146446",
"0.52769536",
"0.52645385",
"0.52579445",
"0.52271026",
"0.5220... | 0.6891914 | 0 |
Get the in_plane angle from two images and output the crosss correlation value The function won't destroy input two images This is the angle that rotates the first image, ima, into the second image, ref. The sense of the rotation is clockwise. center=1 means image is first centered, then rotation angle is found | def get_inplane_angle(ima,ref, iring=1, fring=-1, ringstep=1, xtransSearch=0, ytransSearch=0, stp=1, center=1):
from alignment import Numrinit, ringwe, Applyws, ormq
from filter import fshift
first_ring=int(iring); last_ring=int(fring); rstep=int(ringstep); xrng=int(xtransSearch); yrng=int(ytransSearch); step=int(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_opt_rotate(obj_img, back_img,\n back_center_x, back_center_y,\n obj_center_x, obj_center_y,\n prev_rot_angle=0.,\n is_erosion=False):\n width = obj_img.shape[0]\n rot_img = ndimage.rotate(obj_img, prev_rot_angle, reshape=False)\n... | [
"0.6499765",
"0.64251083",
"0.629712",
"0.61103505",
"0.594957",
"0.58397025",
"0.58203536",
"0.57837665",
"0.5770846",
"0.57563686",
"0.5699609",
"0.5689523",
"0.56460613",
"0.56327623",
"0.561697",
"0.5562077",
"0.5553344",
"0.5546299",
"0.5523779",
"0.55019164",
"0.5499139... | 0.69551015 | 0 |
Return an image created from a text file. The first line of the image should contain "nx ny nz" (separated by whitespace) All subsequent lines contain "ix iy iz val", where ix, iy, and iz are the integer x, y, and z coordinates of the point and val is the floating point value of that point. All points not explicitly li... | def get_textimage(fname):
from string import atoi,atof
infile = open(fname)
lines = infile.readlines()
infile.close()
data = lines[0].split()
nx = atoi(data[0])
ny = atoi(data[1])
nz = atoi(data[2])
e = EMData()
e.set_size(nx, ny, nz)
e.to_zero()
for line in lines[1:]:
data = line.split()
ix = a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_image(filename):\n try:\n fi = open(filename,\"r\")\n lines = fi.readlines()\n n = int(lines[0]);\n img = create_zeroed_image(n)\n for i,line in enumerate(lines[1:]):\n clean_line = line.strip() # remove whitespace and newlines\n for j,char in en... | [
"0.6697791",
"0.6425697",
"0.6267778",
"0.60752165",
"0.6063262",
"0.6061974",
"0.5948842",
"0.5867118",
"0.5839898",
"0.5778474",
"0.57653004",
"0.56806886",
"0.5678753",
"0.56717163",
"0.56614995",
"0.5646917",
"0.5627825",
"0.56230605",
"0.561317",
"0.56094795",
"0.5598929... | 0.7201921 | 0 |
Create a list of available symmetries | def list_syms():
SymStringVec=[];
SymStringVec.append("CSYM");
SymStringVec.append("DSYM");
SymStringVec.append("TET_SYM");
SymStringVec.append("OCT_SYM");
SymStringVec.append("ICOS_SYM");
SymStringVec.append("ISYM");
return SymStringVec | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_symmetries(self):\n temp = self._properties.get('symmetries', [])\n return temp",
"def __set_symbol_dict(self):\r\n return {0: list(alph) if self.is_case_snstv else list(alph)[:26],\r\n 1: list(dgt),\r\n 2: list(spcl) if self.is_spcl else []}",
"def z2... | [
"0.7745224",
"0.669557",
"0.6515156",
"0.63807356",
"0.63562876",
"0.6307514",
"0.6297486",
"0.6230556",
"0.61550385",
"0.6110371",
"0.60140777",
"0.600392",
"0.58965176",
"0.5893767",
"0.5836222",
"0.58326477",
"0.5825521",
"0.5808387",
"0.57900697",
"0.5775794",
"0.57617795... | 0.69593567 | 1 |
Create a centered square (or cube) with edge length of d. | def model_square(d, nx, ny, nz=1):
e = EMData()
e.set_size(nx, ny, nz)
e.process_inplace("testimage.squarecube", {"edge_length":d, "fill":1})
return e | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_square(d):asaasasassssssssssssssssssssssssss\n\t return (d ** 3)",
"def initialize_d(d, square_sides, offset=0):\n return {key:[] for key in range(offset, square_sides ** 2 + offset)}",
"def square_diamond(sx, sy, size, strong):\n if size == 1:\n return\n\n dsize ... | [
"0.5763527",
"0.5631988",
"0.55919534",
"0.5325949",
"0.52789533",
"0.52779573",
"0.5240144",
"0.5220922",
"0.5193584",
"0.5174843",
"0.5162735",
"0.5129172",
"0.5129167",
"0.51191884",
"0.5118387",
"0.51183224",
"0.50997084",
"0.50534856",
"0.50478446",
"0.50203365",
"0.4996... | 0.63994324 | 0 |
Parse a Spider filename string and insert parameters. | def parse_spider_fname(mystr, *fieldvals):
# helper functions and classes
def rm_stack_char(mystr):
"Helper function to remove a stack character if it exists"
stackloc = mystr.find("@")
if stackloc != -1:
# there's an '@' somewhere
if len(mystr) - 1 == stackloc:
# It's at the end of the string
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_filename(cls, filename):\n words = filename.split('_')\n return words[0], int(words[1][1:]), int(words[2])",
"def parseFileName(filename):\n entry = DataEntry(\"\",0,{},{},0,0)\n wordArray = filename.split(\".\")\n entry.publication_name = wordArray[1]\n entry.year = wordArray... | [
"0.5459443",
"0.5448573",
"0.5429191",
"0.52798533",
"0.5271916",
"0.5247543",
"0.52416116",
"0.5215298",
"0.51574737",
"0.5120585",
"0.5072528",
"0.5036985",
"0.5022814",
"0.4980182",
"0.49415386",
"0.4940157",
"0.49290508",
"0.49222475",
"0.49006563",
"0.48977634",
"0.48940... | 0.5895396 | 0 |
Print the data in slice iz, row ix of an image to standard out. | def print_row(input, ix=0, iz=0):
image=get_image(input)
nx = image.get_xsize()
ny = image.get_ysize()
nz = image.get_zsize()
print "(z = %d slice, x = %d row)" % (iz, ix)
line = []
for iy in xrange(ny):
line.append("%12.5g " % (image.get_value_at(ix,iy,iz)))
if ((iy + 1) % 5 == 0): line.append("\n ")
li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_image_row(input, iy=0, iz=0):\n\timage=get_image(input)\n\tnx = image.get_xsize()\n\tny = image.get_ysize()\n\tnz = image.get_zsize()\n\tprint \"(z = %d slice, y = %d col)\" % (iz, iy)\n\tline = []\n\tfor ix in xrange(nx):\n\t\tline.append(\"%12.5g \" % (image.get_value_at(ix,iy,iz)))\n\t\tif ((ix + 1) ... | [
"0.75990057",
"0.7544907",
"0.74450433",
"0.73937047",
"0.7349031",
"0.7347187",
"0.7033798",
"0.68403655",
"0.6811467",
"0.66571254",
"0.6630757",
"0.6279358",
"0.6275334",
"0.61232245",
"0.60401046",
"0.5973948",
"0.5973784",
"0.5965042",
"0.59583265",
"0.59162855",
"0.5894... | 0.76172984 | 0 |
Print the data in slice iz, column iy of an image to standard out. | def print_col(input, iy=0, iz=0):
image=get_image(input)
nx = image.get_xsize()
ny = image.get_ysize()
nz = image.get_zsize()
print "(z = %d slice, y = %d col)" % (iz, iy)
line = []
for ix in xrange(nx):
line.append("%12.5g " % (image.get_value_at(ix,iy,iz)))
if ((ix + 1) % 5 == 0): line.append("\n ")
li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_image_col(input, ix=0, iz=0):\n\timage=get_image(input)\n\tnx = image.get_xsize()\n\tny = image.get_ysize()\n\tnz = image.get_zsize()\n\tprint \"(z = %d slice, x = %d row)\" % (iz, ix)\n\tline = []\n\tfor iy in xrange(ny):\n\t\tline.append(\"%12.5g \" % (image.get_value_at(ix,iy,iz)))\n\t\tif ((iy + 1) ... | [
"0.77487314",
"0.750461",
"0.7496404",
"0.73919225",
"0.7150529",
"0.7141496",
"0.7027633",
"0.6667874",
"0.66633767",
"0.6654244",
"0.6348636",
"0.621092",
"0.6179944",
"0.60063565",
"0.59464717",
"0.59386533",
"0.5911687",
"0.58938134",
"0.5851181",
"0.58338124",
"0.5803081... | 0.75519806 | 1 |
Print the data in slice iz of an image to standard out. | def print_slice(input, iz=0):
image=get_image(input)
nx = image.get_xsize()
ny = image.get_ysize()
nz = image.get_zsize()
print "(z = %d slice)" % (iz)
line = []
for iy in xrange(ny):
line.append("Row ")
line.append("%4i " % iy)
for ix in xrange(nx):
line.append("%12.5g " % (image.get_value_at(ix,iy,iz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_image_slice(input, iz=0):\n\timage=get_image(input)\n\tnx = image.get_xsize()\n\tny = image.get_ysize()\n\tnz = image.get_zsize()\n\tprint \"(z = %d slice)\" % (iz)\n\tline = []\n\tfor iy in xrange(ny-1,-1,-1):\n\t\tline.append(\"Row \")\n\t\tline.append(\"%4i \" % iy)\n\t\tfor ix in xrange(nx):\n\t\t\tl... | [
"0.7832976",
"0.7438628",
"0.72238773",
"0.70643157",
"0.70205015",
"0.6971101",
"0.659192",
"0.65685576",
"0.6525086",
"0.64007616",
"0.6349104",
"0.6105353",
"0.6058925",
"0.6016299",
"0.60077834",
"0.59170806",
"0.5827092",
"0.5820637",
"0.5805464",
"0.58032835",
"0.574112... | 0.7674774 | 1 |
Print the data in slice iz of an image to standard out in a format that agrees with v2 | def print_image_slice(input, iz=0):
image=get_image(input)
nx = image.get_xsize()
ny = image.get_ysize()
nz = image.get_zsize()
print "(z = %d slice)" % (iz)
line = []
for iy in xrange(ny-1,-1,-1):
line.append("Row ")
line.append("%4i " % iy)
for ix in xrange(nx):
line.append("%12.5g " % (image.get_val... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_image(input):\n\timage=get_image(input)\n\tnz = image.get_zsize()\n\tfor iz in xrange(nz): print_slice(input, iz)",
"def print_slice(input, iz=0):\n\timage=get_image(input)\n\tnx = image.get_xsize()\n\tny = image.get_ysize()\n\tnz = image.get_zsize()\n\tprint \"(z = %d slice)\" % (iz)\n\tline = []\n\tf... | [
"0.7314874",
"0.72975045",
"0.7103524",
"0.7012286",
"0.6931774",
"0.67332554",
"0.6709795",
"0.6601998",
"0.6534724",
"0.6502416",
"0.6426161",
"0.6281741",
"0.6222216",
"0.6221346",
"0.6040175",
"0.60378903",
"0.59890413",
"0.594744",
"0.5930997",
"0.5928868",
"0.5903941",
... | 0.7488905 | 0 |
Read data from text file, if ncol = 1, read all columns if ncol >= 0, just read the (ncol+1)th column. | def read_text_file(file_name, ncol = 0):
from string import split
inf = file(file_name, "r")
line = inf.readline()
data = []
while len(line) > 0:
if ncol == -1:
vdata = split(line)
if data == []:
for i in xrange(len(vdata)):
data.append([float(vdata[i])])
else:
for i in xrange(len(vdata))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readOFColumnData(dataFile,nCol):\n fileCheck(dataFile) # does the file exists ? Stop if not.\n #\n # Init list\n data = []\n #\n for line in fileinput.input(dataFile):\n # remove parenthesis if any\n line = line.replace('(', '')\n line = line.replace(')', '') \n ... | [
"0.69048285",
"0.6310644",
"0.6242134",
"0.61760336",
"0.6040689",
"0.60290545",
"0.6026688",
"0.60042155",
"0.587215",
"0.58236593",
"0.5762683",
"0.5731496",
"0.5718888",
"0.5706086",
"0.5696076",
"0.5676739",
"0.56515324",
"0.56390595",
"0.56192374",
"0.55811644",
"0.55722... | 0.73864484 | 0 |
linearly interpolate a 1D power spectrum to required length with required Pixel size input_object a 1D list with a 1D curve to be interpolated length_current half size of the image size (in case of power spectrum, it can be different from the length of the input_object) length_interpolated length of the interpolated 1D... | def reshape_1d(input_object, length_current=0, length_interpolated=0, Pixel_size_current = 0., Pixel_size_interpolated = 0.):
interpolated = []
if length_current == 0: length_current = len(input_object)
lt = len(input_object) - 2
if length_interpolated == 0:
if( Pixel_size_interpolated != Pixel_size_current):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolate(signal, new_length):\n assert len(signal) > 1 and len(signal[0]) > 1\n current_length = len(signal)\n signal = np.array(signal).T\n new_signal = []\n x_array = get_x_array(current_length, new_length)\n\n for l in range(len(signal)):\n fp = signal[l]\n xp = list(range... | [
"0.59042335",
"0.5510684",
"0.5495997",
"0.543274",
"0.54308456",
"0.5368978",
"0.53469396",
"0.5295205",
"0.5252446",
"0.5242712",
"0.51369417",
"0.5123754",
"0.5104273",
"0.5101531",
"0.5047771",
"0.50370836",
"0.5025036",
"0.50159943",
"0.49947384",
"0.49876678",
"0.497830... | 0.6795765 | 0 |
Gather the a list of EMData on all nodes to the main node, we assume the list has the same length on each node. | def gather_EMData(data, number_of_proc, myid, main_node):
from mpi import MPI_COMM_WORLD, MPI_INT, MPI_TAG_UB
from mpi import mpi_send, mpi_recv
l = len(data)
gathered_data = []
inc = 1 # A temp measure
if myid == main_node:
for i in xrange(0, number_of_proc*inc, inc):
if i == main_node:
for k in xra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather(self, node):\n\n return []",
"def _data_parallel_master(self, intermediates):\n\n # Always using same \"device order\" makes the ReduceAdd operation faster.\n # Thanks to:: Tete Xiao (http://tetexiao.com/)\n intermediates = sorted(intermediates, key=lambda i: i[1].sum.get_d... | [
"0.6460555",
"0.5887683",
"0.56105876",
"0.56016797",
"0.5551757",
"0.5506774",
"0.5503824",
"0.5480824",
"0.54083604",
"0.5394268",
"0.5391553",
"0.53643715",
"0.5339283",
"0.5328205",
"0.5325319",
"0.5300631",
"0.52970463",
"0.52842844",
"0.52776074",
"0.526741",
"0.5261743... | 0.67186177 | 0 |
write headers from files in data into a disk file called filename. The filename has to be either hdf or bdb. lima list with positions in the disk files into which headers will be written, i.e., header from data[k] will be written into file number lima[k] | def write_headers(filename, data, lima):
from utilities import file_type
from EMAN2db import db_open_dict
ftp = file_type(filename)
if ftp == "bdb":
# For unknown reasons this does not work on Linux, but works on Mac ??? Really?
DB = db_open_dict(filename)
for i in range(len(lima)):
DB.set_header(lima[i]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_header(filename, data, lima):\n\tfrom utilities import file_type\n\tfrom EMAN2db import db_open_dict\n\n\tftp = file_type(filename)\n\tif ftp == \"bdb\":\n\t\tDB = db_open_dict(filename)\n\t\tDB.set_header(lima, data)\n\telif ftp == \"hdf\":\n\t\tdata.write_image(filename, lima, EMUtil.ImageType.IMAGE_HD... | [
"0.81443864",
"0.65365857",
"0.6521095",
"0.642603",
"0.6422746",
"0.6345552",
"0.63141286",
"0.622469",
"0.6156558",
"0.6150772",
"0.6104141",
"0.60294604",
"0.5993755",
"0.5916143",
"0.58797914",
"0.58024967",
"0.57776046",
"0.57631105",
"0.5731549",
"0.57286596",
"0.571765... | 0.8396805 | 0 |
write header from a single file data into a disk file called filename. The filename has to be either hdf or bdb. lima position in the disk files into which header will be written, i.e., header from data will be written into file number lima | def write_header(filename, data, lima):
from utilities import file_type
from EMAN2db import db_open_dict
ftp = file_type(filename)
if ftp == "bdb":
DB = db_open_dict(filename)
DB.set_header(lima, data)
elif ftp == "hdf":
data.write_image(filename, lima, EMUtil.ImageType.IMAGE_HDF, True)
else:
ERROR("Unac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_headers(filename, data, lima):\n\tfrom utilities import file_type\n\tfrom EMAN2db import db_open_dict\n\n\tftp = file_type(filename)\n\tif ftp == \"bdb\":\n\t\t# For unknown reasons this does not work on Linux, but works on Mac ??? Really?\n\t\tDB = db_open_dict(filename)\n\t\tfor i in range(len(lima)):... | [
"0.7826132",
"0.70860624",
"0.6762291",
"0.6738056",
"0.67234135",
"0.67085034",
"0.66346943",
"0.6610399",
"0.6607992",
"0.6557405",
"0.6481333",
"0.6448737",
"0.64438635",
"0.6427536",
"0.64213383",
"0.6419421",
"0.6363067",
"0.63381046",
"0.631573",
"0.63024944",
"0.629878... | 0.8375335 | 0 |
retrieve 3D alignment parameters from the header phi theta psi tx ty tz mirror scale | def get_params3D(ima, xform = "xform.align3d"):
t = ima.get_attr(xform)
d = t.get_params("spider")
return d["phi"],d["theta"],d["psi"],d["tx"],d["ty"],d["tz"],d["mirror"],d["scale"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_3D_2D(phi, theta, psi, s2x, s2y):\n\tif theta > 90.0:\n\t\tmirror = 1\n\t\talpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 540.0-psi, 0, 0, 1.0)\n\telse:\n\t\tmirror = 0\n\t\talpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 360.0-psi, 0, 0, 1.0)\n\treturn alpha, sx, sy, mirror"... | [
"0.6369768",
"0.63076174",
"0.57975394",
"0.5729281",
"0.5533436",
"0.551851",
"0.5500369",
"0.5439547",
"0.5422399",
"0.54033196",
"0.5388639",
"0.5361121",
"0.53491545",
"0.53419423",
"0.531873",
"0.53108954",
"0.53095436",
"0.53085315",
"0.5303664",
"0.5303664",
"0.5302264... | 0.7157893 | 0 |
set 3D alignment parameters in the header phi theta psi tx ty tz mirror scale | def set_params3D(ima, p, xform = "xform.align3d"):
t = Transform({"type":"spider","phi":p[0],"theta":p[1],"psi":p[2],"tx":p[3],"ty":p[4],"tz":p[5],"mirror":p[6],"scale":p[7]})
ima.set_attr(xform, t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_params3D(ima, xform = \"xform.align3d\"):\n\tt = ima.get_attr(xform)\n\td = t.get_params(\"spider\")\n\treturn d[\"phi\"],d[\"theta\"],d[\"psi\"],d[\"tx\"],d[\"ty\"],d[\"tz\"],d[\"mirror\"],d[\"scale\"]",
"def setCameraRotation3D(ang):\n dislin.vup3d(ang)",
"def params_3D_2D(phi, theta, psi, s2x, s... | [
"0.59650105",
"0.593235",
"0.5929709",
"0.58860916",
"0.5739548",
"0.5691223",
"0.56045157",
"0.5573526",
"0.55701107",
"0.5569729",
"0.55564326",
"0.55041516",
"0.5470599",
"0.5299311",
"0.5288693",
"0.5281004",
"0.5277822",
"0.52361757",
"0.5231874",
"0.5215359",
"0.5197185... | 0.65861595 | 0 |
retrieve projection alignment parameters from the header phi theta psi s2x s2y | def get_params_proj(ima, xform = "xform.projection"):
t = ima.get_attr(xform)
d = t.get_params("spider")
return d["phi"],d["theta"],d["psi"],-d["tx"],-d["ty"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_3D_2D(phi, theta, psi, s2x, s2y):\n\tif theta > 90.0:\n\t\tmirror = 1\n\t\talpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 540.0-psi, 0, 0, 1.0)\n\telse:\n\t\tmirror = 0\n\t\talpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 360.0-psi, 0, 0, 1.0)\n\treturn alpha, sx, sy, mirror"... | [
"0.61034876",
"0.60535675",
"0.6002323",
"0.55047",
"0.53491384",
"0.53456676",
"0.5342712",
"0.5333783",
"0.5266437",
"0.52358764",
"0.52249706",
"0.5206061",
"0.5192297",
"0.51854604",
"0.5182782",
"0.51370823",
"0.51352656",
"0.512739",
"0.5105829",
"0.50973487",
"0.508592... | 0.6081615 | 1 |
set projection alignment parameters in the header phi theta psi s2x s2y | def set_params_proj(ima, p, xform = "xform.projection"):
from EMAN2 import Vec2f
t = Transform({"type":"spider","phi":p[0],"theta":p[1],"psi":p[2]})
t.set_trans(Vec2f(-p[3], -p[4]))
ima.set_attr(xform, t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_3D_2D(phi, theta, psi, s2x, s2y):\n\tif theta > 90.0:\n\t\tmirror = 1\n\t\talpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 540.0-psi, 0, 0, 1.0)\n\telse:\n\t\tmirror = 0\n\t\talpha, sx, sy, scalen = compose_transform2(0, s2x, s2y, 1.0, 360.0-psi, 0, 0, 1.0)\n\treturn alpha, sx, sy, mirror"... | [
"0.59060866",
"0.5602356",
"0.54695225",
"0.531587",
"0.5250702",
"0.51489925",
"0.512252",
"0.51054573",
"0.50826424",
"0.50823313",
"0.50728947",
"0.5068519",
"0.5064257",
"0.50619185",
"0.504671",
"0.5043761",
"0.5035546",
"0.5006031",
"0.49904823",
"0.49792513",
"0.496036... | 0.5937973 | 0 |
recover numerical values of CTF parameters from EMAN2 CTF object stored in a header of the input image | def get_ctf(ima):
from EMAN2 import EMAN2Ctf
ctf_params = ima.get_attr("ctf")
return ctf_params.defocus, ctf_params.cs, ctf_params.voltage, ctf_params.apix, ctf_params.bfactor, ctf_params.ampcont, ctf_params.dfdiff, ctf_params.dfang | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_aperture_coeffs_in_header(head):\n\n coeffs = {}\n for key, value in head.items():\n exp = '^GAMSE TRACE CHANNEL [A-Z] APERTURE \\d+ COEFF \\d+$'\n if re.match(exp, key) is not None:\n g = key.split()\n channel = g[3]\n aperture = int(g[5])\n ... | [
"0.56780773",
"0.56284475",
"0.55668586",
"0.5510405",
"0.5448828",
"0.5425909",
"0.5414353",
"0.54138607",
"0.541011",
"0.54011285",
"0.5374928",
"0.5361909",
"0.5342145",
"0.533246",
"0.5314134",
"0.5313142",
"0.525259",
"0.52504194",
"0.5208928",
"0.520613",
"0.5202701",
... | 0.60774076 | 0 |
generate EMAN2 CTF object using values of CTF parameters given in the list p | def generate_ctf(p):
from EMAN2 import EMAN2Ctf
defocus = p[0]
cs = p[1]
voltage = p[2]
pixel_size = p[3]
bfactor = p[4]
amp_contrast = p[5]
if defocus > 100: # which means it is very likely in Angstrom, therefore we are using the old convention
defocus *= 1e-4
if amp_contrast < 1.0:
from math import... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_thermo(T_C, p):\n\ty = y_from_p(p)\n\tx = x_from_Tp(T_C+C_to_K, p)\n\treturn x, y",
"def construct_param_dict(params,K_RC,K_CP,m_P):\n ###scaling constants\n w=params['w']\n pd=params['pd'] # in 3D and 0.21 in 2D\n pv=params['pv']\n Er=params['Er'] ;Ek=params['Ek']\n ER=params['ER'];EC... | [
"0.5515874",
"0.5445426",
"0.5421652",
"0.54088384",
"0.5321685",
"0.5316981",
"0.5300015",
"0.52771187",
"0.52574724",
"0.5255685",
"0.52163506",
"0.5180207",
"0.5175576",
"0.51701",
"0.5159775",
"0.51574296",
"0.51267034",
"0.51238847",
"0.5120029",
"0.5111619",
"0.5101273"... | 0.77108574 | 0 |
set EMAN2 CTF object in the header of input image using values of CTF parameters given in the list p | def set_ctf(ima, p):
from utilities import generate_ctf
ctf = generate_ctf( p )
ima.set_attr( "ctf", ctf ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_ctf(p):\n\tfrom EMAN2 import EMAN2Ctf\n\n\tdefocus = p[0]\n\tcs = p[1]\n\tvoltage = p[2]\n\tpixel_size = p[3]\n\tbfactor = p[4]\n\tamp_contrast = p[5]\n\t\n\tif defocus > 100: # which means it is very likely in Angstrom, therefore we are using the old convention\n\t\tdefocus *= 1e-4\n\t\n\tif amp_con... | [
"0.6119822",
"0.52715033",
"0.52555937",
"0.521904",
"0.5153852",
"0.5145439",
"0.50969875",
"0.5046172",
"0.5035334",
"0.5006989",
"0.49636608",
"0.49189067",
"0.49184573",
"0.4891116",
"0.4880313",
"0.4876546",
"0.48572096",
"0.4852319",
"0.48459044",
"0.4828242",
"0.482119... | 0.60989493 | 1 |
Find all occurences of val on list lo Returns a list of indices of val on lo. | def findall(lo,val):
u = []
i = -1
while( i < len(lo)-1):
try:
i = lo.index(val,i+1)
u.append(i)
except:
i += 1
return u | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findall(l, o):\n return [i for i, u in enumerate(l) if u==o]",
"def getIndexes(self, val):\n # Find where this value is listed. \n valNdx = (self.values == val).nonzero()[0]\n \n # If this value is not actually in those listed, then we \n # must return empty indexes\n ... | [
"0.70793176",
"0.7071109",
"0.66156113",
"0.6319743",
"0.6250533",
"0.620535",
"0.62024206",
"0.619781",
"0.6169729",
"0.60985184",
"0.6077737",
"0.6067603",
"0.5907215",
"0.5842827",
"0.58379203",
"0.5817054",
"0.58101517",
"0.5786621",
"0.577902",
"0.5734879",
"0.5654707",
... | 0.8087934 | 0 |
Find overall 3D rotation (phi theta psi) between two sets of Eulerian angles. The two sets have to be of the same length and it is assume that k'th element on the first list corresponds to the k'th element on the second list. | def rotation_between_anglesets(agls1, agls2):
from math import sin, cos, pi, sqrt, atan2, acos, atan
from numpy import array, linalg, matrix
import types
deg2rad = pi/180.0
def ori2xyz(ori):
if(type(ori) == types.ListType):
phi, theta, psi = ori[:3]
else:
# it has to be Transformation object
d = or... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_rotation(a, b):\n a.shape = (3,)\n b.shape = (3,)\n\n a /= np.linalg.norm(a)\n b /= np.linalg.norm(b)\n \n v = np.cross(a, b)\n \n angle_AB = -1*vector_angle(a, b) \n \n print(angle_AB)\n s = np.linalg.norm(v) * np.sin(angle_AB)\n \n c = np.dot(a, b) * np.cos(angle_A... | [
"0.61534816",
"0.6057964",
"0.6041564",
"0.6022013",
"0.5908641",
"0.5882892",
"0.5800431",
"0.57707256",
"0.5706791",
"0.56642485",
"0.56599987",
"0.5649005",
"0.5628651",
"0.5623927",
"0.56015086",
"0.5588204",
"0.55626535",
"0.5548194",
"0.55238026",
"0.5522772",
"0.551259... | 0.7362805 | 0 |
Retrieve pixel size from the header. We check attribute Pixel_size and also pixel size from ctf object, if exisits. If the two are different or if the pixel size is not set, return 1.0 and print a warning. | def get_pixel_size(img):
p1 = img.get_attr_default("apix_x", -1.0)
cc = img.get_attr_default("ctf", None)
if cc == None:
p2 = -1.0
else:
p2 = round(cc.apix, 3)
if p1 == -1.0 and p2 == -1.0:
ERROR("Pixel size not set", "get_pixel_size", 0)
return -1.0
elif p1 > -1.0 and p2 > -1.0:
if abs(p1-p2) >= 0.001:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pixelsize(self):\n if hasattr(self, \"_pixelsize\"):\n return self._pixelsize\n\n try:\n return self.header[\"PixSize\"] # [arcsec]\n except KeyError:\n try:\n return abs(self.header[\"CDELT1\"]) * 3600 # [deg] -> [arcsec]\n exce... | [
"0.72802687",
"0.68242306",
"0.68130434",
"0.677174",
"0.6668118",
"0.6537701",
"0.6535796",
"0.6514242",
"0.6482996",
"0.64115053",
"0.63932556",
"0.6321486",
"0.6316444",
"0.6295255",
"0.62676024",
"0.62676024",
"0.62564975",
"0.6233684",
"0.6221311",
"0.6203486",
"0.61531"... | 0.69274837 | 1 |
For the given grouping, convert ROOT files into DataFrames merging groups together. Return a dictionary mapping file names to DataFrames. | def process_group(directory: str, files: dict, channel: str, year: str) -> dict:
if len(files) == 0:
raise Exception('empty file list for directory {}'.format(directory)) + 1
dataframes = {}
for name, ifile in files.items():
# equivalent of hadding
update_dfs = uproot.pandas.iterate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_processed_data(self, group_directory):\n processed_dir = [x for x in group_directory.iterdir()\n if x.is_dir() and 'processed' in x.name][0]\n\n task_dirs = [x for x in processed_dir.iterdir()\n if x.is_dir() and 'task' in x.name]\n\n files =... | [
"0.6541141",
"0.60830426",
"0.6062187",
"0.59850407",
"0.5894021",
"0.5629577",
"0.56196886",
"0.5457541",
"0.5436698",
"0.5417699",
"0.5383131",
"0.53697276",
"0.5362166",
"0.5328199",
"0.5324665",
"0.5262586",
"0.52602506",
"0.5259905",
"0.52521104",
"0.5234652",
"0.5222199... | 0.64353156 | 1 |
Guess an appropriate chunk layout for an array, given its shape and the size of each element in bytes. Will allocate chunks only as large as MAX_SIZE. Chunks are generally close to some powerof2 fraction of each axis, slightly favoring bigger values for the last index. Undocumented and subject to change without warning... | def guess_chunks(shape: Tuple[int, ...], typesize: int) -> Tuple[int, ...]:
ndims = len(shape)
# require chunks to have non-zero length for all dimensions
chunks = np.maximum(np.array(shape, dtype="=f8"), 1)
# Determine the optimal chunk size in bytes using a PyTables expression.
# This is kept as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_chunk(chunk, sizes, max_iter=1000, rng=None):\n assert len(chunk) == sum(sizes), f\"{len(chunk)} != {sum(sizes)}\"\n if not isinstance(rng, random.Random):\n rng = random\n # Precompute neighbors for each cube in the chunk\n neighbors = dict()\n for c in chunk:\n neighbors[c]... | [
"0.644044",
"0.629798",
"0.61731964",
"0.60461324",
"0.598301",
"0.5948597",
"0.59229267",
"0.5806321",
"0.57971877",
"0.5785244",
"0.57549477",
"0.56843406",
"0.5641695",
"0.5637497",
"0.56076527",
"0.5582129",
"0.55698544",
"0.556121",
"0.55578834",
"0.5544379",
"0.5536151"... | 0.7806975 | 0 |
Convenience function to normalize the `chunks` argument for an array with the given `shape`. | def normalize_chunks(chunks: Any, shape: Tuple[int, ...], typesize: int) -> Tuple[int, ...]:
# N.B., expect shape already normalized
# handle auto-chunking
if chunks is None or chunks is True:
return guess_chunks(shape, typesize)
# handle no chunking
if chunks is False:
return sha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _normalize_shape(shape):\n\n if isinstance(shape, (np.integer, int)):\n if shape < 1:\n raise ValueError(\"shape value must be greater than 0: %d\"\n % shape)\n shape = (shape,) # N is a shorthand for (N,)\n try:\n shape = tuple(shape)\n exc... | [
"0.61362606",
"0.60389656",
"0.58118457",
"0.5734301",
"0.5696832",
"0.5670947",
"0.5670829",
"0.5670006",
"0.56443065",
"0.5637183",
"0.56079644",
"0.55675006",
"0.5559034",
"0.55089456",
"0.5506106",
"0.5494193",
"0.54827696",
"0.5472908",
"0.54428035",
"0.54304826",
"0.542... | 0.7882431 | 0 |
Determine whether `item` specifies a complete slice of array with the given `shape`. Used to optimize __setitem__ operations on the Chunk class. | def is_total_slice(item, shape: Tuple[int]) -> bool:
# N.B., assume shape is normalized
if item == Ellipsis:
return True
if item == slice(None):
return True
if isinstance(item, slice):
item = (item,)
if isinstance(item, tuple):
return all(
(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self, item):\n if len(item) != len(self.sizes):\n raise ValueError('Point dimension does not match grid dimension')\n for i in range(len(self.sizes)):\n if not 1 <= item[i] < self.sizes[i] - 1:\n return False\n return True",
"def roi_is_f... | [
"0.5930391",
"0.5894886",
"0.5701367",
"0.56653273",
"0.5539224",
"0.54814374",
"0.54136163",
"0.54108244",
"0.5387186",
"0.5382678",
"0.5344155",
"0.5341929",
"0.53009504",
"0.5299111",
"0.52924687",
"0.5279965",
"0.52784073",
"0.52331346",
"0.5224626",
"0.51978904",
"0.5183... | 0.780188 | 0 |
Test if all the elements of an array are equivalent to a value. If `value` is None, then this function does not do any comparison and returns False. | def all_equal(value: Any, array: Any):
if value is None:
return False
if not value:
# if `value` is falsey, then just 1 truthy value in `array`
# is sufficient to return False. We assume here that np.any is
# optimized to return on the first truthy value in `array`.
try:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_equal(array):\n if not array:\n raise ValueError(\"Array is empty\")\n\n first_item = array[0]\n\n if any(item != first_item for item in array):\n return False\n\n return True",
"def has_equal_values_vec(x):\n return jnp.all(x == x[0])",
"def check_array(self, array: ArrayD... | [
"0.6699362",
"0.6486526",
"0.6385027",
"0.6280364",
"0.61277896",
"0.612132",
"0.6043027",
"0.60365415",
"0.5891498",
"0.5891476",
"0.5875021",
"0.5753058",
"0.5749066",
"0.57388574",
"0.5702565",
"0.56945324",
"0.5661426",
"0.56569785",
"0.56512713",
"0.56494707",
"0.5626120... | 0.7799601 | 0 |
Convenience function to coerce `buf` to ndarraylike array or bytes. First check if `buf` can be zerocopy converted to a contiguous array. If not, `buf` will be copied to a newly allocated `bytes` object. | def ensure_contiguous_ndarray_or_bytes(buf) -> Union[NDArrayLike, bytes]:
try:
return ensure_contiguous_ndarray_like(buf)
except TypeError:
# An error is raised if `buf` couldn't be zero-copy converted
return ensure_bytes(buf) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buffer_to_bytes(buf):\n if not isinstance(buf, bytes):\n buf = bytes(buf)\n return buf",
"def test_array_as_buffer(parser):\n doc = parser.parse(b'''{\n \"d\": [1.2, 2.3, 3.4],\n \"i\": [-1, 2, -3, 4],\n \"u\": [1, 2, 3, 4, 5],\n \"x\": [1, 2, 3, \"not valid\"]\n ... | [
"0.6886174",
"0.6035865",
"0.5953554",
"0.55916303",
"0.5561849",
"0.54923177",
"0.5430941",
"0.53742135",
"0.51953775",
"0.5164276",
"0.51263016",
"0.5078041",
"0.507584",
"0.5072293",
"0.50700045",
"0.5063474",
"0.50496",
"0.5039605",
"0.5037979",
"0.50145006",
"0.49787346"... | 0.8558664 | 0 |
Read and preprocess an image with data augmentation (random transform). | def read_for_training(p, augmentation=False):
img = imread(TRAIN + p, mode='RGB')
msk = img
if mode == 'background':
data = {'image': img}
elif mode == 'instance' or mode == 'code':
msk = imread(TRAIN_MASK + p.replace('.jpg', '.png'))
data = {'image': img, 'mask': msk}
if a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(self, img):\n img_ = image.load_img(img, target_size=(299, 299))\n img_ = image.img_to_array(img_)\n img_ = np.expand_dims(img_, axis=0)\n img_ = preprocess_input(img_)\n return img_",
"def data_augmentation(image, aug):\n if (aug == \"random_crop\") and (rand... | [
"0.6944267",
"0.6885695",
"0.6801366",
"0.6746409",
"0.6730426",
"0.6700084",
"0.6674317",
"0.6642256",
"0.6604827",
"0.65799797",
"0.65796673",
"0.6575271",
"0.6572347",
"0.6542871",
"0.6535678",
"0.6521868",
"0.64719284",
"0.64391285",
"0.6430673",
"0.6425564",
"0.6418553",... | 0.70998 | 0 |
Amount which will increase x until it's divisible evenly by 64 | def padlen_64(x: int):
return (64 - (x % 64)) % 64 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modReduce(self, x):\n\n assert 0 <= x < pow(self.mod, 2), 'out of range.'\n q = (x * self.u) >> (2 * self.M_bit)\n r = x - q * self.mod\n while r >= self.mod:\n r -= self.mod\n return r",
"def taille(x):\n n = 0\n \n while (2**n) -1 < x :\n n+=1\n... | [
"0.64682055",
"0.6353813",
"0.63322943",
"0.6308356",
"0.6298304",
"0.62941134",
"0.61767954",
"0.61767954",
"0.61669123",
"0.61343306",
"0.61135375",
"0.60509366",
"0.59431607",
"0.5926209",
"0.5924908",
"0.5908529",
"0.5902806",
"0.5896249",
"0.58734715",
"0.5857224",
"0.58... | 0.6562799 | 0 |
Turns this userreadable string into an Alternative (no escaping) | def from_str(cls, encstr: str) -> 'Alternative':
encstr = re.sub(r'\s+', '', encstr)
return cls(*re.split('([' + string.punctuation + '])', encstr, maxsplit=1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def T(value):\n return (value if isinstance(value, basestring) else\n str(value) if isinstance(value, AltText) else \"\")",
"def decode(cls, encstr: str) -> Tuple['Alternative', str]:\n cond = None\n end_off = 0\n\n # Swallow field up to conditiona\n while end_off < len(encs... | [
"0.5630695",
"0.5217001",
"0.5198397",
"0.5186945",
"0.5184185",
"0.51392734",
"0.51312214",
"0.50683737",
"0.50631917",
"0.5061903",
"0.5048459",
"0.50467837",
"0.50248337",
"0.49875286",
"0.4931769",
"0.49110556",
"0.48986942",
"0.48867592",
"0.48742884",
"0.4862726",
"0.48... | 0.5572365 | 1 |
Pull a Restriction from encoded string, return remainder | def decode(cls, encstr: str) -> Tuple['Restriction', str]:
alts = []
while len(encstr) != 0:
if encstr.startswith('&'):
encstr = encstr[1:]
break
alt, encstr = Alternative.decode(encstr)
alts.append(alt)
return cls(alts), encstr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_str(cls, encstr: str) -> 'Restriction':\n encstr = re.sub(r'\\s+', '', encstr)\n ret, remainder = cls.decode(encstr)\n if len(remainder) != 0:\n raise ValueError(\"Restriction had extrs characters at end: {}\"\n .format(remainder))\n retur... | [
"0.6682689",
"0.5536616",
"0.54848987",
"0.5409332",
"0.5409332",
"0.5249636",
"0.52139443",
"0.51220363",
"0.5092601",
"0.5083486",
"0.50243723",
"0.49601397",
"0.4911395",
"0.48801553",
"0.48710787",
"0.48674506",
"0.48674506",
"0.48620152",
"0.4848582",
"0.4832647",
"0.479... | 0.61234236 | 1 |
Returns a Restriction from an escaped string (ignoring whitespace) | def from_str(cls, encstr: str) -> 'Restriction':
encstr = re.sub(r'\s+', '', encstr)
ret, remainder = cls.decode(encstr)
if len(remainder) != 0:
raise ValueError("Restriction had extrs characters at end: {}"
.format(remainder))
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _assign_regex(literal, regex):\n if regex:\n return regex.lower().strip()\n else:\n return r'\\b%s\\b'%literal.lower().strip()",
"def interpret_requirement(string):\n string_list = split(string, sep=' ')\n \n requirement = Requirement(points, degree, majors, levels, max_non_degre... | [
"0.5168612",
"0.5026671",
"0.49126112",
"0.48980483",
"0.4877988",
"0.485538",
"0.48332566",
"0.48306048",
"0.4796996",
"0.47644973",
"0.4762547",
"0.47521722",
"0.4743869",
"0.47309223",
"0.47302634",
"0.4718924",
"0.47140232",
"0.47117367",
"0.4668038",
"0.46525672",
"0.463... | 0.6378927 | 0 |
Tests the restrictions against the values dict given. Normally values are treated strings, but conditions only work if they're actually integers. Returns (True, '') if everything is good. Otherwise, returns (False, reasonstring) | def are_restrictions_met(self, values: Dict[str, Any]) -> Tuple[bool, str]:,
for r in self.restrictions:
reasons = r.test(values)
if reasons is not None:
return False, reasons
return True, '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test(self, values: Dict[str, Any]) -> Optional[str]:\n # This is always True\n if self.cond == '#':\n return None\n\n def why(cond, field, explanation) -> Optional[str]:\n if cond:\n return None\n return '{}: {}'.format(field, explanation)\n\... | [
"0.67283416",
"0.66373456",
"0.63170063",
"0.6068614",
"0.60020655",
"0.5946913",
"0.57890636",
"0.5788082",
"0.57537967",
"0.57021195",
"0.56713057",
"0.5626302",
"0.5622262",
"0.5609995",
"0.5586753",
"0.55860853",
"0.5585117",
"0.5569001",
"0.5539537",
"0.5532167",
"0.5508... | 0.76134247 | 0 |
Allinone check that a runestring is valid, derives from this MasterRune and passes all its conditions against the given dictionary of values or callables | def check_with_reason(self, b64str: str, values: Dict[str, Any]) -> Tuple[bool, str]:
try:
rune = Rune.from_base64(b64str)
except: # noqa: E722
return False, "runestring invalid"
if not self.is_rune_authorized(rune):
return False, "rune authcode invalid"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_with_reason(secret: bytes, b64str: str, values: Dict[str, Any]) -> Tuple[bool, str]:\n return MasterRune(secret).check_with_reason(b64str, values)",
"def test_any_rune(self):\n rule = 'alert (name:\"rune\"; regex:\".{64}\";)'\n\n tests = {\n \"A\"*64: [\"proxying connection ... | [
"0.6080785",
"0.5750079",
"0.5702773",
"0.5655834",
"0.54935133",
"0.5481613",
"0.5304172",
"0.52878016",
"0.5247526",
"0.5234183",
"0.523374",
"0.52119046",
"0.5198196",
"0.51774484",
"0.5176261",
"0.517611",
"0.51729107",
"0.5167192",
"0.51573974",
"0.51418495",
"0.5130349"... | 0.64300054 | 0 |
Convenience function that the b64str runestring is valid, derives from our secret, and passes against these values. If you want to check many runes, it's more efficient to create the MasterRune first then check them, but this is fine if you're only checking one. | def check_with_reason(secret: bytes, b64str: str, values: Dict[str, Any]) -> Tuple[bool, str]:
return MasterRune(secret).check_with_reason(b64str, values) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_with_reason(self, b64str: str, values: Dict[str, Any]) -> Tuple[bool, str]:\n try:\n rune = Rune.from_base64(b64str)\n except: # noqa: E722\n return False, \"runestring invalid\"\n if not self.is_rune_authorized(rune):\n return False, \"rune authcode... | [
"0.67954326",
"0.6076462",
"0.56105393",
"0.55704355",
"0.5488138",
"0.54298264",
"0.5401579",
"0.5401579",
"0.5336335",
"0.5291665",
"0.5288441",
"0.5265383",
"0.522915",
"0.5190011",
"0.51790816",
"0.51719004",
"0.51499397",
"0.51450264",
"0.51145905",
"0.50659394",
"0.5063... | 0.7233146 | 0 |
Parse read and quality strings from a FASTQ file with sequencing reads. | def readFastq(filename):
sequences = []
qualities = []
with open(filename) as fh:
while True:
fh.readline() # skip name line
seq = fh.readline().rstrip() #read base sequence
fh.readline() # skip placeholder line
qual = fh.readline().rstrip() # bas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readFastq(filename):\n\tsequences = []\n\tqualities = []\n\twith open(filename, 'r') as f:\n\t\twhile True: \n\t\t\tf.readline() # skip name line\n\t\t\tseq = f.readline().rstrip()\n\t\t\tf.readline() # skip place holder line \n\t\t\tq = f.readline().rstrip()\n\t\t\tif len(seq) ==0:\n\t\t\t\tbreak \n\t\t\tsequ... | [
"0.72407734",
"0.7033901",
"0.69433504",
"0.67568797",
"0.6737888",
"0.66820616",
"0.65858674",
"0.653524",
"0.652288",
"0.6501695",
"0.6497522",
"0.64846104",
"0.64839154",
"0.646596",
"0.63651484",
"0.63603467",
"0.63447005",
"0.6319669",
"0.63027084",
"0.6278591",
"0.62545... | 0.74991745 | 0 |
Create a hash map between kmers and readings. | def kmerHashMap(reads, k):
kmers_dict = {}
# loop through all reads
for i in range(len(reads)):
# loop read's bases, except for the last k, to obtain its kmers
for j in range(1+len(reads[i])-k):
kmer = reads[i][j:k+j]
if kmers_dict.has_key(kmer):
kmers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_kmers_observed(read, k):\n counts = {}\n num_kmers = len(read) - k + 1\n for i in range (num_kmers):\n kmer= read[i:i+k]\n if kmer not in counts:\n counts[kmer] = 0\n counts[kmer] +=1\n return len(counts)",
"def count_kmers_possible(read, k):\n num_kmers = {}\n num_kmers1 ... | [
"0.59770435",
"0.5825306",
"0.5625832",
"0.5522428",
"0.5472376",
"0.5450063",
"0.54420954",
"0.5432603",
"0.5386902",
"0.5372055",
"0.5325172",
"0.5304393",
"0.53000337",
"0.5292728",
"0.5285071",
"0.5272437",
"0.52629334",
"0.5260887",
"0.5257762",
"0.5255245",
"0.5242287",... | 0.7121498 | 0 |
Calculate the squared L2 norm of the pattern. | def l2_norm(pattern):
return np.linalg.norm(pattern) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def L2_norm(self):\n analyticals = self.analytical(self.x_values, self.C, self.D)\n error = analyticals - self.numerical\n self.L2 = np.sqrt((1/self.gp)*np.sum(error**2))",
"def L2norm(m):\n return np.sqrt(np.sum(m**2))",
"def squared_norm(self) -> float:\n return self.__real**2 ... | [
"0.7689054",
"0.7469105",
"0.7411847",
"0.7393104",
"0.73873013",
"0.73019034",
"0.7256206",
"0.72420824",
"0.71961755",
"0.7140405",
"0.71325195",
"0.71182483",
"0.71150076",
"0.7069896",
"0.7034822",
"0.7023806",
"0.7019462",
"0.69990593",
"0.69920164",
"0.69680566",
"0.695... | 0.8329601 | 0 |
Calculate the l2 norm of a stack of patterns. | def l2_norm_batch(pattern_stack):
return np.linalg.norm(pattern_stack, axis=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def l2_norm(pattern):\n return np.linalg.norm(pattern)",
"def l2(weights):\n\treturn np.sqrt(np.sum(weights * weights))",
"def l2_norm(params):\n flattened, _ = flatten(params)\n return np.dot(flattened, flattened)",
"def L2norm(m):\n return np.sqrt(np.sum(m**2))",
"def L2_norm(self):\n ... | [
"0.74098885",
"0.6808609",
"0.67808706",
"0.67259216",
"0.65520793",
"0.65451896",
"0.6460118",
"0.64029825",
"0.6392266",
"0.62797666",
"0.627647",
"0.626877",
"0.62292206",
"0.6221982",
"0.6214867",
"0.62103754",
"0.61965305",
"0.61522037",
"0.6128999",
"0.6110056",
"0.6074... | 0.83394605 | 0 |
Calculate the inner product of the two patterns as a vecter. | def inner_product(pattern_one, pattern_two):
return np.sum(np.multiply(pattern_one, pattern_two)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inner_product_batch(pattern_stack_one, pattern_num_one, pattern_stack_two, pattern_num_two):\n\n \"\"\"\n Notice that the two stacks can be different. So we can not deduce the lower triangular pattern from the \n other half.\n \"\"\"\n holder = np.zeros((pattern_num_one, pattern_num_two))\n f... | [
"0.6906152",
"0.6847398",
"0.68069786",
"0.67931485",
"0.6750435",
"0.6661231",
"0.665229",
"0.6584153",
"0.6543558",
"0.6477087",
"0.645507",
"0.64223343",
"0.64149445",
"0.64062977",
"0.64052427",
"0.6394551",
"0.6389129",
"0.6387153",
"0.6369647",
"0.6364393",
"0.6364216",... | 0.83498394 | 0 |
Calculate the inner product pair of each pattern in batch one and batch two. Notice that the pattern_stack_one variable represent the pattern along the zero dimension while the pattern_stack_two variable represent patterns along dimension one in the final distance matrix. | def inner_product_batch(pattern_stack_one, pattern_num_one, pattern_stack_two, pattern_num_two):
"""
Notice that the two stacks can be different. So we can not deduce the lower triangular pattern from the
other half.
"""
holder = np.zeros((pattern_num_one, pattern_num_two))
for l in range(patt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inner_product(pattern_one, pattern_two):\n\n return np.sum(np.multiply(pattern_one, pattern_two))",
"def l2_norm_batch(pattern_stack):\n\n return np.linalg.norm(pattern_stack, axis=0)",
"def generate_pattern_grid(words1, words2):\n # Convert word lists to integer arrays\n w1, w2 = (\n np... | [
"0.773317",
"0.5649336",
"0.5526998",
"0.54341394",
"0.53960305",
"0.5378274",
"0.5336186",
"0.5309336",
"0.529776",
"0.5289525",
"0.5283448",
"0.52754015",
"0.52056116",
"0.5135578",
"0.50863296",
"0.5050334",
"0.5024294",
"0.49954486",
"0.4992397",
"0.49735647",
"0.49717188... | 0.87116134 | 0 |
Apply np.exp( matrix/two_sigma_square) elementwise. | def gaussian_dense(matrix, two_sigma_square):
return np.exp(- matrix / two_sigma_square) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exp(tensor):\n return _elementary_op(tensor, np.exp, np.exp)",
"def expval(op, dm):\n return np.tensordot(op, dm, ([0, 1], [0, 1]))",
"def Exp(A, B):\n return A.dot(expm(B))",
"def kernel_sqExp(a,b, ls=1, sv=1):\n a = a.T/ls\n b = b.T/ls\n D, n = np.shape(a)\n d, m = np.shape(b)\n s... | [
"0.60777706",
"0.6070397",
"0.6037772",
"0.60048586",
"0.59793174",
"0.58501387",
"0.58492404",
"0.58091897",
"0.57963014",
"0.57812047",
"0.57540333",
"0.57262975",
"0.57174045",
"0.5708458",
"0.5661374",
"0.5589162",
"0.55674833",
"0.5548229",
"0.5532804",
"0.5519702",
"0.5... | 0.7608249 | 0 |
Each row of the matrix, let's say the jth row, represents the distance between the other data point from the jth point. This function returns the indexes for the points with the smallest distances with respect to each point represented by that specified row. By row, I mean the 0th dimension. Also notice that this funct... | def nearest_points_indexes_with_self(matrix, num_to_keep):
# Set the diagonal to 1
np.fill_diagonal(matrix, 1)
# Get the position for the resulted values
sort_arg = np.argsort(matrix, axis=1)
return sort_arg[:, : num_to_keep] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nearest_min(dist_matrix):\n # much faster than np.where\n i, j = np.unravel_index(\n np.argmin(dist_matrix), \n dims=dist_matrix.shape\n )\n return i, j",
"def nearest_points_indexes_without_self(matrix, num_to_keep):\n\n # Set the diagonal to 0\n np.fill_diagonal(matrix, 0)\n... | [
"0.76846826",
"0.7152678",
"0.65159774",
"0.6458269",
"0.64570606",
"0.6453487",
"0.64491487",
"0.6418172",
"0.6344188",
"0.6331945",
"0.62991154",
"0.62834746",
"0.62771547",
"0.62474954",
"0.6215967",
"0.6195537",
"0.6191709",
"0.6147389",
"0.6129545",
"0.6113139",
"0.60623... | 0.7358082 | 1 |
Generate an identity key pair. Clients should only do this once, at install time. the generated IdentityKeyPair. | def generateIdentityKeyPair():
keyPair = Curve.generateKeyPair()
publicKey = IdentityKey(keyPair.getPublicKey())
serialized = '0a21056e8936e8367f768a7bba008ade7cf58407bdc7a6aae293e2c' \
'b7c06668dcd7d5e12205011524f0c15467100dd603e0d6020f4d293' \
'edfbcd8... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_key_pair(self, keysize, cb):\n\n def gen_key_pair_pub_cb(data, ctx):\n if not data:\n warning('keymanagement: Could not generate a key pair\\n')\n cb(None, None)\n else:\n cb(ctx, data)\n\n def gen_key_pair_priv_cb(data, ctx):... | [
"0.71120954",
"0.68204904",
"0.65850353",
"0.6553852",
"0.65218014",
"0.6443924",
"0.6378423",
"0.63755655",
"0.6358998",
"0.6324435",
"0.63147116",
"0.6309187",
"0.62952316",
"0.6251726",
"0.61868006",
"0.61828184",
"0.61474425",
"0.6133282",
"0.61287004",
"0.60888094",
"0.6... | 0.8180875 | 0 |
Generate a registration ID. Clients should only do this once, at install time. | def generateRegistrationId():
regId = KeyHelper.getRandomSequence()
return regId | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_id():\n return uuid4().get_hex()",
"def generateID(self):\n\n return str(uuid.uuid1())",
"def get_id(self) -> str:\n return self._register_id",
"def makeid(cls):\n return str(uuid.uuid4().hex)",
"def generate_id():\n\treturn \"%s-%s\" % (str(uuid.uuid4())[:4],random... | [
"0.7785231",
"0.7583207",
"0.74686027",
"0.74049723",
"0.7362628",
"0.72884035",
"0.72758955",
"0.72758955",
"0.7264104",
"0.7262016",
"0.72611034",
"0.72470003",
"0.7220589",
"0.721949",
"0.7148431",
"0.71448946",
"0.7102137",
"0.7092246",
"0.70777285",
"0.7075378",
"0.70580... | 0.8603011 | 0 |
Generate a list of PreKeys. Clients should do this at install time, and subsequently any time the list of PreKeys stored on the server runs low. PreKey IDs are shorts, so they will eventually be repeated. Clients should store PreKeys in a circular buffer, so that they are repeated as infrequently as possible. start The... | def generatePreKeys(start, count):
results = []
start -= 1
for i in range(0, count):
preKeyId = ((start + i) % (Medium.MAX_VALUE - 1)) + 1
results.append(PreKeyRecord(preKeyId, Curve.generateKeyPair()))
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_keys(self):\n self.keys = []\n key = string_to_bit_array(self.passwd)\n key = self.permutation(key, CP_1) # Perform initial permutation on the key\n g, d = split_into_n(key, 28) # Split into g (LEFT) & d (RIGHT)\n for i in range(16): # Apply the 16 rounds\n ... | [
"0.6100436",
"0.57589746",
"0.5668012",
"0.56462705",
"0.5632386",
"0.55703026",
"0.5561076",
"0.5519232",
"0.5507431",
"0.5470912",
"0.546842",
"0.54056185",
"0.52409744",
"0.5236303",
"0.5193606",
"0.5192819",
"0.51398957",
"0.50818324",
"0.5079338",
"0.5055663",
"0.5039773... | 0.87624663 | 0 |
Check whether the given reader exists | def exists(reader_name: str) -> bool:
return plugins.exists(package_name=__name__, plugin_name=reader_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _haveReadLocks(self): \n readLockFileName = ReadLock.fileName\n for name in os.listdir(self.dir):\n if name.startswith(readLockFileName):\n return True\n return False",
"def exists(identifier, network):\n foo = next(load(identifier, network), None)... | [
"0.6164184",
"0.5904849",
"0.58638656",
"0.58638656",
"0.5770025",
"0.575396",
"0.56898904",
"0.5686118",
"0.56144536",
"0.56005126",
"0.5580309",
"0.5566034",
"0.5542885",
"0.55397743",
"0.5537704",
"0.55220896",
"0.5509569",
"0.54929805",
"0.549026",
"0.54900736",
"0.547761... | 0.66304976 | 0 |
Get one line documentation for readers If no readers are specified, documentation for all available readers are returned. | def short_docs(*readers: str) -> List[Tuple[str, str]]:
if not readers:
readers = names()
return [(r, plugins.doc(__name__, r, long_doc=False)) for r in readers] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_readers():\n return all_readers",
"def get_docs(self):\n return self.retrieve_docstring()",
"def get_docs(self):\n return self.retrieve_docstring()",
"def get_docs(self):\n return self.retrieve_docstring()",
"def read_documentation(self, fid):\r\n\r\n lin = self.read_... | [
"0.6139211",
"0.5529351",
"0.5529351",
"0.5529351",
"0.5385095",
"0.53439957",
"0.52958757",
"0.5215697",
"0.5117727",
"0.49581614",
"0.48913068",
"0.4863882",
"0.48443574",
"0.48011702",
"0.47767526",
"0.47586027",
"0.47446275",
"0.4685375",
"0.46740708",
"0.4643249",
"0.462... | 0.67184293 | 0 |
Read a bytes stream with a given reader If the reader is not specified, an attempt to guess at an appropriate reader is made. A NoReaderFound error is raised if no such appropriate reader is found. | def read_stream(
input_stream: IO[bytes], reader_name: Optional[str] = None, **reader_args: Any
) -> Reader:
if reader_name is None:
reader_name = identify(input_stream)
reader = plugins.call(
package_name=__name__,
plugin_name=reader_name,
input_stream=input_stream,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_reader(fn):\n if is_bed(fn):\n return BedReader(fn)\n elif is_vcf(fn):\n return VcfReader(fn)\n else:\n raise ValueError(\"Could not get reader for %s\" % fn)",
"def read_file(\n file_path: Union[str, pathlib.Path],\n reader_name: Optional[str] = None,\n **reader_ar... | [
"0.6057923",
"0.6019735",
"0.5995071",
"0.59576786",
"0.5762868",
"0.5712855",
"0.5576423",
"0.544311",
"0.54237616",
"0.54231197",
"0.5403411",
"0.53777176",
"0.53776944",
"0.52933985",
"0.5291875",
"0.52114725",
"0.5191779",
"0.5167444",
"0.514691",
"0.51206833",
"0.510413"... | 0.6454055 | 0 |
Read a file with a given reader If the reader is not specified, an attempt to guess at an appropriate reader is made. A NoReaderFound error is raised if no such appropriate reader is found. | def read_file(
file_path: Union[str, pathlib.Path],
reader_name: Optional[str] = None,
**reader_args: Any,
) -> Reader:
with open(file_path, mode="rb") as input_stream:
return read_stream(input_stream, reader_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(filePath, reader='infer'):\n if isinstance(reader, str):\n if reader == 'infer':\n loader = inferReader(filePath)\n else:\n if reader in READERS:\n loader = READERS[reader]\n else:\n raise SerpentToolsException(\n ... | [
"0.73507124",
"0.6649994",
"0.6541662",
"0.6465156",
"0.6096228",
"0.5905837",
"0.5818582",
"0.5808917",
"0.57055247",
"0.5697342",
"0.5619084",
"0.5508928",
"0.5467147",
"0.5462562",
"0.5446384",
"0.5420934",
"0.5397053",
"0.5380353",
"0.53490704",
"0.5324267",
"0.53047097",... | 0.7362303 | 0 |
Test pointwise arithmetic with stencil offsets across two functions in indexed expression format | def test_indexed_stencil(self, expr, result):
j, l = dimify('j l')
a = symbol(name='a', dimensions=(j, l), value=0., mode='indexed').base
fa = a.function
b = symbol(name='b', dimensions=(j, l), value=2., mode='indexed').base
fb = b.function
eqn = eval(expr)
Opera... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_offsets():\n B = 100\n H = 20\n E = 210000\n sections = ((B, H, 0, E),)\n sections2 = ((B, H, 12.435, E),)\n EI, top, bot = bm.EI(sections, E)\n EI2, top2, bot2 = bm.EI(sections2, E)\n assert 0.99 < EI / EI2 < 1.01\n assert 0.99 < top / top2 < 1.01\n assert 0.99 < bot / bot2 ... | [
"0.54499704",
"0.54236096",
"0.54200417",
"0.54183537",
"0.53868484",
"0.5386813",
"0.5386671",
"0.53676295",
"0.53601813",
"0.5349417",
"0.53437924",
"0.53436583",
"0.5304866",
"0.53009784",
"0.5292884",
"0.52877325",
"0.5283028",
"0.5282718",
"0.5279577",
"0.52767044",
"0.5... | 0.70558316 | 0 |
Test pointwise arithmetic with stencil offsets across a single functions with buffering dimension in indexed expression format | def test_indexed_buffered(self, expr, result):
i, j, l = dimify('i j l')
a = symbol(name='a', dimensions=(i, j, l), value=2., mode='indexed').base
fa = a.function
eqn = eval(expr)
Operator(eqn)(fa)
assert np.allclose(fa.data[1, 1:-1, 1:-1], result[1:-1, 1:-1], rtol=1e-12... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_indexed_stencil(self, expr, result):\n j, l = dimify('j l')\n a = symbol(name='a', dimensions=(j, l), value=0., mode='indexed').base\n fa = a.function\n b = symbol(name='b', dimensions=(j, l), value=2., mode='indexed').base\n fb = b.function\n\n eqn = eval(expr)\n... | [
"0.70109046",
"0.5731927",
"0.5725207",
"0.5534058",
"0.5485873",
"0.54508567",
"0.5420271",
"0.5402067",
"0.53938526",
"0.5361206",
"0.53606236",
"0.5359261",
"0.5359202",
"0.5320887",
"0.5293664",
"0.5291382",
"0.5265721",
"0.52385396",
"0.523383",
"0.52290106",
"0.52282166... | 0.5903518 | 1 |
Test pointwise arithmetic with stencil offsets and open loop boundaries in indexed expression format | def test_indexed_open_loops(self, expr, result):
i, j, l = dimify('i j l')
pushed = [d.size for d in [j, l]]
j.size = None
l.size = None
a = DenseData(name='a', dimensions=(i, j, l), shape=(3, 5, 6)).indexed
fa = a.function
fa.data[0, :, :] = 2.
eqn = eva... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_indexed_stencil(self, expr, result):\n j, l = dimify('j l')\n a = symbol(name='a', dimensions=(j, l), value=0., mode='indexed').base\n fa = a.function\n b = symbol(name='b', dimensions=(j, l), value=2., mode='indexed').base\n fb = b.function\n\n eqn = eval(expr)\n... | [
"0.6950202",
"0.58628595",
"0.56040186",
"0.5595086",
"0.5519812",
"0.54418904",
"0.54108006",
"0.533119",
"0.53181374",
"0.53098184",
"0.5292402",
"0.5292149",
"0.5247795",
"0.5246134",
"0.523379",
"0.5228938",
"0.5216184",
"0.51775336",
"0.51391",
"0.513825",
"0.51371264",
... | 0.6362784 | 1 |
Test calltime symbols overrides with other symbols | def test_override_symbol(self):
i, j, k, l = dimify('i j k l')
a = symbol(name='a', dimensions=(i, j, k, l), value=2.)
a1 = symbol(name='a1', dimensions=(i, j, k, l), value=3.)
a2 = symbol(name='a2', dimensions=(i, j, k, l), value=4.)
op = Operator(Eq(a, a + 3))
op()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testSymbolHash(self):\n gScope = pykd.diaLoadPdb( str(target.module.pdb()) )\n symSet = set([ gScope[\"g_structTest\"], gScope[\"EnumWindowsProc1\"], gScope[\"g_structTest\"] ])\n self.assertEqual( 2, len(symSet) )\n self.assertTrue( gScope[\"g_structTest\"] in symSet )\n sel... | [
"0.6088717",
"0.5891969",
"0.586841",
"0.57884955",
"0.57511026",
"0.5713668",
"0.5713668",
"0.57010543",
"0.5664404",
"0.5631575",
"0.5563887",
"0.55595315",
"0.55191725",
"0.5508196",
"0.54970926",
"0.54917103",
"0.5480295",
"0.54737866",
"0.5444322",
"0.54287255",
"0.54046... | 0.58977205 | 1 |
Test calltime symbols overrides with numpy arrays | def test_override_array(self):
i, j, k, l = dimify('i j k l')
shape = tuple(d.size for d in (i, j, k, l))
a = symbol(name='a', dimensions=(i, j, k, l), value=2.)
a1 = np.zeros(shape=shape, dtype=np.float32) + 3.
a2 = np.zeros(shape=shape, dtype=np.float32) + 4.
op = Opera... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_TimeArray_repr():",
"def test_format_signature_numpy():",
"def test_TimeArray_convert_unit():",
"def test_TimeArray_copyflag():\r\n\r\n #These two should both generate a TimeArray, with one picosecond.\r\n #This one holds time_unit='s'\r\n t1 = ts.TimeArray(np.array([1], dtype=np.int64), co... | [
"0.6313198",
"0.6234536",
"0.61531353",
"0.60441715",
"0.5897211",
"0.58689487",
"0.5791092",
"0.5729955",
"0.5682435",
"0.5682435",
"0.5633471",
"0.55964816",
"0.55935395",
"0.5578403",
"0.5577986",
"0.5554115",
"0.5551436",
"0.555043",
"0.554579",
"0.5534603",
"0.55257624",... | 0.6475489 | 0 |
Test that the dimension sizes are being inferred correctly | def test_dimension_size_infer(self, nt=100):
i, j, k = dimify('i j k')
shape = tuple([d.size for d in [i, j, k]])
a = DenseData(name='a', shape=shape).indexed
b = TimeData(name='b', shape=shape, save=True, time_dim=nt).indexed
eqn = Eq(b[time, x, y, z], a[x, y, z])
op = O... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_size_check(self):\n [x1, y1, s1, g1] = self.data.diffusion_data.shape\n [x2, y2, s2, g2] = module_05.run_module(self.data).diffusion_data.shape\n self.assertEqual(x1, x2)\n self.assertEqual(y1, y2)\n self.assertEqual(s1, s2)\n self.assertEqual(g1, g2)",
"def dim... | [
"0.76725674",
"0.75539386",
"0.74125654",
"0.7359512",
"0.73051524",
"0.72323257",
"0.7225344",
"0.7185799",
"0.71210706",
"0.6941943",
"0.68519884",
"0.6851906",
"0.68469083",
"0.68195313",
"0.6812142",
"0.67658305",
"0.6746414",
"0.6741667",
"0.6688384",
"0.66588515",
"0.66... | 0.76781756 | 0 |
Test Box with photon shooting. Particularly the flux of the final image. | def test_box_shoot():
rng = galsim.BaseDeviate(1234)
obj = galsim.Box(width=1.3, height=2.4, flux=1.e4)
im = galsim.Image(100,100, scale=1)
im.setCenter(0,0)
added_flux, photons = obj.drawPhot(im, poisson_flux=False, rng=rng.duplicate())
print('obj.flux = ',obj.flux)
print('added_flux = ',ad... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_box():\n savedImg = galsim.fits.read(os.path.join(imgdir, \"box_1.fits\"))\n myImg = galsim.ImageF(savedImg.bounds, scale=0.2)\n myImg.setCenter(0,0)\n test_flux = 1.8\n\n pixel = galsim.Pixel(scale=1, flux=1)\n pixel.drawImage(myImg, method=\"sb\", use_true_center=False)\n np.testing... | [
"0.6883019",
"0.60247976",
"0.5729917",
"0.5662367",
"0.5657805",
"0.56022036",
"0.5602087",
"0.55716115",
"0.5532589",
"0.5502499",
"0.5473831",
"0.54660267",
"0.54527724",
"0.54423535",
"0.5430135",
"0.5401244",
"0.5400176",
"0.53518057",
"0.53516215",
"0.53498757",
"0.5337... | 0.72881216 | 0 |
Decide whether to enter hotspot mode or wifi mode and then do so | def set_wifi_mode(args):
pass
"""+
try:
if args['mode'] == 'hotspot':
logger.info('will enter hotspot mode')
#TODO - Need to capture the line that contains interface [some lan id] and uncomment it.
change_file_line(path.join('/etc', 'dhcpcd.conf'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cycle_wifi(mode=None):\n call(['ifdown', settings.WIFI_INTERFACE])\n if mode is not None:\n call(['iwconfig', settings.WIFI_INTERFACE, 'mode', mode])\n call(['ifup', settings.WIFI_INTERFACE])",
"def switch_network(self,type = None):\n network_type = self.appconfig(type... | [
"0.6191428",
"0.60795987",
"0.60477906",
"0.5971737",
"0.59445924",
"0.58588445",
"0.57119495",
"0.570681",
"0.57007",
"0.5689363",
"0.5664943",
"0.5628451",
"0.5603096",
"0.5597446",
"0.55574036",
"0.55567616",
"0.5528155",
"0.55259633",
"0.5525236",
"0.5521546",
"0.5498724"... | 0.71384984 | 0 |
Function that returns true if a string contains a number | def hasNumbers(inputString):
return any(char.isdigit() for char in inputString) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __has_numbers(self, input_string):\n return bool(re.search(r'\\d', input_string))",
"def has_number(any_string):\n return any(char.isdigit() for char in any_string)",
"def has_num(text):\n return any(str.isdigit(c) for c in text)",
"def is_number(s):\r\n try:\r\n int(s)\r\n ... | [
"0.86861813",
"0.83668447",
"0.82383734",
"0.7930955",
"0.79304606",
"0.7924505",
"0.78930366",
"0.78647584",
"0.77653086",
"0.7743263",
"0.7714202",
"0.7706238",
"0.77058214",
"0.77046204",
"0.77044505",
"0.7690902",
"0.766317",
"0.7639565",
"0.7527607",
"0.7527464",
"0.7508... | 0.8393111 | 1 |
Function that saves the return_list from make_time to a file called yt_vids.txt Optional, default False | def save_link_time(return_list, path_to_download):
# Opens a new file and writes lines to it and saves it at the spot provided
with open(os.path.join(path_to_download, "yt_vids.txt"), "w") as w:
w.write('\n'.join('{} {} {}'.format(
x[0], x[1][0], x[1][1]) for x in return_list)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_save_list_to_file(self):\n task_list = TaskList()\n task1 = Task()\n output_file_path = self.testing_files[0]\n task1.set_name('Test Task One')\n task1.set_minutes(30)\n task1.set_notes('This is a great test task')\n task_list.add_task(task1)\n\n sel... | [
"0.5606279",
"0.54776007",
"0.5325414",
"0.527905",
"0.5232085",
"0.5220749",
"0.5214294",
"0.5194305",
"0.5157583",
"0.5149266",
"0.51426595",
"0.51125914",
"0.50968117",
"0.50955224",
"0.50598377",
"0.50564367",
"0.5056409",
"0.5055913",
"0.50520384",
"0.5035325",
"0.503340... | 0.7020351 | 0 |
Function that downloads a whole video when no interval is supplied Downloaded to the same place where yt_vids is saved to (from save_link_time func) | def download_whole(no_interval):
print(os.getcwd())
SAVE_PATH = 'tmp'
ydl_opts = {"nocheckcertificate": True, "noplaylist": True,
'outtmpl': f'{SAVE_PATH}/%(title)s.%(ext)s'}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
for video in range(len(no_interval)):
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(df_shorter,folderName):\n os.mkdir(str(folderName))\n path = os.getcwd()+'\\\\'+str(folderName)+'\\\\'\n #add column with video link generated from IDs\n df_shorter['urls'] = df_shorter['id'].apply(lambda x: generateLinkFromId(x))\n vid_dl = []\n i = 1\n for url in df_shorter['url... | [
"0.73994005",
"0.72689897",
"0.7202489",
"0.7171504",
"0.7060031",
"0.6903402",
"0.6774965",
"0.67710614",
"0.67318517",
"0.6675659",
"0.66156524",
"0.66117424",
"0.6610987",
"0.6610455",
"0.6599049",
"0.6573128",
"0.6570862",
"0.6523697",
"0.651439",
"0.65080476",
"0.6456765... | 0.74180853 | 0 |
Function to download videos in specified intervals Takes a list (interval_list) and a path as inputs | def download_interval(interval_list):
start = ['start', 'begin', 'beginning', 'head', 'first']
end = ['slut', 'end', 'tail', 'finish',
'finito', 'fin', 'done', 'finished']
# Iterate over the list
for link in range(len(interval_list)):
try:
video = pafy.new(interval_list[l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_whole(no_interval):\n print(os.getcwd())\n SAVE_PATH = 'tmp'\n ydl_opts = {\"nocheckcertificate\": True, \"noplaylist\": True,\n 'outtmpl': f'{SAVE_PATH}/%(title)s.%(ext)s'}\n\n with youtube_dl.YoutubeDL(ydl_opts) as ydl:\n for video in range(len(no_interval)):\n ... | [
"0.6634631",
"0.6432747",
"0.63896453",
"0.6305958",
"0.60365444",
"0.59619087",
"0.5885181",
"0.5815725",
"0.56896555",
"0.5573953",
"0.5560245",
"0.5557694",
"0.55472976",
"0.5520894",
"0.5493748",
"0.5459092",
"0.54333603",
"0.54173565",
"0.54105514",
"0.54061747",
"0.5402... | 0.79695 | 0 |
Function to download pictures from the input sequence | def download_pics(pics_links):
for link in range(len(pics_links)):
r = requests.get(pics_links[link][0])
with open(os.path.join("tmp", f"{link}.jpg"), "wb") as dl:
dl.write(r.content) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downloadLocal(url_list,path):\n print(\"You are downloading {} images\".format(parser_arguments().limit),end=\" \");print(\"of {} class.\".format(parser_arguments().classes))\n print(\"Please, be patient :)\")\n for i in range(len(url_list)):\n filename= url_list[i].split(\"/\")[-1] # name of t... | [
"0.66714674",
"0.6665392",
"0.662957",
"0.65895194",
"0.6587865",
"0.6502355",
"0.64724034",
"0.64450634",
"0.64316654",
"0.6391709",
"0.6382724",
"0.6302078",
"0.6292136",
"0.6259905",
"0.6259636",
"0.6252637",
"0.6219414",
"0.6212664",
"0.61892736",
"0.61513776",
"0.6140734... | 0.6981115 | 0 |
Get chain attribute for an object. | def chain_getattr(obj, attr, value=None):
try:
return _resolve_value(safe_chain_getattr(obj, attr))
except AttributeError:
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_chain_getattr(obj, attr):\n return reduce(getattr, attr.split('.'), obj)",
"def chained_getattr(obj, path):\n target = obj\n for attr in path:\n target = corner_case_getattr(target, attr)\n return target",
"def deepgetattr(obj, attr):\n\t\treturn reduce(getattr, attr.split('.'), obj)",
"def... | [
"0.6868703",
"0.65075165",
"0.6485146",
"0.64567274",
"0.62154573",
"0.61727905",
"0.61658573",
"0.6000796",
"0.5964722",
"0.5916216",
"0.5916216",
"0.5876859",
"0.5874207",
"0.5869589",
"0.5869589",
"0.5850275",
"0.58463216",
"0.58114004",
"0.5795329",
"0.57904404",
"0.57904... | 0.7126414 | 0 |
trim the list to make total length no more than limit.If split specified,a string is return. | def trim_iterable(iterable, limit, *, split=None, prefix='', postfix=''):
if split is None:
sl = 0
join = False
else:
sl = len(split)
join = True
result = []
rl = 0
for element in iterable:
element = prefix + element + postfix
el = len(element)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trim(self, input_words_list):\n def to_be_trimmed(x):\n if len(x) < 3:\n return False\n else:\n return True\n self.trimmed_words_list = list(filter(to_be_trimmed, input_words_list))\n # print('the filtered words are:')\n # for word... | [
"0.61260587",
"0.61242557",
"0.60332996",
"0.5976751",
"0.59576887",
"0.59357154",
"0.59291357",
"0.575979",
"0.5731277",
"0.56639487",
"0.5637736",
"0.5636854",
"0.5605196",
"0.5510604",
"0.5455997",
"0.54495543",
"0.5449324",
"0.544276",
"0.54360414",
"0.5429126",
"0.542896... | 0.66803694 | 0 |
It raises an error when trying to decrypt a nonencrypted value. | def test_decrypt_format(self):
with pytest.raises(EncryptionError):
decrypt('message') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_decrypt_key_invalid(self):\n encrypted = encrypt('message', key=b'0' * 32)\n\n with pytest.raises(EncryptionError):\n decrypt(encrypted, key=b'0' * 31)",
"def test_decrypt_key_incorrect(self):\n right_key = b'0' * 32\n wrong_key = b'1' * 32\n\n encrypted = e... | [
"0.7508658",
"0.73156184",
"0.7232054",
"0.6764023",
"0.66845644",
"0.657834",
"0.6562093",
"0.65003294",
"0.6460941",
"0.6459456",
"0.6367024",
"0.63215554",
"0.6274202",
"0.62535083",
"0.62495065",
"0.62276834",
"0.6201334",
"0.6190526",
"0.618059",
"0.61519164",
"0.6145261... | 0.76258427 | 0 |
It accepts a custom decryption key. | def test_decrypt_key(self):
key = b'0' * 32
encrypted = encrypt('message', key=key)
assert decrypt(encrypted, key=key) == 'message' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt(ciphertext: str, key: str) -> str:\n return encrypt(ciphertext, key)",
"def test_decryption(d, c):\n\n#\td = int(raw_input(\"\\nEnter d from public key\\n\"))\n#\tc = int(raw_input(\"\\nEnter c from public key\\n\"))\n\n x = int(raw_input(\"\\nEnter number to decrypt\\n\"))\n decode(endecryp... | [
"0.6593434",
"0.6539305",
"0.6523048",
"0.65177274",
"0.65156114",
"0.6480838",
"0.645648",
"0.63991714",
"0.63842076",
"0.63480246",
"0.634022",
"0.6332533",
"0.6332092",
"0.631312",
"0.62985706",
"0.6246969",
"0.6217749",
"0.6211802",
"0.6208556",
"0.62013805",
"0.6200206",... | 0.69840544 | 0 |
It reencrypts an encrypted message using a new key. | def test_rekey(self):
old_key = b'0' * 32
new_key = b'1' * 32
old_encrypted = encrypt('message', key=old_key)
new_encrypted = rekey(old_encrypted, old_key=old_key, new_key=new_key)
assert decrypt(new_encrypted, key=new_key) == 'message' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rekey_defaults(self, settings):\n old_key = b'0' * 32\n new_key = b'1' * 32\n\n settings.CHITON_ENCRYPTION_KEY = new_key\n settings.CHITON_PREVIOUS_ENCRYPTION_KEY = old_key\n\n encrypted = encrypt('message', key=old_key)\n rekeyed = rekey(encrypted)\n\n ass... | [
"0.7298857",
"0.7298796",
"0.71268785",
"0.66500294",
"0.6324676",
"0.62568414",
"0.6190534",
"0.6128457",
"0.61111814",
"0.6098401",
"0.60541093",
"0.59321904",
"0.5931756",
"0.5884302",
"0.587639",
"0.58716655",
"0.5832455",
"0.58202076",
"0.5819175",
"0.5817855",
"0.580720... | 0.7975824 | 0 |
It raises an error when trying to rekey a nonencrypted value. | def test_rekey_non_encrypted(self):
with pytest.raises(EncryptionError):
rekey('message', old_key=b'0' * 32, new_key=b'1' * 32) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rekey_key_format(self):\n old_key = b'0' * 32\n encrypted = encrypt('message', key=old_key)\n\n with pytest.raises(EncryptionError):\n rekey(encrypted, old_key=old_key, new_key=b'1' * 31)",
"def test_encrypt_key_invalid(self):\n with pytest.raises(EncryptionError):... | [
"0.7787494",
"0.7165129",
"0.7140279",
"0.71330994",
"0.69257516",
"0.6686824",
"0.6646899",
"0.6348278",
"0.6192973",
"0.6057841",
"0.60305434",
"0.6001477",
"0.5970502",
"0.58401686",
"0.5836722",
"0.5806258",
"0.5804228",
"0.57949257",
"0.57405263",
"0.57361877",
"0.571489... | 0.82164097 | 0 |
It raises an error when given an invalid new key. | def test_rekey_key_format(self):
old_key = b'0' * 32
encrypted = encrypt('message', key=old_key)
with pytest.raises(EncryptionError):
rekey(encrypted, old_key=old_key, new_key=b'1' * 31) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _newKey(self, key):\n pass",
"def _check_key(self, key):\n raise NotImplementedError",
"def test_rekey_non_encrypted(self):\n with pytest.raises(EncryptionError):\n rekey('message', old_key=b'0' * 32, new_key=b'1' * 32)",
"def test_set_invalid_key(test_file):\n md = OSX... | [
"0.71822304",
"0.70056105",
"0.69519156",
"0.6922246",
"0.6791061",
"0.6753472",
"0.6749198",
"0.67076725",
"0.66495234",
"0.6584771",
"0.6557083",
"0.65199524",
"0.65018636",
"0.64907044",
"0.6454335",
"0.64416265",
"0.6438558",
"0.6431475",
"0.6424363",
"0.6396235",
"0.6389... | 0.7050168 | 1 |
Return True if domain is marked sensitive | def is_domain_sensitive(name):
query = database.session_query(Domain)
query = query.filter(and_(Domain.sensitive, Domain.name == name))
return database.find_all(query, Domain, {}).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indomain(url, domain):\n if url and domain:\n return url.startswith(domain)\n return False",
"def is_secure_site_enabled(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"is_secure_site_enabled\")",
"def is_secure_site_enabled(self) -> Optional[pulumi.Input[bool]]:\n ... | [
"0.5945297",
"0.5943389",
"0.5943389",
"0.58801776",
"0.5860374",
"0.5823208",
"0.58100474",
"0.5775172",
"0.57475305",
"0.57442623",
"0.57067436",
"0.56709236",
"0.56709236",
"0.56709236",
"0.56595856",
"0.56003463",
"0.55976045",
"0.5583748",
"0.5570339",
"0.5522135",
"0.55... | 0.7324499 | 0 |
Update an existing domain | def update(domain_id, name, sensitive):
domain = get(domain_id)
domain.name = name
domain.sensitive = sensitive
database.update(domain) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_domain(domain_name):\n\n if request.method == \"POST\":\n domain = session.query(Domain).filter(\n Domain.domain_name == domain_name).first()\n\n # Check if domain.provider object exists to make sure\n # duplicate Provider.provider_url is not created\n provider = ... | [
"0.7216133",
"0.6992674",
"0.69599164",
"0.6770144",
"0.6691671",
"0.6631902",
"0.66250306",
"0.66209924",
"0.6600841",
"0.65592813",
"0.6530738",
"0.65130335",
"0.6412239",
"0.63919693",
"0.63866",
"0.6360199",
"0.6326602",
"0.6326602",
"0.63022065",
"0.6297731",
"0.62386405... | 0.77741724 | 0 |
Establish a TCP connection to the indiserver via port 7624 | def connect_to_indi():
indiclient=IndiClient()
indiclient.setServer("localhost",7624)
# Ensure the indiserver is running
if (not(indiclient.connectServer())):
print("No indiserver running on "+indiclient.getHost()+":"+str(indiclient.getPort())+" - Try to run")
print(" indis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SCPI_sock_connect(ipaddress,port=5025):\n\n try:\n session=socket.socket(socket.AF_INET,socket.SOCK_STREAM)\n #session.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 0)\n #session.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, 0)\n session.connect((ipaddress,port))\n exce... | [
"0.62255913",
"0.62050253",
"0.6195879",
"0.6171926",
"0.6135462",
"0.6120585",
"0.606939",
"0.60673463",
"0.602371",
"0.6017615",
"0.60021055",
"0.60011834",
"0.5976623",
"0.5967753",
"0.5963107",
"0.59526026",
"0.59498817",
"0.5947324",
"0.5940068",
"0.5910819",
"0.59102845... | 0.68877107 | 0 |
Connection routine for the CCD (given below in ccd variable). The following CCD properties are accessed. More can be found by going to indilib.org. CONNECTION Switch CCD_EXPOSURE Number CCD1 BLOB CCD_BINNING Number CCD_ABORT_EXPOSURE Number CCD_TEMPERATURE Number CCD_COOLER Switch CCD_FRAME_TYPE Switch | def connect_to_ccd():
ccd="SX CCD SXVR-H694"
device_ccd=indiclient.getDevice(ccd)
while not(device_ccd):
time.sleep(0.5)
device_ccd=indiclient.getDevice(ccd)
print("Searching for device...")
print("Found device")
ccd_connect=device_ccd.getSwitch("CONNECTION")
whil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_circ():\n\n set_mode(mode_cc) # set operation mode to CC\n time.sleep(.250)\n set_CC_current(cc_current=0) # set CC mode current to 0 amps\n time.sleep(.1)\n \n oc_vals = get_input_values() # read open circuits levels\n oc_data_point = data_point(oc_vals) # create data point for ope... | [
"0.5991389",
"0.5908873",
"0.563912",
"0.5434294",
"0.54057074",
"0.53454",
"0.53262013",
"0.5306355",
"0.52807844",
"0.52574426",
"0.5246854",
"0.5221757",
"0.5210567",
"0.51662695",
"0.51509064",
"0.5141476",
"0.51294994",
"0.5121288",
"0.5110107",
"0.5095082",
"0.50932145"... | 0.7094732 | 0 |
Find the last numbered image in the current directory. | def last_image(fileDir):
lastNum = 0
lastImg = ''
# find the name and number of the last image in the current directory
for f in os.listdir(fileDir):
if os.path.isfile(os.path.join(fileDir, f)):
file_name = os.path.splitext(f)[0]
file_name2 = file_name[4:]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_counter():\n counter = imageNumStart\n if imageNumOn:\n image_ext = \".jpg\"\n search_str = imagePath + \"/*\" + image_ext\n file_prefix_len = len(imagePath + imageNamePrefix)+1\n try:\n # Scan image folder for most recent jpg file\n # and try to e... | [
"0.7381124",
"0.71163946",
"0.6752403",
"0.65669954",
"0.651449",
"0.6455671",
"0.6257701",
"0.62144595",
"0.61207634",
"0.6083774",
"0.60167074",
"0.6005787",
"0.5981818",
"0.59797287",
"0.5971447",
"0.597075",
"0.59043884",
"0.5898508",
"0.58921754",
"0.5875937",
"0.581396"... | 0.7685043 | 0 |
Sends an exposure command to the CCD given the type of frame and exposure time. The received BLOB is of FITS type and is | def exposure(frameType, expTime):
blobEvent.clear()
# set the specified frame type
if frameType.lower() == 'light':
ccd_frame[0].s = PyIndi.ISS_ON
ccd_frame[1].s = PyIndi.ISS_OFF
ccd_frame[2].s = PyIndi.ISS_OFF
ccd_frame[3].s = PyIndi.ISS_OFF
indiclient.sendNew... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expose(self, cmd, expTime, expType):\n\n if not expType:\n expType = 'test'\n if cmd:\n cmd.inform('exposureState=\"exposing\"')\n if expType not in ('bias', 'test') and expTime > 0:\n time.sleep(expTime + self._exposureOverheadTime())\n\n if cmd:\n ... | [
"0.66172343",
"0.66024214",
"0.61997694",
"0.6147396",
"0.6001152",
"0.5911744",
"0.5895627",
"0.5890128",
"0.5692038",
"0.5651894",
"0.5623061",
"0.56096864",
"0.54805845",
"0.54146963",
"0.5291824",
"0.5205684",
"0.5177268",
"0.51427567",
"0.51357037",
"0.5105987",
"0.50998... | 0.7639681 | 0 |
This is the method that receives the client's data and decides what to do with it. It runs in a loop to always be accepting new connections. If the data is 'status', the CCD status is returned. If the data is 'stop', the current exposure is stopped. If the data is anything else, a new thread is created and the data is ... | async def handle_client(reader, writer):
request = None
# loop to continually handle incoming data
while request != 'quit':
request = (await reader.read(255)).decode('utf8')
print(request.encode('utf8'))
#log.info('COMMAND = '+request)
writer.write(('COMMAND = '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handleRecvData(self, data):\n\n\t\t#Look for commands\n\t\tif data == 'Hello':\n\t\t\t#Inform client it is 'connected'\n\t\t\tself.transmit(\"Welcome\")\n\n\t\telif data == 'kill':\t\n\t\t\t#Stop the server running\n\t\t\tself.running = False\n\n\t\telif data == 'control':\n\t\t\t#Print out if in control of ca... | [
"0.7136164",
"0.66953665",
"0.6398843",
"0.6384446",
"0.63746595",
"0.6355251",
"0.6276334",
"0.62578547",
"0.6232429",
"0.6153676",
"0.61311704",
"0.60923487",
"0.60865486",
"0.6026433",
"0.59538",
"0.5909406",
"0.5902352",
"0.58999",
"0.58918047",
"0.58892024",
"0.58742887"... | 0.6803808 | 1 |
Get list of names of accessible repositories (including owner) | def list_repositories(self):
data = self._get_all_data('/user/repos')
return [repo['full_name'] for repo in data] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repositories(self, user_name=None):\n user_name = user_name if user_name else self._auth[0]\n data = self._request('GET', 'users', user_name)\n return data.repositories\n #ret_val = []\n #for repository in data.repositories:\n # ret_val.append(repository.name)\n ... | [
"0.7608418",
"0.7267118",
"0.7101556",
"0.70416945",
"0.6976196",
"0.69618136",
"0.6874849",
"0.6862077",
"0.68582284",
"0.68060064",
"0.6804673",
"0.6765574",
"0.67367995",
"0.67278445",
"0.67108905",
"0.66979",
"0.6602462",
"0.6571694",
"0.65691054",
"0.6552383",
"0.6520411... | 0.78467643 | 0 |
Get dict of labels with colors for given repository slug | def list_labels(self, repository):
data = self._get_all_data('/repos/{}/labels'.format(repository))
return {l['name']: str(l['color']) for l in data} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def colors_for_labels():\n colors = [(i * np.array([2 ** 25 - 1, 2 ** 15 - 1, 2 ** 21 - 1]) % 255).astype(np.uint8) for i in range(len(CATEGORY))]\n #colors = np.array(range(len(COCO_INSTANCE_CATEGORY_NAMES))) * np.array([2 ** 25 - 1, 2 ** 15 - 1, 2 ** 21 - 1])\n #colors = (colors % 255).numpy().astype(\"... | [
"0.65194696",
"0.5914808",
"0.5822218",
"0.5784747",
"0.57322896",
"0.5691123",
"0.5686196",
"0.5633396",
"0.56304544",
"0.56205434",
"0.55804044",
"0.5575821",
"0.5575821",
"0.5575821",
"0.5575821",
"0.5560394",
"0.55267113",
"0.55267113",
"0.5519801",
"0.5494467",
"0.549199... | 0.7589527 | 0 |
Create new label in given repository | def create_label(self, repository, name, color, **kwargs):
data = {'name': name, 'color': color}
response = self.session.post(
'{}/repos/{}/labels'.format(self.GH_API_ENDPOINT, repository),
json=data
)
if response.status_code != 201:
raise GitHubError(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_label(self, org, name):\n pass",
"def test_issue_create_label(self):\n pass",
"async def new_label(event, gh, *args, **kwargs):\n if event.data[\"label\"][\"name\"] == TRIVIAL_LABEL:\n issue_number_found = ISSUE_RE.search(\n event.data[\"pull_request\"][\"title\"])... | [
"0.7274326",
"0.7140176",
"0.67611367",
"0.6694404",
"0.6539713",
"0.6458034",
"0.64482284",
"0.6406368",
"0.63728607",
"0.6343112",
"0.6218493",
"0.6180373",
"0.6086001",
"0.6058881",
"0.60423875",
"0.6024324",
"0.6002186",
"0.5988165",
"0.5969681",
"0.59262604",
"0.5906312"... | 0.77359784 | 0 |
Update existing label in given repository | def update_label(self, repository, name, color, old_name=None, **kwargs):
data = {'name': name, 'color': color}
response = self.session.patch(
'{}/repos/{}/labels/{}'.format(
self.GH_API_ENDPOINT, repository, old_name or name
),
json=data
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_labels(repo: Repository, labels: list[Label]):\n\n log.info(f\"Fetching existing labels from {repo.full_name}\")\n existing_labels = {label.name.casefold(): label for label in repo.get_labels()}\n log.info(f\"Found {len(existing_labels)} existing labels\")\n\n for label in labels:\n qual... | [
"0.6681116",
"0.6653021",
"0.64337254",
"0.6265893",
"0.62407804",
"0.6226869",
"0.61520106",
"0.6127353",
"0.61121166",
"0.61037016",
"0.6094828",
"0.603661",
"0.60320926",
"0.59240484",
"0.59008676",
"0.58834106",
"0.58732027",
"0.5860932",
"0.5839947",
"0.58363944",
"0.580... | 0.72466385 | 0 |
Delete existing label in given repository | def delete_label(self, repository, name, **kwargs):
response = self.session.delete(
'{}/repos/{}/labels/{}'.format(
self.GH_API_ENDPOINT, repository, name
)
)
if response.status_code != 204:
raise GitHubError(response) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_issue_delete_label(self):\n pass",
"def delete(ctx: click.Context, repository_path):\n root_commands.cmd_delete(ctx.obj, repository_path)",
"def repository_delete(ctx: click.Context, repository_name):\n subcommand_repository.cmd_delete(ctx.obj, repository_name)",
"def delete_label(id):\... | [
"0.7348744",
"0.716896",
"0.7127642",
"0.6931051",
"0.6877669",
"0.67660433",
"0.67263836",
"0.67033213",
"0.6610836",
"0.6601114",
"0.6599512",
"0.64673704",
"0.64669335",
"0.64562386",
"0.6455143",
"0.63759565",
"0.6242319",
"0.6198236",
"0.61135364",
"0.60569805",
"0.60212... | 0.8369633 | 0 |
Extracts feature vectors from a given model and dataset and writes them, along with labels, to a file. This function works for any model whose forward() method returns, on any given input x, the pair (prediction on x, feature vector for x) and more generally, any model whose second return value is a feature vector. | def extract_feature_vectors(model, data_loader, parameters, features_file_path):
feature_vectors, label_vectors = [], []
# Set model to evaluation mode
model.eval()
# Show progress bar while iterating over mini-batches
with tqdm(total=len(data_loader)) as progress_bar:
for i, (X_batch, Y_b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_vectors (feat_vec = None, labels = None, file_extension = None):\n\n feat_file_name = 'output/' + file_extension + '.feature'\n label_file_name = 'output/' + file_extension + '.label'\n\n prettyPrint('Saving feature vector file: {0} ... \\n'\n 'Saving Labels file: {1} ... '.format(... | [
"0.6803554",
"0.6240717",
"0.6221068",
"0.6063516",
"0.6009722",
"0.5950848",
"0.5824239",
"0.58020353",
"0.57663727",
"0.57563233",
"0.5755955",
"0.57133436",
"0.5701105",
"0.5675284",
"0.56728137",
"0.56672686",
"0.56518734",
"0.56423616",
"0.56261265",
"0.56195384",
"0.560... | 0.6868015 | 0 |
Returns the average distance between pairs of vectors in a given list of vectors. | def average_distance_between_vectors(vectors, distance):
vectors = numpy.array(vectors)
vectors = vectors - numpy.mean(vectors, axis=0)
vectors = normalize(vectors)
vectors = list(vectors)
average_distance = utils.RunningAverage()
for vector_1, vector_2 in itertools.combinations(vectors, r=2): #... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_vectors(vectors_list):\n return np.mean(vectors_list, axis=0)",
"def compute_average(vec_list):\r\n return np.sum(vec_list, axis = 0)/len(vec_list)",
"def average(cls, vectors):\n return cls.sum(vectors) / len(vectors)",
"def vector_mean(vectors: List[Vector]) -> Vector:\n n = len... | [
"0.7456902",
"0.7266837",
"0.7161427",
"0.66369",
"0.66369",
"0.6613315",
"0.6526983",
"0.6526983",
"0.652161",
"0.652161",
"0.652161",
"0.6493121",
"0.6426592",
"0.641932",
"0.61453825",
"0.6135802",
"0.6098236",
"0.60969055",
"0.60628074",
"0.6040219",
"0.6035585",
"0.601... | 0.8062336 | 0 |
Reads feature vectors and labels from a file and prints information about their clustering properties. Here, we think of the space of feature vectors, and consider a vector v_i to be in cluster j if j is one of the labels for example i. | def analyze_feature_vector_clusters(features_file_path, distance=utils.L2_distance):
feature_vectors, label_vectors = utils.read_feature_and_label_vectors(features_file_path)
logging.info('Building clusters...')
# Map from (integer j) --> (list of indices i such that feature_vectors[i] is in cluster j)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_vectors (file_extension = None):\n \n feat_file_name = 'output/' + file_extension + '.feature'\n label_file_name = 'output/' + file_extension + '.label'\n \n prettyPrint( \"Loading feature vectors and labels from disk ... \", color.CYAN)\n if not os.path.isfile(feat_file_name) or not os.... | [
"0.5931401",
"0.58759993",
"0.5818201",
"0.5670178",
"0.55925786",
"0.5564548",
"0.5553166",
"0.5509292",
"0.5509292",
"0.5505033",
"0.55044186",
"0.5498727",
"0.5490172",
"0.54632276",
"0.54203254",
"0.54109955",
"0.5390733",
"0.5373782",
"0.5334791",
"0.5330502",
"0.5268046... | 0.65529263 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.