query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Example of entry point
def main(args=None): if args is None: args = sys.argv[1:] print('This is the main function of pycharm') """Read the args""" if len(args) > 0: for i in args: print(i) if args[0] == 'create_setup': remove = False if len(args) > 2: if args[2] == '-removeold': remove = True from pymake.tools.create_setup import create_setup create_setup(args[1], remove) else: print('No parameters passed')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entry_point():", "def entry_point():", "def entry_point():", "def main():\n pass", "def main():\n return", "def main(self) -> None:\n pass", "def main() -> None:", "def main() -> None:", "def main() -> None:", "def main() -> None:", "def main(args=None):", "def main(args=...
[ "0.84055316", "0.84055316", "0.84055316", "0.8176242", "0.8088535", "0.80879116", "0.8034941", "0.8034941", "0.8034941", "0.8034941", "0.7982359", "0.7982359", "0.7979266", "0.7979266", "0.7979266", "0.7979266", "0.79315084", "0.7893428", "0.78562397", "0.7752687", "0.7752687...
0.0
-1
Converts an array with WCS to altitude and azimuth coordinates
def getAltAz(arr,header,time,location): soln = wcs.WCS(header) coords = cartesian([arange(arr.shape[1]),arange(arr.shape[0])]) world = soln.wcs_pix2world(coords,0) radec = SkyCoord(ra=world[:,0],dec=world[:,1],frame='icrs',unit='deg') altaz = radec.transform_to(AltAz(obstime=time,location=telescope)) return altaz.alt.deg,altaz.az.deg,coords[:,0],coords[:,1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def offset_to_altaz(xoff, yoff, azimuth, altitude):\n #Deal with situations where offset = 0?\n\n d = sqrt(xoff*xoff+yoff*yoff)\n pos = np.where(d==0)\n d=1e-12 * u.deg # add a very small offset to prevent math errors\n\n q = arctan(d.to(u.rad).value)\n\n sq = sin(q)\n xp1 = xoff * (sq/d)\n ...
[ "0.55827683", "0.544639", "0.5397533", "0.53178024", "0.53166306", "0.52501696", "0.5224251", "0.52204317", "0.5159298", "0.5143273", "0.5093226", "0.5093226", "0.5093226", "0.50815976", "0.50683326", "0.506293", "0.50404876", "0.5039063", "0.501149", "0.5002514", "0.4954378"...
0.6210394
0
Gets all immediate subdirectories of directory
def getsubdir(directory): subdir=[name for name in os.listdir(directory) if os.path.isdir(os.path.join(directory, name))] subdir=['/'+name+'/' for name in subdir if '.' not in name] return subdir
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getImmediateSubdirectories(dir):", "def get_immediate_subdirectories(self, a_dir):\n return [name for name in os.listdir(a_dir)\n if os.path.isdir(os.path.join(a_dir, name))]", "def all_subdirs_of(dir='.'):\n result = []\n for item in os.listdir(dir):\n path = os.path.joi...
[ "0.8456564", "0.7849883", "0.75609636", "0.7355576", "0.72475153", "0.7239605", "0.7224201", "0.7196618", "0.71935165", "0.7171549", "0.7157886", "0.7133028", "0.71121323", "0.71053064", "0.706358", "0.7032585", "0.6998959", "0.69399023", "0.692623", "0.6925599", "0.68778616"...
0.6162301
81
Run source extractor on f, producing a catalogue, and object and background maps
def sexcall(f,ddi,odi,cdi,bdi): # Split to make file name for catalogue, # object map and background map filenames fname = f.split('.fits')[0] # Construct source extractor call objsexcall = 'sex -CATALOG_TYPE ASCII_HEAD -PARAMETERS_NAME photo.param -CATALOG_NAME '+cdi+fname+'.cat'+' -CHECKIMAGE_TYPE OBJECTS -CHECKIMAGE_NAME '+odi+fname+'_objects.fits '+ddi+f baksexcall = 'sex -CATALOG_TYPE ASCII_HEAD -PARAMETERS_NAME photo.param -CATALOG_NAME '+cdi+fname+'.cat'+' -CHECKIMAGE_TYPE BACKGROUND -CHECKIMAGE_NAME '+bdi+fname+'_background.fits '+ddi+f os.system(objsexcall) os.system(baksexcall)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, vcffiles):\n self.vcffilenames = vcffiles\n self.snpsites = {}\n self.snp_positions = {}", "def sources_extraction(image,sextractor_pars):\n\n cat_name, detect_minarea, detect_thresh, analysis_thresh, phot_aperture, satur_level, ZP, gain, pixelScale,seeing,back_type,back...
[ "0.5765961", "0.5687466", "0.5643927", "0.5641508", "0.56028205", "0.5564399", "0.5480887", "0.5477202", "0.53990245", "0.53960085", "0.5374448", "0.5361827", "0.532035", "0.53024715", "0.5297381", "0.52936006", "0.52374905", "0.52320105", "0.5228987", "0.5202783", "0.5200074...
0.51135045
25
Creates a 2D histogram from data given by numpy's histogram
def hist2d(x,y,nbins = 50 ,maskval = 0,saveloc = '',labels=[],slope = 1,sloperr = 0): # Remove NANs and masked values good = where((isnan(x) == False) & (isnan(y) == False) & (x != maskval) & (y != maskval)) x = x[good] y = y[good] # Create histogram H,xedges,yedges = histogram2d(x,y,bins=nbins) # Reorient appropriately H = rot90(H) H = flipud(H) # Mask zero value bins Hmasked = ma.masked_where(H==0,H) # Find average values in y: yavgs = [] ystds = [] xposs = [] for j in range(len(xedges)-1): toavg = where((x > xedges[j]) & (x < xedges[j+1])) xpos = np.mean(x[toavg]) yavg = np.median(y[toavg]) ystd = np.std(y[toavg])/len(y[toavg]) xposs.append(xpos) yavgs.append(yavg) ystds.append(ystd) # Begin creating figure plt.figure(figsize=(12,10)) # Make histogram pixels with logscale plt.pcolormesh(xedges,yedges,Hmasked, norm = LogNorm(vmin = Hmasked.min(), vmax = Hmasked.max()), cmap = plt.get_cmap('Spectral_r')) # Create fit line x-array uplim = nmax(x)+5 dolim = nmin(x)-5 x_range = arange(dolim,uplim) # Plot fit line plt.plot(x_range,slope*x_range,color = 'royalblue',linewidth = 3,label = 'Slope = {0}, Uncertainty = {1}'.format(slope,sloperr)) # Plot average points plt.errorbar(xposs,yavgs,yerr = ystds,fmt = 'D',color='k',markersize = 5) # Set plot limits plt.xlim(dolim+5,uplim-5) plt.ylim(nmin(y),nmax(y)) # Add colourbar cbar = plt.colorbar() # Add labels if labels != []: title,xlabel,ylabel,zlabel = labels plt.xlabel(xlabel) plt.ylabel(ylabel) plt.title(title) cbar.ax.set_ylabel(zlabel) plt.legend(loc = 'best',fontsize = 15) # Save plot if saveloc != '': plt.savefig(saveloc) plt.close() # Return histogram return xedges,yedges,Hmasked
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fast_hist_2d(data, bin_edges):\n # Yes, I've tested this against histogramdd().\n xassign = np.digitize(data[:,0], bin_edges[1:-1]) \n yassign = np.digitize(data[:,1], bin_edges[1:-1])\n nbins = len(bin_edges) - 1\n flatcount = np.bincount(xassign + yassign * nbins, minlength=nbins*nbins)\n ...
[ "0.7927253", "0.71789026", "0.7173408", "0.71437126", "0.70881116", "0.7070723", "0.70457834", "0.6966444", "0.69234824", "0.68995667", "0.6850321", "0.6839149", "0.68292195", "0.6809204", "0.6803134", "0.66806215", "0.66756934", "0.66571724", "0.6654381", "0.66289043", "0.66...
0.0
-1
Convert a hexadecimal string with leading hash into a three item list of values between [0, 1]. E.g. 00ff00 > [0, 1, 0]
def convert_hex_to_rgb(hex_string): hex_string = hex_string.lstrip('#') return [int(hex_string[i:i + 2], 16) / 255.0 for i in (0, 2, 4)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hex_to_RGB(hex_code: str) -> list:\n\n hex_code = hex_code.lstrip('#')\n return [int(hex_code[i:i + 2], 16) for i in (0, 2, 4)]", "def hex_list(self):\r\n return [''.join(['{:02X}'.format(b) for b in data]) for data in self.buffers()]", "def _string_to_bitlist(self, data):\n l = len(dat...
[ "0.6689272", "0.6465506", "0.63749844", "0.63519144", "0.6346904", "0.63243943", "0.62050515", "0.61755127", "0.6154368", "0.615235", "0.61361694", "0.60561454", "0.603794", "0.6002749", "0.60014415", "0.5985288", "0.5950709", "0.5918056", "0.58994037", "0.58917654", "0.58843...
0.625158
6
Return the element of an atom as defined in it's label.
def xd_element(name): try: name = name[:2] except: pass try: covalence_radius[name] except: name = name[0] return name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_item_from_label(self, label):\n idx = self.labels.index(label)\n item = self[idx][0]\n return item", "def get_label(urs):\n return assign_term(urs)[1]", "def findLabel(self, label):\n return self.root._findLabel(label)", "def fromLabel(name):\n return Data.labels...
[ "0.64875007", "0.6234612", "0.6180619", "0.60778284", "0.6046715", "0.60378295", "0.6036052", "0.59951407", "0.59556556", "0.5930658", "0.59231937", "0.58469766", "0.5837059", "0.57520235", "0.5750243", "0.564846", "0.561729", "0.56039554", "0.55868757", "0.5572615", "0.55563...
0.52610904
65
Reads a .FChk file and returns a list containing the charge of the compound, the number of electrons in the compound, the overall lengths of the dipole moment vector and the total HF energy.
def get_compound_properties(path): filepointer = open(path) charge = None NE = None E_HF = None dipole = None read_dipole = False for line in filepointer: if read_dipole: read_dipole = False dipole = [float(value) for value in line.split(' ') if '.' in value] dipole = np.linalg.norm(dipole) elif 'Charge' in line and not charge: charge = line.split(' ')[-1].rstrip('\n') elif 'Number of electrons' in line and not NE: NE = line.split(' ')[-1].rstrip('\n') elif 'Total Energy' in line and not E_HF: E_HF = line.split(' ')[-1].rstrip('\n') elif 'Dipole Moment' in line and not dipole: read_dipole = True if charge and NE and E_HF and dipole: break return [charge, NE, dipole, E_HF]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_forces(self):\n #\"\"\"Read Forces from dftb output file (results.tag).\"\"\"\n\n from ase.units import Hartree, Bohr\n\n myfile = open(os.path.join(self.directory, 'detailed.out'), 'r')\n self.lines = myfile.readlines()\n myfile.close()\n\n # Force line indexes\n...
[ "0.61628425", "0.6071108", "0.5977757", "0.5936052", "0.5908581", "0.5907671", "0.5888301", "0.5856573", "0.5693422", "0.5663114", "0.56423414", "0.5607148", "0.55911905", "0.550648", "0.55034184", "0.5458108", "0.544729", "0.54410064", "0.54253936", "0.5411036", "0.538077", ...
0.5689103
9
Returns the bond order between two atoms.
def bond_order(bondxi, threshold_single_meso=0.0847, # ================================================================ # threshold_meso_double=0.184, #================================================================ threshold_meso_double=0.0847, threshold_double_triple=0.27): if bondxi < threshold_single_meso: order = '1' elif bondxi < threshold_meso_double: order = '1.5' elif bondxi < threshold_double_triple: order = '2' else: order = '3' return order
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bond_order(molecule, bond_index):\n return molecule.GetBondOrder(bond_index)", "def get_bond_order(bond_type):\n if bond_type == 'single':\n return 1\n elif bond_type == 'aromatic':\n return 1.5\n elif bond_type == 'double':\n return 2\n elif bond_type == 'triple':\n ...
[ "0.7267477", "0.66433895", "0.61120665", "0.61120355", "0.5785895", "0.5775953", "0.563049", "0.5494583", "0.5392209", "0.5384048", "0.5254621", "0.52386093", "0.5236131", "0.5225658", "0.52222705", "0.51403373", "0.51322603", "0.5125893", "0.508684", "0.5077968", "0.50548816...
0.5774481
6
Rotates the ADP of 'atom' to match the orientation of 'source_atom.
def rotate_3D(atom, source_atom): from lauescript.cryst.match import get_transform lst2 = [np.array([0, 0, 0]), source_atom.orientation[0], source_atom.orientation[1]] lst1 = [np.array([0, 0, 0]), atom.orientation[0], atom.orientation[1]] matrix = get_transform(lst1, lst2, matrix=True) adp = source_atom.adp['cart_int'] atom.adp['cart_int'] = rotate_adp(adp, matrix)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotation_alignment(referent_shape, current_shape):\n numerator = 0.\n denominator = 0.\n\n for i in range(len(referent_shape.points)):\n numerator += current_shape.points[i, 0] * referent_shape.points[i, 1] - current_shape.points[i, 1] * referent_shape.points[i, 0]\n denominator += curre...
[ "0.54740787", "0.54063845", "0.53933036", "0.5287055", "0.5184366", "0.5183668", "0.5156844", "0.50909144", "0.50790036", "0.50740695", "0.50218683", "0.50043344", "0.499874", "0.49680153", "0.49113643", "0.49104938", "0.4907334", "0.489211", "0.48913074", "0.48873633", "0.48...
0.6927287
0
Calculates the bond distinguishing parameter Xi.
def xi(element1, element2, distance): return (float(covalence_radius[element1]) + float(covalence_radius[element2]) - (0.08 * float(abs(electro_negativ[element1] - electro_negativ[element2]))) - distance)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Insurance(Md,X):\n u = X[iu]\n b = Md.b()\n return u/b - u/(1-u+u*b)", "def Insurance(Md,X):\n if VERSION == 16:\n utemp = 0.0*X[iu]+1.0*Md.ubar\n elif VERSION == 31:\n utemp = 1.25*(X[iu]-Md.ubar)+1.0*Md.ubar\n else:\n utemp = X[iu]\...
[ "0.5771887", "0.5497939", "0.5485339", "0.54537404", "0.5412243", "0.52982736", "0.5246974", "0.5218475", "0.5195119", "0.51869047", "0.5173168", "0.5159012", "0.5122866", "0.51090294", "0.5108821", "0.509033", "0.5054854", "0.5019761", "0.50018966", "0.4988922", "0.49803066"...
0.50392056
17
Function to identify atoms belonging to a previosly defined rigid group.
def framework_crawler(atom, direction, rigid_group_old=None): if not rigid_group_old: rigid_group = [atom, direction] else: rigid_group = rigid_group_old for atom in get_framework_neighbours(direction): if not atom in rigid_group and not atom.element == 'H': rigid_group.append(atom) framework_crawler(rigid_group[0], atom, rigid_group) if not rigid_group_old: #======================================================================= # print ' Determined rigid group:', [i.name for i in rigid_group] #======================================================================= return rigid_group
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_group(group):\n # Get the true classification from the longest reads\n true_species = group[group['file'].eq(f'OG_reads_{sample_letter}')]['classification'].iloc[0]\n print(true_species)\n # return a 1 if it's true across the group and 0 if not\n group['positives']= np.where(group['classif...
[ "0.53478336", "0.526648", "0.52470756", "0.5181944", "0.51471263", "0.51189107", "0.50924", "0.50924", "0.5078987", "0.5077038", "0.505254", "0.4997841", "0.4995758", "0.49540886", "0.49455371", "0.49252045", "0.49165574", "0.48953816", "0.48634696", "0.48486274", "0.48388016...
0.52450806
3
Returns the atom with the shortest distance to the given atom.
def get_closest_atom_of_element(element, atom, exclude=None): for atom2 in atom.partner: if (element == atom2.element or not element) and not atom2 == exclude: return atom2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest_distance_to(self, pt):\n return self._nearest_to_point(pt)[0]", "def _minimum_distance(self,arg):\n return min([abs(arg-e) for e in self if not e is arg])", "def get_min_distance(self, node):\r\n if self.have_min_distance(node):\r\n return self.table[node][\"dist\"]...
[ "0.6927831", "0.637707", "0.6341551", "0.6167055", "0.61642516", "0.60590255", "0.59727126", "0.595667", "0.59553444", "0.5929634", "0.5880962", "0.5837155", "0.58368987", "0.5720252", "0.5698188", "0.56682664", "0.5647115", "0.56391704", "0.56333494", "0.5632058", "0.5616186...
0.5314012
39
Needs a ATOM.atom instance as argument. Returns the names of the framework atoms bound to that atom.
def get_framework_neighbours(atom, useH=True): neighbourlist = [] for atom2 in atom.partner[:5]: #if not 'H(' in atom2.name and np.linalg.norm(atom.cart-atom2.cart)<=1.6: if np.linalg.norm(atom.cart - atom2.cart) <= float(covalence_radius[atom.element]) + float( covalence_radius[atom2.element]) + .1: if not 'H' == atom2.element or useH: neighbourlist.append(atom2) return neighbourlist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_atom_labels(self, full=False):\n import numpy\n\n labels = self.get_attr(\"atom_labels\")\n if full:\n return labels\n return numpy.array(labels)[self._get_equivalent_atom_list()].tolist()", "def getAtomNames(self):\n return self._raw_data['ATOM_NAME']", "d...
[ "0.5786468", "0.5760434", "0.5465059", "0.54395527", "0.5285232", "0.52612984", "0.52286106", "0.5170458", "0.5095022", "0.5048037", "0.5035679", "0.5034012", "0.49822837", "0.49687123", "0.4942803", "0.49194297", "0.49104977", "0.49047342", "0.4869437", "0.48587328", "0.4852...
0.45080042
97
Reads the measured ADP from the xd.res file. The parameters are stored in atom.adp['frac_meas'] and atom.adp['cart_meas']
def read_meas_adp(data, path='xd.res', use='meas'): use2 = 'frac_' + use switch = False filepointer = open(path, 'r') atomname = None for line in filepointer: if switch: split = [i for i in line.split(' ') if len(i) > 0] if not len(split) == 6: print('WARNING!!! Inconsistend number of floats while\ reading measured ADP.') data['exp'][atomname].adp[use2] = split switch = False if '(' in line: split = [i for i in line.split(' ') if len(i) > 0] if split[0][-1] == ')': switch = True atomname = split[0] use = 'cart_' + use for atom in data['exp'].atoms: # if use == 'cart_neut': print(atom) atom.adp[use] = rotate_adp2(atom.adp[use2], atom.molecule.frac2cartmatrix, atom.molecule.cell) return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def R_adp(data):\n printer('S_adp = ?')\n printer('R_adp = | (U_iso_xxx - U_iso_obs) / U_iso_obs |')\n printer('mean = sum((U_iso_xxx - U_iso_obs) / U_iso_obs) / n')\n printer('abs = sum(R_adp) / n\\n')\n printer('(geometric mean is used)\\n')\n\n printer(' | ADP_calc / ADP_obs | APD_tl...
[ "0.58027154", "0.546091", "0.5428187", "0.5426959", "0.5236421", "0.5206721", "0.5204981", "0.5189248", "0.5178479", "0.51778173", "0.51361907", "0.5132914", "0.51140034", "0.51137125", "0.5094768", "0.505379", "0.5024168", "0.49520048", "0.49162722", "0.4861708", "0.48393014...
0.78116286
0
Returns the ADP after reflection on the plane defined by its normal vector 'planev'.
def reflect_adp(adp, planev): M = np.identity(4) M[:3, :3] -= 2.0 * np.outer(planev, planev) M[:3, 3] = (2.0 * np.dot(np.array([0, 0, 0]), planev)) * planev return rotate_adp(adp, M[:3, :3])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plane(self):\n return Plane(Point(0, self.evaluations.exposedWing.edges[2].point1.y, 0), Vector(0, 1, 0),\n hidden=True)", "def GetPlane(plane):\r\n pass", "def get_adp_from_calc(vx, vy, vz):\n ## lx=np.linalg.norm(vx)\n ## ly=np.linalg.norm(vy)\n ## lz=n...
[ "0.6131728", "0.57741225", "0.56889206", "0.56324", "0.55201805", "0.55160964", "0.5514133", "0.5479282", "0.5462305", "0.5436542", "0.52982074", "0.52627504", "0.52521896", "0.5238149", "0.52197284", "0.52163255", "0.51973253", "0.5194445", "0.5152425", "0.5139117", "0.51376...
0.6869817
0
Calculates the tensor representation of ADP from its priciple axis.
def eigenv2tensor(axis): vec = np.ones((3, 3)) vecval = np.ones((3, 3)) for i in xrange(len(axis)): vmag = np.linalg.norm(axis[i]) v = axis[i] / vmag #print v vec[:, i] = v vecval[:, i] = axis[i] adp = np.linalg.solve(vec, vecval) return adp
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ADP (self):", "def get_axis(adp):\n adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])],\n [float(adp[3]), float(adp[1]), float(adp[5])],\n [float(adp[4]), float(adp[5]), float(adp[2])]])\n w, v = np.linalg.eig(adp)\n return [np....
[ "0.6216488", "0.60510916", "0.60209346", "0.58952725", "0.5770266", "0.5735157", "0.55482674", "0.5510566", "0.53965545", "0.5327899", "0.5300603", "0.5298402", "0.52585346", "0.5229013", "0.520525", "0.5193558", "0.51586944", "0.51218873", "0.50987124", "0.5092296", "0.50793...
0.56617206
6
Calculates an ADP in its matrix representation from the three principle axis representing the displacement ellipsoid. The three principle axis of the ellipsoid are needed as arguments. A Matrix representation of the ADP is returned.
def get_adp_from_calc(vx, vy, vz): ## lx=np.linalg.norm(vx) ## ly=np.linalg.norm(vy) ## lz=np.linalg.norm(vz) lx = vx ly = vy lz = vz L = np.matrix([[lx, 0, 0], [0, ly, 0], [0, 0, lz]]) ## Vx=vx/lx ## Vy=vy/ly ## Vz=vz/lz Vx = np.array([1, 0, 0]) Vy = np.array([0, 1, 0]) Vz = np.array([0, 0, 1]) V = np.matrix([[Vx[0], Vy[0], Vz[0]], [Vx[1], Vy[1], Vz[1]], [Vx[2], Vy[2], Vz[2]]]) Vinv = np.linalg.inv(V) #print V,Vinv M = np.dot(np.dot(Vinv, L), V) #print M return M
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def A_coefficients_ellipsoid(v, DD, bDDisDelta=False):\n #v can be given as an array with X/Y/Z cartesian dimensions being the last.\n #\"\"\"\n if bDDisDelta:\n delta=DD\n else:\n delta=Ddelta_ellipsoid(dd)\n #v=_sanitise_v(v)\n #v2=np.square(v)\n #v4=np.square(v2)\n #fact2=n...
[ "0.6180545", "0.5795742", "0.5749824", "0.56150705", "0.55909604", "0.55889744", "0.5540044", "0.5520576", "0.5389443", "0.53017646", "0.52529544", "0.5236133", "0.5234051", "0.52170014", "0.5192699", "0.5171544", "0.51684576", "0.5142525", "0.51380336", "0.5134151", "0.51299...
0.59788334
1
Determines the the quaternion representing the best possible transformation of two coordinate systems into each other using a least sqare approach. This function is used by the get_refined_rotation() function.
def get_best_quaternion(coordlist1, coordlist2): M = np.matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]]) if len(coordlist1) <= len(coordlist2): number = len(coordlist1) else: number = len(coordlist2) for i in xrange(number): aaa = np.matrix(np.outer(coordlist1[i], coordlist2[i])) M = M + aaa N11 = float(M[0][:, 0] + M[1][:, 1] + M[2][:, 2]) N22 = float(M[0][:, 0] - M[1][:, 1] - M[2][:, 2]) N33 = float(-M[0][:, 0] + M[1][:, 1] - M[2][:, 2]) N44 = float(-M[0][:, 0] - M[1][:, 1] + M[2][:, 2]) N12 = float(M[1][:, 2] - M[2][:, 1]) N13 = float(M[2][:, 0] - M[0][:, 2]) N14 = float(M[0][:, 1] - M[1][:, 0]) N21 = float(N12) N23 = float(M[0][:, 1] + M[1][:, 0]) N24 = float(M[2][:, 0] + M[0][:, 2]) N31 = float(N13) N32 = float(N23) N34 = float(M[1][:, 2] + M[2][:, 1]) N41 = float(N14) N42 = float(N24) N43 = float(N34) N = np.matrix([[N11, N12, N13, N14], [N21, N22, N23, N24], [N31, N32, N33, N34], [N41, N42, N43, N44]]) values, vectors = np.linalg.eig(N) w = list(values) quat = vectors[:, w.index(max(w))] quat = np.array(quat).reshape(-1, ).tolist() return quat, max(w)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_best_rotation(q1, q2, allow_reflection = False, only_xy = False):\n if q1.ndim != 2 or q2.ndim != 2:\n raise Exception(\"This only supports curves of shape (N,M) for N dimensions and M samples\")\n\n n = q1.shape[0]\n\n # if only_xy, strip everything but the x and y coordinates of q1 and q...
[ "0.71130097", "0.6103423", "0.60989857", "0.6034236", "0.5984659", "0.5808696", "0.5793859", "0.5789661", "0.57519877", "0.57339966", "0.5732701", "0.56862444", "0.56858575", "0.56503344", "0.563665", "0.5622966", "0.554343", "0.5540692", "0.5537474", "0.55108356", "0.5505729...
0.6384881
1
Returns the rotation matrix equivalent of the given quaternion. This function is used by the get_refined_rotation() function.
def get_rotation_matrix_from_quaternion(q): R = np.matrix([[q[0] * q[0] + q[1] * q[1] - q[2] * q[2] - q[3] * q[3], 2 * (q[1] * q[2] - q[0] * q[3]), 2 * (q[1] * q[3] + q[0] * q[2])], [2 * (q[2] * q[1] + q[0] * q[3]), q[0] * q[0] - q[1] * q[1] + q[2] * q[2] - q[3] * q[3], 2 * (q[2] * q[3] - q[0] * q[1])], [2 * (q[3] * q[1] - q[0] * q[2]), 2 * (q[3] * q[2] + q[0] * q[1]), q[0] * q[0] - q[1] * q[1] - q[2] * q[2] + q[3] * q[3]]]) return R
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quaternion_to_rotation_matrix(quaternion):\n\n q_w, q_x, q_y, q_z = quaternion\n sqw, sqx, sqy, sqz = np.square(quaternion)\n norm = (sqx + sqy + sqz + sqw)\n rotation_matrix = np.zeros((3, 3))\n\n # division of square length if quaternion is not already normalized\n rotation_matrix[0, 0] = (...
[ "0.8077829", "0.79751414", "0.7973847", "0.797261", "0.79455817", "0.79306656", "0.79097867", "0.780534", "0.7727341", "0.77201724", "0.77022475", "0.7419111", "0.74067664", "0.7311962", "0.7208562", "0.7142397", "0.71323454", "0.71113116", "0.70910096", "0.7048041", "0.69940...
0.8253612
0
Calculates the geometrical center of a set of points.
def get_geom_center(coordlist): return sum(coordlist) / len(coordlist)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def centre_of_points(list_of_points):\n\n cp = np.average(list_of_points, axis=0)\n return cp", "def pointcenter(x):\n return point(x)", "def center(self):\n points = set()\n for face in self._points:\n points.update(face)\n x_points = [point[0] for point in points]\n ...
[ "0.7816311", "0.7496035", "0.74138576", "0.7411869", "0.735026", "0.73026866", "0.72750986", "0.7227958", "0.7207048", "0.7157561", "0.71556854", "0.7141065", "0.71169", "0.70823437", "0.7073579", "0.70721674", "0.7064834", "0.7059459", "0.70201606", "0.7017879", "0.7004704",...
0.75747705
1
Moves the geometrical center of the atoms in atomlist to the given point.
def move_center_to_point(atomlist, point): for atom in range(len(atomlist)): atomlist[atom] = atomlist[atom] - point return atomlist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recenter(self, point=(0, 0)):\n self.center = Point(*point)", "def centerOn(self, point):\n rect = self.rect()\n x = point.x() - rect.width() / 2.0\n y = point.y() - rect.height() / 2.0\n \n self.setPos(x, y)", "def centerOnPoint(self, point):\n\n inClass = ...
[ "0.70135695", "0.6748774", "0.6072873", "0.60708416", "0.60040206", "0.59520334", "0.5908273", "0.5892884", "0.57873654", "0.5775457", "0.57008934", "0.56635845", "0.5663209", "0.5656083", "0.5635438", "0.5621651", "0.5585128", "0.5584832", "0.5545488", "0.55017734", "0.54478...
0.8722849
0
Rotates the adp with its corresponding rotation matrix.
def rotate_adp_reverse(adp, rotmat): adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])], [float(adp[3]), float(adp[1]), float(adp[5])], [float(adp[4]), float(adp[5]), float(adp[2])]]) rotmatT = np.transpose(rotmat) adp = np.dot(rotmat, adp) adp = np.dot(adp, rotmatT) adp = np.array(adp).flatten().tolist() return [adp[0], adp[4], adp[8], adp[1], adp[2], adp[5]]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_adp(adp, rotmat):\n\n adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])],\n [float(adp[3]), float(adp[1]), float(adp[5])],\n [float(adp[4]), float(adp[5]), float(adp[2])]])\n rotmatT = np.transpose(rotmat)\n adp = np.dot(rotmatT, adp)\n adp...
[ "0.79376036", "0.73167443", "0.73074406", "0.7229753", "0.7113275", "0.7051355", "0.6992302", "0.6686556", "0.66458803", "0.66007537", "0.657009", "0.6538239", "0.6492567", "0.64686793", "0.6467943", "0.6442462", "0.64174455", "0.63961196", "0.6388264", "0.63866466", "0.63760...
0.7127177
4
Rotates the adp with its corresponding rotation matrix.
def rotate_adp(adp, rotmat): adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])], [float(adp[3]), float(adp[1]), float(adp[5])], [float(adp[4]), float(adp[5]), float(adp[2])]]) rotmatT = np.transpose(rotmat) adp = np.dot(rotmatT, adp) adp = np.dot(adp, rotmat) # print '=\n',adp,'\n-------------------------------------------------\n\n\n\n\n\n' adp = np.array(adp).flatten().tolist() return [adp[0], adp[4], adp[8], adp[1], adp[2], adp[5]]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate(mat,angle):\n return np.dot(Mueller.rotator(angle), np.dot(mat, Mueller.rotator(-angle)))", "def rotate_adp2(adp, rotmat, cell):\n adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])],\n [float(adp[3]), float(adp[1]), float(adp[5])],\n [float...
[ "0.73167443", "0.73074406", "0.7229753", "0.7127177", "0.7113275", "0.7051355", "0.6992302", "0.6686556", "0.66458803", "0.66007537", "0.657009", "0.6538239", "0.6492567", "0.64686793", "0.6467943", "0.6442462", "0.64174455", "0.63961196", "0.6388264", "0.63866466", "0.637600...
0.79376036
0
Rotates the adp with its corresponding rotation matrix.
def rotate_adp2(adp, rotmat, cell): adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])], [float(adp[3]), float(adp[1]), float(adp[5])], [float(adp[4]), float(adp[5]), float(adp[2])]]) rotmat = np.linalg.inv(rotmat) rotmatT = np.transpose(rotmat) Nmat = np.matrix([[1 / cell[0], 0, 0], [0, 1 / cell[1], 0], [0, 0, 1 / cell[2]]]) Nmat = np.linalg.inv(Nmat) NmatT = np.transpose(Nmat) adp = np.dot(rotmat, adp) adp = np.dot(adp, rotmatT) adp = np.dot(Nmat, adp) adp = np.dot(adp, NmatT) adp = np.array(adp).flatten().tolist() return [adp[0], adp[4], adp[8], adp[1], adp[2], adp[5]]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_adp(adp, rotmat):\n\n adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])],\n [float(adp[3]), float(adp[1]), float(adp[5])],\n [float(adp[4]), float(adp[5]), float(adp[2])]])\n rotmatT = np.transpose(rotmat)\n adp = np.dot(rotmatT, adp)\n adp...
[ "0.79376036", "0.73167443", "0.7229753", "0.7127177", "0.7113275", "0.7051355", "0.6992302", "0.6686556", "0.66458803", "0.66007537", "0.657009", "0.6538239", "0.6492567", "0.64686793", "0.6467943", "0.6442462", "0.64174455", "0.63961196", "0.6388264", "0.63866466", "0.637600...
0.73074406
2
Rotates the adp with its corresponding rotation matrix.
def rotate_adp3(adp, rotmat, cell): adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])], [float(adp[3]), float(adp[1]), float(adp[5])], [float(adp[4]), float(adp[5]), float(adp[2])]]) rotmati = np.matrix(rotmat) rotmatiT = np.transpose(rotmati) rotmat = np.linalg.inv(rotmat) Nmat = np.matrix([[1 / cell[0], 0, 0], [0, 1 / cell[1], 0], [0, 0, 1 / cell[2]]]) Nmat = np.linalg.inv(Nmat) NmatT = np.transpose(Nmat) adp = np.dot(rotmati, adp) adp = np.dot(adp, rotmatiT) adp = np.dot(Nmat, adp) adp = np.dot(adp, NmatT) adp = np.array(adp).flatten().tolist() return [adp[0], adp[4], adp[8], adp[1], adp[2], adp[5]]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_adp(adp, rotmat):\n\n adp = np.matrix([[float(adp[0]), float(adp[3]), float(adp[4])],\n [float(adp[3]), float(adp[1]), float(adp[5])],\n [float(adp[4]), float(adp[5]), float(adp[2])]])\n rotmatT = np.transpose(rotmat)\n adp = np.dot(rotmatT, adp)\n adp...
[ "0.79376036", "0.73167443", "0.73074406", "0.7127177", "0.7113275", "0.7051355", "0.6992302", "0.6686556", "0.66458803", "0.66007537", "0.657009", "0.6538239", "0.6492567", "0.64686793", "0.6467943", "0.6442462", "0.64174455", "0.63961196", "0.6388264", "0.63866466", "0.63760...
0.7229753
3
Returns a list of coordinates where every position is rotated by the the rotation matrix 'R'.
def rotate_list_by(coordlist, R): for coord in xrange(len(coordlist)): value = np.dot(R, coordlist[coord]) value = np.array(value).reshape(-1, ).tolist() coordlist[coord] = value return coordlist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _rotation_matrix_to_euler_angles(R):\n sy = math.sqrt(R[0, 0] * R[0, 0] + R[1, 0] * R[1, 0])\n\n singular = sy < 1e-6\n\n if not singular:\n x = math.atan2(R[2, 1], R[2, 2])\n y = math.atan2(-R[2, 0], sy)\n z = math.atan2(R[1, 0], R[0, 0])\n else:\n x = math.atan2(-R[1, ...
[ "0.72974885", "0.7189403", "0.7180745", "0.6643963", "0.6516557", "0.65161246", "0.6515442", "0.65101385", "0.64101136", "0.6373137", "0.63658345", "0.63429064", "0.6326192", "0.6319467", "0.6302939", "0.6279795", "0.62754506", "0.6256248", "0.622159", "0.6209498", "0.6200936...
0.7185248
2
Returns the rotation matrix that rotates a vector around the given axis by the given angle using the "EulerRodrigues formula".
def get_3drotation_matrix(axis, angle): angle = angle #*-1 norm = np.linalg.norm(np.array(axis)) if norm > 0: axis /= norm ax, ay, az = axis[0], axis[1], axis[2] cos, sin = np.cos(angle), np.sin(angle) rotmat = np.array([[cos + ax * ax * (1 - cos), ax * ay * (1 - cos) - az * sin, ax * az * (1 - cos) + ay * sin], [ay * ax * (1 - cos) + az * sin, cos + ay * ay * (1 - cos), ay * az * (1 - cos) - ax * sin], [az * ax * (1 - cos) - ay * sin, az * ay * (1 - cos) + ax * sin, cos + az * az * (1 - cos)]]) return rotmat
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotateEuler(axis, angle):\n if(axis == 'Z'):\n return np.array([[cos(angle), -sin(angle),0,0],[sin(angle), cos(angle),0,0],[0,0,1,0],[0,0,0,1]])\n if(axis == 'Y'):\n return np.array([[cos(angle),0,sin(angle),0],[0,1,0,0],[-sin(angle),0,cos(angle),0],[0,0,0,1]])\n if(axis == 'X'):\n ...
[ "0.7911063", "0.788436", "0.7837863", "0.77911395", "0.77726126", "0.77274466", "0.7598185", "0.75942045", "0.753307", "0.7435765", "0.7434122", "0.7428991", "0.74156046", "0.7338308", "0.732471", "0.7321008", "0.7264772", "0.71720546", "0.7159397", "0.71509737", "0.7136716",...
0.7117221
21
Returns the normal vector of a plane defined by the points p1,p2 and p3.
def get_normal_vector_of_plane(p1, p2, p3): v12 = np.array(p1) - np.array(p2) v13 = np.array(p1) - np.array(p3) nvec = np.cross(v12, v13) ## print 'norm: '+str(np.linalg.norm(nvec)) return nvec / np.linalg.norm(nvec)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normal(self) -> Vec:\n # The three points are in clockwise order, so compute differences\n # in the clockwise direction, then cross to get the normal.\n point_1 = self.planes[1] - self.planes[0]\n point_2 = self.planes[2] - self.planes[1]\n\n return Vec.cross(point_1, point_2...
[ "0.7993883", "0.75612503", "0.7551127", "0.75036335", "0.73087484", "0.70266545", "0.6976466", "0.69476783", "0.69432104", "0.68638694", "0.6826915", "0.6760271", "0.67263806", "0.670698", "0.66756666", "0.66190445", "0.65483314", "0.6541516", "0.6535791", "0.6529659", "0.651...
0.88373834
0
Returns a list where every element is a list of three atomnames. The second and third names are the closest neighbours of the first names. The argument is a list as returned by frac_to_cart and the number of neighbours to be returned.
def get_closest_neighbours(atomlist, neighbours=2): print('atomlist', atomlist) neighbourlist = [] for atom in atomlist: listline = [atom[0][0]] dists = [] distsc = [] for partner in atomlist: dists.append(np.linalg.norm(atom[1] - partner[1])) distsc.append(np.linalg.norm(atom[1] - partner[1])) dists.remove(min(dists)) for _ in range(neighbours): if min(dists) < 2.5: listline.append(atomlist[distsc.index(min(dists))][0][0]) dists.remove(min(dists)) #listline.append(atomlist[distsc.index(min(dists))][0][0]) neighbourlist.append(listline) return neighbourlist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_CX_neighbours(list_of_atoms, atom_list):\n my_list = []\n atom_numbers = []\n for atom in list_of_atoms:\n for element in identify_bonds(atom, atom_list):\n if (((element[0].atom_name == \"CX\") or (element[0].atom_name == \"CY\")) and (element[0].atom_number not in atom_numbers...
[ "0.5994788", "0.56360227", "0.56093794", "0.55970883", "0.54962254", "0.54728734", "0.5409299", "0.53933924", "0.5324893", "0.53109133", "0.5306111", "0.5260367", "0.5244169", "0.5237841", "0.5218403", "0.5203575", "0.5183413", "0.5180326", "0.5171642", "0.5169028", "0.514798...
0.67386407
0
Calculates for every atom the distances to all other atoms in atomlist. Returns a list where every element is a list of all distances.
def calculate_distance_matrix(atomlist): distlist = [] for atom in atomlist: atomdict = {} for partner in atomlist: if not str(int(partner[0][1])) in atomdict.keys(): atomdict[str(int(partner[0][1]))] = [] atomdict[str(int(partner[0][1]))].append(np.linalg.norm(atom[1] - partner[1])) else: atomdict[str(int(partner[0][1]))].append(np.linalg.norm(atom[1] - partner[1])) atomdict[str(int(partner[0][1]))].sort() distlist.append(atomdict) return distlist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _compute_distances(self, atoms: List[CellAtom]):\n muon = self._cell_atoms[self._muon_index]\n\n for atom in atoms:\n atom.distance_from_muon = np.linalg.norm(muon.position - atom.position)", "def calcDistanceList(work_list):\n distance_list = []\n for swap in work_list...
[ "0.73647845", "0.7127275", "0.7080569", "0.67939436", "0.66801125", "0.66210407", "0.6395463", "0.6352536", "0.60293406", "0.59641975", "0.5953034", "0.5883599", "0.5874572", "0.5861031", "0.5844821", "0.5841001", "0.5830898", "0.5818882", "0.5806686", "0.57949203", "0.578432...
0.78830993
0
The function is able to identify equal atoms of one molecule in different coordinate systems independent of the molecule's orientaion.
def link_atoms_by_distance(distlist1, atomlist1, distlist2, atomlist2, keys): hitlist = [] for atom in distlist1: atomtype = int(atomlist1[distlist1.index(atom)][0][1]) valuelist = [] for partner in distlist2: partnertype = int(atomlist2[distlist2.index(partner)][0][1]) if atomtype == partnertype: partnervalue = 0 keylist = partner.keys() for key in keylist: for element in xrange(len(atom[key])): partnervalue += abs(atom[key][element] - partner[key][element]) else: partnervalue = 9999999 valuelist.append(partnervalue) minvalue = min(valuelist) besthit = valuelist.index(minvalue) hitlist.append(besthit)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_isomorphic_general(self):\n # check that hill formula fails are caught\n ethanol = create_ethanol()\n acetaldehyde = create_acetaldehyde()\n assert ethanol.is_isomorphic_with(acetaldehyde) is False\n assert acetaldehyde.is_isomorphic_with(ethanol) is False\n # che...
[ "0.6392542", "0.63092023", "0.6111575", "0.6041727", "0.6018316", "0.6011343", "0.60099506", "0.6008797", "0.5996518", "0.59733444", "0.5879561", "0.58772373", "0.586719", "0.58652085", "0.5841096", "0.58306956", "0.58160913", "0.5800217", "0.5774613", "0.5731002", "0.5731002...
0.0
-1
Determines the atoms defining the chemical enviroment of a given atom by checking their bonding partners. Only the first and second neighbours are considered.
def get_influence_atoms(atomlist): enviromentlist = [] trunclist = [] neighbourlist = get_closest_neighbours(atomlist, 4) for neighbours in neighbourlist: if neighbours[0][0] == "H": neighbours = neighbours[:2] if neighbours[0][0] == "O": neighbours = neighbours[:3] trunclist.append(neighbours) for atom in trunclist: newatom = [] for atom1partner in atom[1:]: for partner in trunclist: if partner[0] == atom1partner: counter = 0 for atomi in partner: if atomi[0] == 'H': counter += 1 if counter < 2 or (partner[0] in atom and atom[0][0] == 'H'): newatom += atom + partner[1:] newatom = make_list_unique(newatom) newatom.sort() enviromentlist.append(newatom) return enviromentlist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def identify_bonds(chosen_atom, atom_list):\n list_of_hydrogens = ['H15', 'H14', 'H13', 'H12', 'H11', 'H10', 'H9', 'H8', 'H7', 'H6', 'H5', 'H4', 'H3', 'H2', 'H1'] \n if ((chosen_atom.atom_name not in list_of_hydrogens) and (chosen_atom.residue_name != \"P1A\")):\n nearby_atoms_crude = [atom for ato...
[ "0.6319188", "0.6093581", "0.6006863", "0.5989993", "0.592804", "0.59155035", "0.58293885", "0.56470066", "0.5599455", "0.5575535", "0.5540133", "0.54949856", "0.5488254", "0.54558873", "0.54485685", "0.5412311", "0.54049903", "0.5360718", "0.5342761", "0.5333482", "0.5312497...
0.60876876
2
The function is able to identify equivalent atoms in different molecules in different coordinate systems independent of the molecule's orientaion.
def link_atoms_by_distance_diff(distlist1, atomlist1, distlist2, atomlist2, keys): hitlist = [] for atom in distlist1: atomtype = int(atomlist1[distlist1.index(atom)][0][1]) valuelist = [] for partner in distlist2: partnertype = int(atomlist2[distlist2.index(partner)][0][1]) if atomtype == partnertype: partnervalue = 0 keylist = partner.keys() for key in keylist: for element in xrange(len(atom[key])): value = abs(atom[key][element] - partner[key][element]) partnervalue += value else: partnervalue = 9999999 valuelist.append(partnervalue) minvalue = min(valuelist) besthit = valuelist.index(minvalue) hitlist.append(besthit)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_molecules_match_after_remap(self, mol1, mol2):\n for atoms in zip(mol1.atoms, mol2.atoms):\n assert atoms[0].to_dict() == atoms[1].to_dict()\n # bonds will not be in the same order in the molecule and the atom1 and atom2 indecies could be out of\n # order ...
[ "0.6269365", "0.62579566", "0.6199401", "0.619143", "0.6133642", "0.6082986", "0.6040619", "0.59960866", "0.59847355", "0.5943765", "0.59333813", "0.58742005", "0.5850207", "0.5810267", "0.5768853", "0.5726057", "0.5721131", "0.5681214", "0.5680995", "0.5673212", "0.5653497",...
0.0
-1
Calls read_coordinates and frac_to_cart for every path=name in fragmentnames and returns a dictionary where every returnvalue of frac_to_cart is keyed to its fragment name.
def read_multiple_coordinates(fragmentnames): fragdict = {} for name in fragmentnames: path = name + '/' cell, pos = read_coordinates(path) atomlist = frac_to_cart(cell, pos) atomdict = {} for atom in atomlist: atomdict[atom[0][0]] = atom[1] fragdict[name] = atomlist return fragdict
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_files():\n with open(\"CvixLerC9.loc\") as loc, open(\"CvixLerC9.qua\") as qua:\n qua_file = (qua.read().split('\\n'))\n qua_file = qua_file[8:-1]\n new_qua = []\n for q in qua_file:\n new_qua.append(q.split('\\t')) # [['1', '1.279502474'], ['3', '0.303712231'].....
[ "0.5323081", "0.511978", "0.50651133", "0.50311476", "0.4981396", "0.4981396", "0.49392763", "0.49328926", "0.49008498", "0.48904055", "0.48638704", "0.48584062", "0.48568657", "0.48379332", "0.4833694", "0.48149553", "0.47972798", "0.47770527", "0.47520956", "0.47463682", "0...
0.7859618
0
Returns the compound name and the cell parameters from a xd.mas style file specified by 'path'.
def read_xd_master_file(path, errorpointer): filepointer = open(path, 'r') for line in filepointer.readlines(): if 'TITLE' in line: compound_name = line.partition('!')[2].lstrip().rstrip() if 'CELL' in line: cell = [float(i) for i in line.split(" ") if '.' in i] break filepointer.close() try: return compound_name, cell except: errorpointer.write(path + '\n') return None, None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_compound_properties(path):\n filepointer = open(path)\n charge = None\n NE = None\n E_HF = None\n dipole = None\n read_dipole = False\n for line in filepointer:\n if read_dipole:\n read_dipole = False\n dipole = [float(value) for value in line.split(' ') if...
[ "0.6235567", "0.61867106", "0.5885496", "0.5595712", "0.5569049", "0.5382577", "0.5362518", "0.53287804", "0.5324073", "0.53078204", "0.52826846", "0.52695364", "0.52454114", "0.51977813", "0.5176313", "0.5159904", "0.51186925", "0.50939804", "0.5091242", "0.5027156", "0.4991...
0.65298444
0
Reads the cell parameters from a 'xd.mas' file and the atomic positions from a 'xd.res' file. The function returns a list with the cell parameters and an dictionary which keys the atom name to its fractional coordinates.
def read_coordinates(path='', sort=True): maspointer = open(path + 'xd.mas', 'r') respointer = open(path + 'xd.res', 'r') positions = {} keylist = [] #Needed to keep the atomlist order. This is important for the frequency read function. for line in maspointer.readlines(): if 'CELL ' in line: cell = [float(i) for i in line.split(" ") if '.' in i] break for line in respointer.readlines(): if '(' in line and not '!' in line: coords = [float(i) for i in line.split(" ") if '.' in i] coords = coords[:-1] key = line.split(" ")[0] keylist.append(key) positions[key] = coords if sort: sortkeylist = [] for i in xrange(len(keylist)): j = i + 1 for key in keylist: number = get_number(key) if j == int(number): sortkeylist.append(key) else: sortkeylist = keylist return cell, positions, sortkeylist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_xyz(filename):\n\n config = {}\n\n with open(filename, 'r') as f:\n # number of atoms (spins)\n config['nat'] = int(re.findall('\\S+', f.readline())[0])\n\n # box parameters (type, dimension, shape, periodicity)\n sarr = re.findall('\\S+', f.readline())\n config['l...
[ "0.62354904", "0.6009959", "0.57815313", "0.57030374", "0.5664513", "0.5592775", "0.5527532", "0.5496724", "0.5496124", "0.5451055", "0.5448297", "0.53548825", "0.5279107", "0.52720135", "0.526696", "0.5173193", "0.5169754", "0.5153554", "0.5111259", "0.51051176", "0.5093884"...
0.68994904
0
Returns the number in the brackets of an atomname.
def get_number(atomname): switch = False number = '' for char in atomname: if char == ')': switch = False if switch: number += char if char == '(': switch = True return number
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def atomic_number(name):\n try:\n return symbols.index(name.capitalize()) + 1\n except ValueError:\n return lower_names.index(name.lower()) + 1", "def getNameIndex(name):\n try:\n location = len(name) - \"\".join(reversed(name)).index(\".\")\n index = int(name[location:])\n ...
[ "0.7131723", "0.6602477", "0.6242266", "0.6130583", "0.6037743", "0.5923889", "0.58768123", "0.5873613", "0.5861094", "0.5821463", "0.58060014", "0.5772363", "0.5768761", "0.5733707", "0.5732828", "0.5719784", "0.56835663", "0.56269145", "0.5624526", "0.5605099", "0.5601558",...
0.78789806
0
Transforms a set of given fractional coordinates to cartesian coordinates. Needs a list containing the cell parameters as its first argument and the dictionary returned by read coordinates(). Returns a dictionary with cartesian coordinates analog to fractional dictionary.
def frac_to_cart(cell, positions): atomlist = [] counter = 1 a, b, c = cell[0], cell[1], cell[2] alpha, beta, gamma = cell[3] / 180 * np.pi, cell[4] / 180 * np.pi, cell[5] / 180 * np.pi v = np.sqrt(1 - np.cos(alpha) * np.cos(alpha) - np.cos(beta) * np.cos(beta) - np.cos(gamma) * np.cos(gamma) \ + 2 * np.cos(alpha) * np.cos(beta) * np.cos(gamma)) transmatrix = np.matrix([[a, b * np.cos(gamma), c * np.cos(beta)], [0, b * np.sin(gamma), c * (np.cos(alpha) - np.cos(beta) * np.cos(gamma)) / np.sin(gamma)], [0, 0, c * v / np.sin(gamma)]]) for atom in positions: coordmatrix = np.dot(transmatrix, positions[str(atom)]) coordmatrix = np.array(coordmatrix).flatten().tolist() atomlist.append([]) atomlist[-1].append([atom, atomtable[atom[0]]]) counter += 1 atomlist[-1].append(np.array(coordmatrix)) return atomlist
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def frac2cart_all(frac_coordinates, lattice_array):\n coordinates = deepcopy(frac_coordinates)\n for coord in range(coordinates.shape[0]):\n coordinates[coord] = cartisian_from_fractional(coordinates[coord],\n lattice_array)\n return coordinates...
[ "0.5961069", "0.5903401", "0.5892975", "0.5871701", "0.5760852", "0.57279056", "0.5697128", "0.56781834", "0.563091", "0.56191087", "0.5551498", "0.54956114", "0.5457087", "0.5442877", "0.5397851", "0.5384462", "0.5377413", "0.53385407", "0.53186697", "0.5285104", "0.52689", ...
0.49380758
52
Keys the coordinates of the atoms read from xd.res to the numerical part of its name.
def list_to_dict(atomlist, full=False): atomdict = {} if full: for atom in atomlist: atomdict[atom[0]] = atom[1] else: for atom in atomlist: atomdict[atom[0][0]] = atom[1] return atomdict
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_coordinates(path='', sort=True):\n maspointer = open(path + 'xd.mas', 'r')\n respointer = open(path + 'xd.res', 'r')\n\n positions = {}\n keylist = [] #Needed to keep the atomlist order. This is important for the frequency read function.\n for line in maspointer.readlines():\n if 'C...
[ "0.6195289", "0.5910004", "0.5743342", "0.57411754", "0.5721014", "0.5695221", "0.5674487", "0.5631202", "0.55479956", "0.5417099", "0.5406426", "0.5400523", "0.53862077", "0.535987", "0.53320104", "0.52723056", "0.5238446", "0.5231852", "0.522691", "0.520619", "0.52059865", ...
0.0
-1
Returns the angle between two vectors.
def get_angle(v1, v2): return np.arccos(np.dot(v1, v2))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angle_between_vectors(a, b):\n return math.acos(dot_product(a, b) / (length(a) * length(b)))", "def angle_between_vectors(vec1, vec2):\n vec = vec1 - vec2\n vec = vec.perpendicular()\n return vec.angle", "def angle(v1: Vector, v2: Vector) -> float:\n return math.degrees(math.acos((v1 * v2) /...
[ "0.8752359", "0.8643369", "0.8583145", "0.85778534", "0.8426674", "0.83578736", "0.8332106", "0.825163", "0.8241473", "0.82317245", "0.8202834", "0.8093871", "0.80870366", "0.8080988", "0.8072849", "0.8057119", "0.80453193", "0.8017723", "0.80015993", "0.7964633", "0.79558647...
0.80805355
14
Create and init a conv1d layer with spectral normalization
def _conv1d_spect(ni, no, ks=1, stride=1, padding=0, bias=False): conv = nn.Conv1d(ni, no, ks, stride=stride, padding=padding, bias=bias) nn.init.kaiming_normal_(conv.weight) if bias: conv.bias.data.zero_() return spectral_norm(conv)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def V1_init(layer, size, spatial_freq, center=None, scale=1., bias=False, seed=None, tied=False):\n classname = layer.__class__.__name__\n assert classname.find('Conv2d') != -1, 'This init only works for Conv layers'\n\n out_channels, in_channels, xdim, ydim = layer.weight.shape\n data = layer.weight.d...
[ "0.6902533", "0.6492409", "0.6420767", "0.6415407", "0.63521636", "0.62814677", "0.62803644", "0.6270748", "0.6245793", "0.6226488", "0.607607", "0.6073126", "0.5975672", "0.59554344", "0.5911507", "0.59033775", "0.58964217", "0.58664775", "0.5841798", "0.58339804", "0.582184...
0.74178046
0
Helper function that returns dedicated directory for Post media. This organizes user uploaded Post content and is used by `ministry.models.Post.attachment` to save uploaded content. Arguments =========
def post_media_dir(instance, filename, prepend=settings.MEDIA_ROOT): if instance.ministry: _ministry = instance.ministry elif instance.campaign: _ministry = instance.campaign.ministry else: e = 'There was an unknown error finding a dir for %s' % instance.title raise AttributeError(e) return path.join(generic_media_dir(_ministry, prepend=prepend), 'post_media', filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_dir(self):\n return os.path.join(settings.MEDIA_ROOT,self.upload_dir_rel())", "def get_media_directory():\n\treturn _paths[_MEDIA_DIRECTORY_KEY]", "def public_upload_dir(self):\n return os.path.join(settings.MEDIA_ROOT,\n self.public_upload_dir_rel())", "de...
[ "0.6631069", "0.6379418", "0.63036174", "0.61629796", "0.6003821", "0.5945193", "0.58830917", "0.58586687", "0.5771684", "0.5700648", "0.5641766", "0.56303585", "0.55782616", "0.5443347", "0.543865", "0.53991973", "0.5380151", "0.5379563", "0.53412217", "0.5281436", "0.527181...
0.6963208
0
Utility function that creates a dedicated directory for Post media. Arguments =========
def create_news_post_dir(instance, prepend=settings.MEDIA_ROOT): for _ in (post_media_dir,): _path = path.split(_(instance, "", prepend=prepend))[0] try: mkdir(_path) except FileExistsError: pass except FileNotFoundError: if instance.ministry: _ministry = instance.ministry elif instance.campaign: _campaign = instance.campaign _ministry = _campaign.ministry else: e = 'There was an unknown error finding a dir for %s' % instance.name raise AttributeError(e) # NOTE: this is infinitely recursive if `prepend` does not lead to correct directory create_news_post_dir(instance, prepend=prepend)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_media_dir(instance, filename, prepend=settings.MEDIA_ROOT):\n if instance.ministry:\n _ministry = instance.ministry\n elif instance.campaign:\n _ministry = instance.campaign.ministry\n else:\n e = 'There was an unknown error finding a dir for %s' % instance.title\n rai...
[ "0.7129349", "0.6599995", "0.65848666", "0.6278641", "0.6270782", "0.62637275", "0.621008", "0.6079701", "0.60781497", "0.6029266", "0.6018568", "0.6013729", "0.5994422", "0.5988125", "0.5982215", "0.59778285", "0.5950593", "0.59488165", "0.59399545", "0.59338474", "0.5907977...
0.73629373
0
Roundtrip to check what we serialise is what we get back.
def test_serialises_and_deserialises_hs00_message_correctly_for_full_1d_data(self): original_hist = { "source": "some_source", "timestamp": 123456, "current_shape": [5], "dim_metadata": [ { "length": 5, "unit": "m", "label": "some_label", "bin_boundaries": np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]), } ], "last_metadata_timestamp": 123456, "data": np.array([1.0, 2.0, 3.0, 4.0, 5.0]), "errors": np.array([5.0, 4.0, 3.0, 2.0, 1.0]), "info": "info_string", } buf = serialise_hs00(original_hist) hist = deserialise_hs00(buf) assert hist["source"] == original_hist["source"] assert hist["timestamp"] == original_hist["timestamp"] assert hist["current_shape"] == original_hist["current_shape"] self._check_metadata_for_one_dimension( hist["dim_metadata"][0], original_hist["dim_metadata"][0] ) assert np.array_equal(hist["data"], original_hist["data"]) assert np.array_equal(hist["errors"], original_hist["errors"]) assert hist["info"] == original_hist["info"] assert ( hist["last_metadata_timestamp"] == original_hist["last_metadata_timestamp"] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_dumps(self):\n result = self.mapper.dumps(self.serialization)\n self.mapper.to_dict.assert_called_once_with(\"custom\")\n self.serialization.assert_called_once_with(\n self.mapper.to_dict.return_value\n )\n self.assertIs(result, self.serialization.return_value...
[ "0.65497476", "0.64250165", "0.6318902", "0.6110213", "0.6092596", "0.60524327", "0.6047912", "0.60349566", "0.59723496", "0.59635586", "0.59397215", "0.59294575", "0.59294575", "0.59081197", "0.58982784", "0.58918864", "0.58906686", "0.5878805", "0.58623", "0.5853447", "0.58...
0.0
-1
Roundtrip to check what we serialise is what we get back.
def test_serialises_and_deserialises_hs00_message_correctly_for_minimal_1d_data( self, ): original_hist = { "timestamp": 123456, "current_shape": [5], "dim_metadata": [ { "length": 5, "unit": "m", "label": "some_label", "bin_boundaries": np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]), } ], "data": np.array([1.0, 2.0, 3.0, 4.0, 5.0]), } buf = serialise_hs00(original_hist) hist = deserialise_hs00(buf) assert hist["source"] == "" assert hist["timestamp"] == original_hist["timestamp"] assert hist["current_shape"] == original_hist["current_shape"] self._check_metadata_for_one_dimension( hist["dim_metadata"][0], original_hist["dim_metadata"][0] ) assert np.array_equal(hist["data"], original_hist["data"]) assert len(hist["errors"]) == 0 assert hist["info"] == ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_dumps(self):\n result = self.mapper.dumps(self.serialization)\n self.mapper.to_dict.assert_called_once_with(\"custom\")\n self.serialization.assert_called_once_with(\n self.mapper.to_dict.return_value\n )\n self.assertIs(result, self.serialization.return_value...
[ "0.65497476", "0.64250165", "0.6318902", "0.6110213", "0.6092596", "0.60524327", "0.6047912", "0.60349566", "0.59723496", "0.59635586", "0.59397215", "0.59294575", "0.59294575", "0.59081197", "0.58982784", "0.58918864", "0.58906686", "0.5878805", "0.58623", "0.5853447", "0.58...
0.0
-1
Roundtrip to check what we serialise is what we get back.
def test_serialises_and_deserialises_hs00_message_correctly_for_full_2d_data(self): original_hist = { "source": "some_source", "timestamp": 123456, "current_shape": [2, 5], "dim_metadata": [ { "length": 2, "unit": "b", "label": "y", "bin_boundaries": np.array([10.0, 11.0, 12.0]), }, { "length": 5, "unit": "m", "label": "x", "bin_boundaries": np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]), }, ], "last_metadata_timestamp": 123456, "data": np.array([[1.0, 2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0, 10.0]]), "errors": np.array([[5.0, 4.0, 3.0, 2.0, 1.0], [10.0, 9.0, 8.0, 7.0, 6.0]]), "info": "info_string", } buf = serialise_hs00(original_hist) hist = deserialise_hs00(buf) assert hist["source"] == original_hist["source"] assert hist["timestamp"] == original_hist["timestamp"] assert hist["current_shape"] == original_hist["current_shape"] self._check_metadata_for_one_dimension( hist["dim_metadata"][0], original_hist["dim_metadata"][0] ) self._check_metadata_for_one_dimension( hist["dim_metadata"][1], original_hist["dim_metadata"][1] ) assert np.array_equal(hist["data"], original_hist["data"]) assert np.array_equal(hist["errors"], original_hist["errors"]) assert hist["info"] == original_hist["info"] assert ( hist["last_metadata_timestamp"] == original_hist["last_metadata_timestamp"] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_dumps(self):\n result = self.mapper.dumps(self.serialization)\n self.mapper.to_dict.assert_called_once_with(\"custom\")\n self.serialization.assert_called_once_with(\n self.mapper.to_dict.return_value\n )\n self.assertIs(result, self.serialization.return_value...
[ "0.65497476", "0.64250165", "0.6318902", "0.6110213", "0.6092596", "0.60524327", "0.6047912", "0.60349566", "0.59723496", "0.59635586", "0.59397215", "0.59294575", "0.59294575", "0.59081197", "0.58982784", "0.58918864", "0.58906686", "0.5878805", "0.58623", "0.5853447", "0.58...
0.0
-1
Roundtrip to check what we serialise is what we get back.
def test_serialises_and_deserialises_hs00_message_correctly_for_int_array_data( self, ): original_hist = { "source": "some_source", "timestamp": 123456, "current_shape": [5], "dim_metadata": [ { "length": 5, "unit": "m", "label": "some_label", "bin_boundaries": np.array([0, 1, 2, 3, 4, 5]), } ], "last_metadata_timestamp": 123456, "data": np.array([1, 2, 3, 4, 5]), "errors": np.array([5, 4, 3, 2, 1]), "info": "info_string", } buf = serialise_hs00(original_hist) hist = deserialise_hs00(buf) assert hist["source"] == original_hist["source"] assert hist["timestamp"] == original_hist["timestamp"] assert hist["current_shape"] == original_hist["current_shape"] self._check_metadata_for_one_dimension( hist["dim_metadata"][0], original_hist["dim_metadata"][0] ) assert np.array_equal(hist["data"], original_hist["data"]) assert np.array_equal(hist["errors"], original_hist["errors"]) assert hist["info"] == original_hist["info"] assert ( hist["last_metadata_timestamp"] == original_hist["last_metadata_timestamp"] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_dumps(self):\n result = self.mapper.dumps(self.serialization)\n self.mapper.to_dict.assert_called_once_with(\"custom\")\n self.serialization.assert_called_once_with(\n self.mapper.to_dict.return_value\n )\n self.assertIs(result, self.serialization.return_value...
[ "0.65497476", "0.64250165", "0.6318902", "0.6110213", "0.6092596", "0.60524327", "0.6047912", "0.60349566", "0.59723496", "0.59635586", "0.59397215", "0.59294575", "0.59294575", "0.59081197", "0.58982784", "0.58918864", "0.58906686", "0.5878805", "0.58623", "0.5853447", "0.58...
0.0
-1
Roundtrip to check what we serialise is what we get back.
def test_serialises_and_deserialises_hs00_message_correctly_when_float_input_is_not_ndarray( self, ): original_hist = { "source": "some_source", "timestamp": 123456, "current_shape": [2, 5], "dim_metadata": [ { "length": 2, "unit": "b", "label": "y", "bin_boundaries": [10.0, 11.0, 12.0], }, { "length": 5, "unit": "m", "label": "x", "bin_boundaries": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0], }, ], "last_metadata_timestamp": 123456, "data": [[1.0, 2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0, 10.0]], "errors": [[5.0, 4.0, 3.0, 2.0, 1.0], [10.0, 9.0, 8.0, 7.0, 6.0]], "info": "info_string", } buf = serialise_hs00(original_hist) hist = deserialise_hs00(buf) assert hist["source"] == original_hist["source"] assert hist["timestamp"] == original_hist["timestamp"] assert hist["current_shape"] == original_hist["current_shape"] self._check_metadata_for_one_dimension( hist["dim_metadata"][0], original_hist["dim_metadata"][0] ) self._check_metadata_for_one_dimension( hist["dim_metadata"][1], original_hist["dim_metadata"][1] ) assert np.array_equal(hist["data"], original_hist["data"]) assert np.array_equal(hist["errors"], original_hist["errors"]) assert hist["info"] == original_hist["info"] assert ( hist["last_metadata_timestamp"] == original_hist["last_metadata_timestamp"] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_dumps(self):\n result = self.mapper.dumps(self.serialization)\n self.mapper.to_dict.assert_called_once_with(\"custom\")\n self.serialization.assert_called_once_with(\n self.mapper.to_dict.return_value\n )\n self.assertIs(result, self.serialization.return_value...
[ "0.65497476", "0.64250165", "0.6318902", "0.6110213", "0.6092596", "0.60524327", "0.6047912", "0.60349566", "0.59723496", "0.59635586", "0.59397215", "0.59294575", "0.59294575", "0.59081197", "0.58982784", "0.58918864", "0.58906686", "0.5878805", "0.58623", "0.5853447", "0.58...
0.0
-1
Roundtrip to check what we serialise is what we get back.
def test_serialises_and_deserialises_hs00_message_correctly_when_int_input_is_not_ndarray( self, ): original_hist = { "source": "some_source", "timestamp": 123456, "current_shape": [2, 5], "dim_metadata": [ { "length": 2, "unit": "b", "label": "y", "bin_boundaries": [10, 11, 12], }, { "length": 5, "unit": "m", "label": "x", "bin_boundaries": [0, 1, 2, 3, 4, 5], }, ], "last_metadata_timestamp": 123456, "data": [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], "errors": [[5, 4, 3, 2, 1], [10, 9, 8, 7, 6]], "info": "info_string", } buf = serialise_hs00(original_hist) hist = deserialise_hs00(buf) assert hist["source"] == original_hist["source"] assert hist["timestamp"] == original_hist["timestamp"] assert hist["current_shape"] == original_hist["current_shape"] self._check_metadata_for_one_dimension( hist["dim_metadata"][0], original_hist["dim_metadata"][0] ) self._check_metadata_for_one_dimension( hist["dim_metadata"][1], original_hist["dim_metadata"][1] ) assert np.array_equal(hist["data"], original_hist["data"]) assert np.array_equal(hist["errors"], original_hist["errors"]) assert hist["info"] == original_hist["info"] assert ( hist["last_metadata_timestamp"] == original_hist["last_metadata_timestamp"] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_dumps(self):\n result = self.mapper.dumps(self.serialization)\n self.mapper.to_dict.assert_called_once_with(\"custom\")\n self.serialization.assert_called_once_with(\n self.mapper.to_dict.return_value\n )\n self.assertIs(result, self.serialization.return_value...
[ "0.65497476", "0.64250165", "0.6318902", "0.6110213", "0.6092596", "0.60524327", "0.6047912", "0.60349566", "0.59723496", "0.59635586", "0.59397215", "0.59294575", "0.59294575", "0.59081197", "0.58982784", "0.58918864", "0.58906686", "0.5878805", "0.58623", "0.5853447", "0.58...
0.0
-1
In rare cases, pandas can produce broken datasets when writing to hdf5, this function can be used to delete them so they can be either downloaded again or discarded USE WITH UTTERMOST CARE
def del_sensordata(self): organisation_id = '5af01e0210bac288dba249ad' animal_id = '5b6419ff36b96c52808951b1' with self.writefile() as file: del file[f'data/{organisation_id}/{animal_id}/sensordata']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_ds(self, dt):\n\n for k in self.datasets_keys:\n for F in self.datasets[k]:\n if F not in data[k].keys():\n continue \n max_date = data[k][F]['max_date'] \n \"\"\" Deleting unec...
[ "0.65211636", "0.65018326", "0.6463773", "0.6445838", "0.6362268", "0.63500494", "0.6349943", "0.63297856", "0.6250076", "0.6238", "0.62326133", "0.6211138", "0.61991334", "0.61900306", "0.61059207", "0.60499495", "0.6021087", "0.6016084", "0.5999302", "0.5968676", "0.5964416...
0.57039887
40
Fixture for client object passed as an argument to the test functions
def client(): client = Client() return client
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_for_client():", "def test_create_client(self):\n pass", "def test_client_create(self):\n pass", "def setUp(self):\n self.client = DummyClient()", "def test_client_retrieve(self):\n pass", "def setUp(self):\n self.client = Client()", "def setUp(self):\n ...
[ "0.754755", "0.74860317", "0.73783517", "0.7377558", "0.73457175", "0.73118144", "0.73118144", "0.73118144", "0.73118144", "0.73099387", "0.7090056", "0.6969668", "0.69263554", "0.69252616", "0.6855763", "0.67790884", "0.6763768", "0.66879356", "0.66879356", "0.66879356", "0....
0.0
-1
Fixture for user object passed as an argument to the user create view test function
def user(): user = User.objects.create(name='Janek', surname='Kowalski', internal_id='PUHgjdJ', is_administrator=True, is_payment_creator=True, is_payment_approver=False, can_delete_payment=True) return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_user_creation(self):\r\n \r\n self.assertIsInstance(self.user, User)", "def test_create_user(self):\n pass", "def test_create_user(self):\n pass", "def test_create_user(self):\n pass", "def test_user():\n user_data = {\n \"name\": \"Brad\",\n \"u...
[ "0.7581336", "0.7469687", "0.7469687", "0.7469687", "0.74045193", "0.7388603", "0.71562016", "0.7155055", "0.7099242", "0.69998574", "0.6995502", "0.6981704", "0.6978693", "0.6965282", "0.69559574", "0.6923249", "0.6908104", "0.6863743", "0.68313307", "0.68313307", "0.6827611...
0.0
-1
Fixture for company object passed as an argument to the company create view test function
def company(): company = Company.objects.create(name='Tre G.M.B.H.', country='Germany') return company
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_website_companies_create(self):\n pass", "def test_create_company_1(self):\n company_data = {\n \"_id\": \"sbucks\",\n \"headquarters\": \"Seattle\",\n \"name\": \"Starbucks Inc.\",\n }\n\n resp = self.app.post('/companies', data=json.dumps(co...
[ "0.7572055", "0.6949927", "0.6910108", "0.6783742", "0.6782509", "0.6768939", "0.6648319", "0.64719594", "0.62653613", "0.62246877", "0.61053544", "0.60505855", "0.604088", "0.60324633", "0.5979618", "0.5958282", "0.59542584", "0.5907634", "0.58789223", "0.58328825", "0.58327...
0.662038
7
Fixture for admin object passed as an argument to the admin create view test function
def administrator(): administrator = Administrator.objects.create(name='Michał', surname='Paluch', login='Udfsr43', password='Password_3', password_repeat='Password_3') return administrator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_admin(self):\n assert(admin)", "def test_an_admin_view(admin_client):\n response = admin_client.get('/admin/')\n assert status(response) == 'ok'", "def test_add_admin(self):\n self.test_create_user()\n self.test_create_organization()\n url = reverse('MGA:add_admin')\n...
[ "0.7291503", "0.6833036", "0.6821154", "0.6697566", "0.668051", "0.66122943", "0.64742976", "0.6402408", "0.6336394", "0.63025343", "0.6262725", "0.62581766", "0.62279063", "0.6192794", "0.61778784", "0.61756825", "0.61681473", "0.6146008", "0.6134811", "0.6131507", "0.609376...
0.0
-1
Fixture for bank object passed as an argument to the admin bank view test function
def bank(): bank = Bank.objects.create(name='Random Bank') return bank
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_client_bank_account_retrieve(self):\n pass", "def test_client_bank_accounts_list(self):\n pass", "def test_client_bank_account_create(self):\n pass", "def test_create_virtual_account_beneficiary(self):\n pass", "def test_edit_boat(self):\n pass", "def test_hous...
[ "0.68055016", "0.67185485", "0.65409213", "0.6355551", "0.6263593", "0.6235724", "0.6129963", "0.6102043", "0.6074391", "0.6055766", "0.6043796", "0.60177153", "0.5949179", "0.58791125", "0.58271164", "0.5814391", "0.5790518", "0.5788916", "0.5783457", "0.5749937", "0.5742416...
0.6220651
6
Fixture for account object passed as an argument to the account create view test function
def account(): bank_test = Bank.objects.create(name='R-Bank') company_test = Company.objects.create(name='Tre Belarus', country='Belarus') account = Account.objects.create(iban_number='TEEdddddddfs', swift_code='tertrefdsf', bank=bank_test, company=company_test) return account
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_account(self):\n url = reverse('account:accounts')\n data = {'name': 'Test Account 1'}\n response = self.client.post(url, data, format='json')\n self.assertEqual(response.status_code, status.HTTP_201_CREATED)\n self.assertEqual(Account.objects.count(), 1)\n ...
[ "0.7160241", "0.69238716", "0.6886644", "0.68595505", "0.68389684", "0.681058", "0.6805492", "0.66778797", "0.66131806", "0.66090906", "0.6590591", "0.6572082", "0.6519173", "0.6509788", "0.6508603", "0.6420267", "0.6328433", "0.62413573", "0.62157965", "0.6204515", "0.619508...
0.6343079
16
return a working WLAN(STA_IF) instance or None
def get_connection(ssid,password): # First check if there already is any connection: if wlan_sta.isconnected(): return wlan_sta connected = False try: # ESP connecting to WiFi takes time, wait a bit and try again: time.sleep(3) if wlan_sta.isconnected(): return wlan_sta # Search WiFis in range wlan_sta.active(True) connected = do_connect(ssid,password) except OSError as e: print("exception", str(e)) # start web server for connection manager: # if not connected: # connected = start() return wlan_sta if connected else None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_wifi(self):\n return self._wifi", "def init_wlan_sta():\n\n print('WLAN: STA mode')\n wlan.init(mode=WLAN.STA)\n if not wlan.isconnected():\n wlan.connect(WLAN_SSID, auth=WLAN_AUTH, timeout=5000)\n while not wlan.isconnected():\n machine.idle() # save power while...
[ "0.68340015", "0.63972205", "0.616661", "0.5945816", "0.5928931", "0.5894898", "0.5855707", "0.58045965", "0.56598383", "0.5637595", "0.5623451", "0.5612626", "0.55965465", "0.5566321", "0.5533868", "0.5496373", "0.544632", "0.54028994", "0.5389177", "0.5349265", "0.53430164"...
0.61334884
3
Constructor for object DeleteRenewKeys that reads content from config.json
def __init__(self): # open json config file that reads in information config_path = open("config.json", "r") config_json = config_path.read() config_dict = json.loads(config_json) # assign object variables self.project_id = config_dict["project-id"] self.bucket_name = config_dict["bucket-name"] self.location_id = config_dict["key-location"] self.key_ring_id = config_dict["key-ring-id"] self.crypto_key_id = config_dict["crypto-key-id"] self.service_account_email = config_dict["service-account-email"] # close the file config_path.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n try:\n with open(os.path.expanduser(\"~/.dkeyrc\"), 'r') as f:\n self.__cfgdata = json.load(f)\n except Exception as e:\n print(\"Error: Unable to load config JSON at ~/.dkeyrc -- %s\" % (e))\n sys.exit(1)", "def __init__(self, k...
[ "0.5615627", "0.53399825", "0.53382677", "0.5235249", "0.51820284", "0.5108353", "0.5022169", "0.5007471", "0.49882397", "0.49877107", "0.49747235", "0.49552137", "0.49455333", "0.49418396", "0.49205673", "0.49144816", "0.48787165", "0.48667872", "0.48570824", "0.48304826", "...
0.52679664
3
Decrypts input ciphertext using a symmetric CryptoKey.
def decrypt_symmetric(self, ciphertext): from google.cloud import kms_v1 # Creates an API client for the KMS API. client = kms_v1.KeyManagementServiceClient() # The resource name of the CryptoKey. name = client.crypto_key_path_path(self.project_id, self.location_id, self.key_ring_id, self.crypto_key_id) # Use the KMS API to decrypt the data. response = client.decrypt(name, ciphertext) return response.plaintext
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decrypt_symmetric(secret_key, ciphertext, ttl=None):\n f = Fernet(secret_key)\n # fernet requires the ciphertext to be bytes, it will raise an exception\n # if it is a string\n return f.decrypt(bytes(ciphertext), ttl)", "def decrypt(priv_key, ciphertext):\n pk_encrypted_secret_key = ciphertext...
[ "0.78190506", "0.76649165", "0.73512477", "0.7301102", "0.72868747", "0.7224076", "0.7158116", "0.7080847", "0.7073697", "0.70620877", "0.7024779", "0.70223695", "0.70039576", "0.7003598", "0.6956859", "0.6855221", "0.6831517", "0.68168175", "0.6813381", "0.679899", "0.678872...
0.8391707
0
Method that decrypts a file using the decrypt_symmetric method and writes the output of this decryption to a file named gcpkey.json
def decrypt_from_file(self, file_path): # open and decrypt byte file f = open(file_path, "rb").read() decrypted = self.decrypt_symmetric(f) json_string = decrypted.decode("utf-8") # write string to json file destination_file_name = Path("downloaded-key/gcp-key.json") destination_file_name.touch(exist_ok=True) # creates file if it does not yet exist destination_file_name.touch(exist_ok=True) # creates file if it does not yet exist destination_file_name.write_text(json_string)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decrypt_symmetric(self, ciphertext):\n from google.cloud import kms_v1\n\n # Creates an API client for the KMS API.\n client = kms_v1.KeyManagementServiceClient()\n\n # The resource name of the CryptoKey.\n name = client.crypto_key_path_path(self.project_id, self.location_id,...
[ "0.64325106", "0.63213474", "0.622638", "0.61633515", "0.61598235", "0.6144704", "0.608841", "0.60840195", "0.6062278", "0.5996128", "0.5985062", "0.59499764", "0.59409845", "0.59369785", "0.5880555", "0.5879515", "0.5877775", "0.58735037", "0.5852493", "0.58381975", "0.58349...
0.801987
0
Downloads key for configured service account and stores it in the folder generatedkey/
def download_key_from_blob(self): source_blob_name = "generated-keys/{}".format(self.service_account_email) destination_name = self.service_account_email # generate destination folder and file if they do not yet exist Path("downloaded-key/").mkdir(parents=True, exist_ok=True) # creates folder if not exists folder = Path("downloaded-key/") # folder where all the newly generated keys go destination_file_name = folder / "{}".format(destination_name) # file named after service-account name destination_file_name.touch(exist_ok=True) # download the file and store it locally storage_client = storage.Client() bucket = storage_client.get_bucket(self.bucket_name) blob = bucket.blob(source_blob_name) blob.download_to_filename(destination_file_name) # prints source and destination indicating successful download print('Encrypted key downloaded to -----> \n {}.'.format( source_blob_name, destination_file_name)) return destination_file_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_key():\n data = check_args(('cloudProvider', ))\n provider = jobs.init_provider(data, True)\n key = encrypt_key(provider.get_key(), data['username'])\n return make_response(keyName=provider.keyname, key=key)", "def generate_key():\r\n # generating key\r\n key = Fernet.generate_key(...
[ "0.7312609", "0.6830154", "0.6603424", "0.6562619", "0.6516955", "0.6498773", "0.6481392", "0.64763385", "0.64518285", "0.6347369", "0.6296295", "0.6269412", "0.62465113", "0.6237751", "0.61916953", "0.61603403", "0.6143181", "0.6117199", "0.61056596", "0.6093765", "0.6090465...
0.803482
0
main method that executes the workings of the script
def main(): print("Reading from config.json") download_decrypt_store = DownloadDecryptStore() print("Downloading key from storage-bucket") file_path = download_decrypt_store.download_key_from_blob() print("Decrypting downloaded file") download_decrypt_store.decrypt_from_file(file_path) print("Completed")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_script(self) -> None:\n main()", "def run():\n main()", "def main():\n run_program()", "def run_script(self):\n pass", "def main():\n pass", "def main():\n return", "def main():\n\n BASIC.run(PROGRAM)", "def main(self) -> None:\n pass", "def main():\...
[ "0.77707267", "0.75500584", "0.75495726", "0.7460941", "0.73748064", "0.73399204", "0.7278216", "0.72609", "0.72570956", "0.72451305", "0.72448987", "0.72448987", "0.72448987", "0.72448987", "0.72448987", "0.72448987", "0.72448987", "0.72448987", "0.72448987", "0.72448987", "...
0.0
-1
Calculate overlap among trajectories
def trajectory_overlap(gt_trajs, pred_traj): max_overlap = 0 max_index = 0 for t, gt_traj in enumerate(gt_trajs): s_viou = viou_sx(gt_traj['sub_traj'], gt_traj['duration'], pred_traj['sub_traj'], pred_traj['duration']) o_viou = viou_sx(gt_traj['obj_traj'], gt_traj['duration'], pred_traj['obj_traj'], pred_traj['duration']) so_viou = min(s_viou, o_viou) if so_viou > max_overlap: max_overlap = so_viou max_index = t return max_overlap, max_index
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overlap_cost(track_a, track_b):\n return 1 - overlap(track_a.bbox, track_b.bbox)", "def overlap_with(self, other):", "def poverlap(t1, t2, size1, size2):\n x0 = t1[0]\n y0 = t1[1]\n x1 = t1[0] + size1[0]\n y1 = t1[1] + size1[1]\n\n x2 = t2[0]\n y2 = t2[1]\n x3 = t2[0] + size2[0]\n ...
[ "0.70222414", "0.6725737", "0.66626245", "0.6478671", "0.6425438", "0.6360582", "0.63547766", "0.63308674", "0.63305753", "0.6300792", "0.6285758", "0.6278362", "0.6266364", "0.62542456", "0.62484795", "0.6247598", "0.614467", "0.613606", "0.61254627", "0.6118002", "0.6102571...
0.68951005
1
Encodes a list of strings to a single string.
def encode (self, strs): if strs == []: return "null" return chr(257).join(strs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_as_str(list_to_encode, sep = \"|\"):\n return sep.join([str(x) for x in list_to_encode])", "def _encode_list(source: list) -> bytes:\n result_data = b\"l\"\n\n for item in source:\n result_data += encode(item)\n\n return result_data + b\"e\"", "def stringer(list):\n\tstring = \"\"...
[ "0.7459969", "0.74273384", "0.7255417", "0.6790711", "0.67658377", "0.66986156", "0.6680612", "0.6643305", "0.6643305", "0.65740526", "0.6573746", "0.6484516", "0.6398631", "0.6318684", "0.63106364", "0.628163", "0.62610334", "0.62113565", "0.62003165", "0.6199526", "0.619224...
0.7258633
2
Decodes a single string to a list of strings.
def decode (self, s): if s == "null": return [] return s.split(chr(257))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode(self, s):\n lststr = s.split(',')\n if s=='': return []\n rst = []\n for i in range(len(lststr)):\n rst.append(lststr[i])\n return rst", "def parse_string_list(data):\n txt = data.decode()\n x = ast.literal_eval(txt)\n return x", "def _decode_li...
[ "0.7429849", "0.67665714", "0.6603133", "0.6484686", "0.64099807", "0.63982195", "0.63764083", "0.63426924", "0.63409954", "0.6335773", "0.62704915", "0.62629604", "0.6239383", "0.6189524", "0.6171236", "0.6159162", "0.6110307", "0.6100137", "0.6022035", "0.60078084", "0.5990...
0.7317169
1
GameObjects by default don't have agency but they may still do things...
def update(self, dt): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_over(self):\n raise NotImplementedError(\"Abstract method\") # no mercy for stooges", "def object_detection(self):\r\n pass", "def playerdefeated(self):\n globalvalues.gameover_combat()", "def is_actor():\n return False", "def on_collision(self):", "def __init__(self):\n...
[ "0.63586646", "0.58945036", "0.5857092", "0.5510857", "0.54797775", "0.54752845", "0.54633653", "0.54481524", "0.5443868", "0.5428182", "0.5414342", "0.54023975", "0.54023975", "0.5400207", "0.5384979", "0.53770864", "0.53669137", "0.53261596", "0.53248054", "0.52967083", "0....
0.0
-1
sort list of objects randomly then update everything in this world
def update(self, dt): random.shuffle(self.gameObjects) for item in self.gameObjects: description = item.update(dt)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dispatch_items_randomly(self, level):\n for item in self.list:\n item.position = Item.define_random_position(item, level)", "def populate_objects(self):\n if not self._random_object: # only populate the first object\n U.spawn_object(self.object_list[0], self.object_initia...
[ "0.6626622", "0.6585694", "0.6483848", "0.6469369", "0.6035206", "0.6019736", "0.60169244", "0.5968468", "0.5968468", "0.5951621", "0.5919026", "0.59153605", "0.5901477", "0.5880968", "0.58774793", "0.5859918", "0.5817854", "0.58043724", "0.5801076", "0.5794008", "0.5786912",...
0.6854891
0
add this to the world
def add_to_world(self, thing): thing.set_world_info(self.current_id, self) self.gameObjects.append(thing) self.current_id += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_world(self):\n raise NotImplementedError()", "def __init__(self, world):\n self.__init__(world, ArrayList())", "def update_world(self):\n pass", "def __init__(self, world, x, y, direction):\n self.ID = world.__register__(x, y, direction)", "def world(self):\n ret...
[ "0.6970694", "0.6964329", "0.6806117", "0.6598959", "0.64999914", "0.64821887", "0.64505976", "0.6299828", "0.6281762", "0.6269024", "0.62657404", "0.62023485", "0.61991674", "0.6084373", "0.5940955", "0.5922447", "0.58853203", "0.5820223", "0.5784347", "0.57677424", "0.57647...
0.74709004
0
Merge data from another instance of this object.
def merge_stats(self, other): self[0] += other[0] self[1] += other[1] self[2] += other[2] self[3] = ((self[0] or self[1] or self[2]) and min(self[3], other[3]) or other[3]) self[4] = max(self[4], other[3])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(self, other):\n from .dataset import Dataset\n\n if other is None:\n return self.to_dataset()\n else:\n other_vars = getattr(other, 'variables', other)\n coords = merge_coords_without_align([self.variables, other_vars])\n return Dataset._fr...
[ "0.69505", "0.694683", "0.6885921", "0.68476945", "0.68086684", "0.6734038", "0.67226946", "0.66790885", "0.66472447", "0.66369003", "0.6572359", "0.6542647", "0.6503335", "0.65015614", "0.6469766", "0.64362967", "0.64317465", "0.6385473", "0.6376822", "0.6375423", "0.6370342...
0.0
-1
Merge data from an apdex metric object.
def merge_apdex_metric(self, metric): self[0] += metric.satisfying self[1] += metric.tolerating self[2] += metric.frustrating self[3] = ((self[0] or self[1] or self[2]) and min(self[3], metric.apdex_t) or metric.apdex_t) self[4] = max(self[4], metric.apdex_t)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_custom_metrics(self, metrics):\n\n if not self.__settings:\n return\n\n for name, other in metrics:\n key = (name, '')\n stats = self.__stats_table.get(key)\n if not stats:\n self.__stats_table[key] = other\n else:\n ...
[ "0.59747314", "0.59122944", "0.54553163", "0.53186303", "0.52896434", "0.52513325", "0.52353007", "0.5187257", "0.5186104", "0.51808596", "0.5174486", "0.5171695", "0.5140604", "0.51390433", "0.5108755", "0.5096023", "0.50914425", "0.50677156", "0.5052862", "0.50481683", "0.5...
0.69163495
0
Merge data from another instance of this object.
def merge_stats(self, other): self[1] += other[1] self[2] += other[2] self[3] = self[0] and min(self[3], other[3]) or other[3] self[4] = max(self[4], other[4]) self[5] += other[5] # Must update the call count last as update of the # minimum call time is dependent on initial value. self[0] += other[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(self, other):\n from .dataset import Dataset\n\n if other is None:\n return self.to_dataset()\n else:\n other_vars = getattr(other, 'variables', other)\n coords = merge_coords_without_align([self.variables, other_vars])\n return Dataset._fr...
[ "0.69505", "0.694683", "0.6885921", "0.68476945", "0.68086684", "0.6734038", "0.67226946", "0.66790885", "0.66472447", "0.66369003", "0.6572359", "0.6542647", "0.6503335", "0.65015614", "0.6469766", "0.64362967", "0.64317465", "0.6385473", "0.6376822", "0.6375423", "0.6370342...
0.0
-1
Merge data from a time metric object.
def merge_time_metric(self, metric): self.merge_raw_time_metric(metric.duration, metric.exclusive)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def combine(cls, date_obj, time_obj):\n return cls(date_obj.year, date_obj.month, date_obj.day,\n time_obj.hour, time_obj.minute, time_obj.second,\n time_obj.nanosecond)", "def add_time(data, t):\n data['year'] = t.year\n data['month'] = t.month\n data['day'] = t.day\n ...
[ "0.6252038", "0.5991166", "0.5987996", "0.59735656", "0.5910383", "0.5889225", "0.58206046", "0.5819968", "0.5817195", "0.56706285", "0.5599506", "0.55690825", "0.5536235", "0.54553676", "0.5344387", "0.532456", "0.5291916", "0.52320737", "0.52283955", "0.5221072", "0.5202319...
0.69977385
0
Record a single value metric, merging the data with any data from prior value metrics with the same name.
def record_custom_metric(self, name, value): if isinstance(value, dict): if len(value) == 1 and 'count' in value: new_stats = CountStats(call_count=value['count']) else: new_stats = TimeStats(*c2t(**value)) else: new_stats = TimeStats(1, value, value, value, value, value**2) stats = self.__stats_table.get(name) if stats is None: self.__stats_table[name] = new_stats else: stats.merge_stats(new_stats)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log(self, metric_name: str, value: float) -> None:\n if metric_name in self.metrics:\n self.metrics[metric_name].append(value)\n else:\n self.metrics[metric_name] = [value]", "def log_metric(self, name: str, value):\n self.metrics[name] = value\n\n self._sync...
[ "0.72285455", "0.6880584", "0.6831178", "0.67528003", "0.64814395", "0.6404036", "0.6218233", "0.6194534", "0.6135706", "0.60753894", "0.6063926", "0.60352796", "0.59790224", "0.59553665", "0.59262705", "0.589197", "0.58506346", "0.5779258", "0.5770089", "0.5764042", "0.57204...
0.69385666
1
Returns an iterator over the set of value metrics. The items returned are a tuple consisting of the metric name and accumulated stats for the metric.
def metrics(self): return six.iteritems(self.__stats_table)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __iter__(self):\n prefix = len(META_NS) + 2\n for key, value in self.stats.items():\n yield (key[prefix:-6], int(value))", "def get_val_iterator(self) -> Iterable[Batch]:\n if self._val_name not in self._datasets:\n raise ValueError(\"Val data not provided.\")\n ...
[ "0.61560905", "0.6048202", "0.6047815", "0.6044677", "0.6018319", "0.6018319", "0.5974941", "0.59604144", "0.5956948", "0.595421", "0.59379584", "0.58816415", "0.58809036", "0.58738184", "0.5869844", "0.5865912", "0.58568335", "0.5852111", "0.5831421", "0.58237755", "0.579164...
0.66805625
0
Resets the accumulated statistics back to initial state for metric data.
def reset_metric_stats(self): self.__stats_table = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n self.sum_metric = 0.\n self.num_inst = 0.\n self.metrics.reset_stats()", "def reset_metric_stats(self):\n\n self.__stats_table = {}", "def stats_reset(self):\n self.stats.reset()", "def stats_reset(self):\n self.stats.reset()", "def reset(self) -...
[ "0.8448358", "0.84143066", "0.83299094", "0.83299094", "0.8270503", "0.8153123", "0.79735655", "0.7772603", "0.77270293", "0.77003264", "0.76665866", "0.7614711", "0.75709176", "0.7540221", "0.75036174", "0.75036174", "0.7490715", "0.7471787", "0.74488425", "0.74488425", "0.7...
0.83412653
2
Merge data from another instance of this object.
def merge_stats(self, other): self[1] += other[1] self[2] = self[0] and min(self[2], other[2]) or other[2] self[3] = max(self[3], other[3]) if self[3] == other[3]: self[4] = other[4] # Must update the call count last as update of the # minimum call time is dependent on initial value. self[0] += other[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(self, other):\n from .dataset import Dataset\n\n if other is None:\n return self.to_dataset()\n else:\n other_vars = getattr(other, 'variables', other)\n coords = merge_coords_without_align([self.variables, other_vars])\n return Dataset._fr...
[ "0.69505", "0.694683", "0.6885921", "0.68476945", "0.68086684", "0.6734038", "0.67226946", "0.66790885", "0.66472447", "0.66369003", "0.6572359", "0.6542647", "0.6503335", "0.65015614", "0.6469766", "0.64362967", "0.64317465", "0.6385473", "0.6376822", "0.6375423", "0.6370342...
0.0
-1
Merge data from a slow sql node object.
def merge_slow_sql_node(self, node): duration = node.duration self[1] += duration self[2] = self[0] and min(self[2], duration) or duration self[3] = max(self[3], duration) if self[3] == duration: self[4] = node # Must update the call count last as update of the # minimum call time is dependent on initial value. self[0] += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_slow_sql_node(self, node):\n\n if not self.__settings:\n return\n\n key = node.identifier\n stats = self.__sql_stats_table.get(key)\n if stats is None:\n # Only record slow SQL if not already over the limit on\n # how many can be collected in ...
[ "0.5318473", "0.52193975", "0.5193449", "0.515354", "0.5137922", "0.50185084", "0.49987668", "0.49883923", "0.4975488", "0.4966561", "0.49638265", "0.49379689", "0.48661035", "0.48568356", "0.48503768", "0.4833968", "0.48199612", "0.4812925", "0.4802843", "0.47878385", "0.477...
0.6787032
0
Returns a count of the number of unique metrics currently recorded for apdex, time and value metrics.
def metrics_count(self): return len(self.__stats_table)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_running_metrics(self):\n try:\n return len(self.get_classads(\"OSGRSV==\\\"metrics\\\"\"))\n except TypeError:\n self.rsv.log(\"ERROR\", \"Classad parsing failed, unable to count running metrics\")", "def metric_data_count(self):\n\n if not self.__settings...
[ "0.6411366", "0.6283042", "0.62296087", "0.6220417", "0.61111647", "0.6047972", "0.60304636", "0.5969979", "0.59513307", "0.5878805", "0.5827968", "0.5753369", "0.5703473", "0.56953144", "0.56933933", "0.56933933", "0.5690032", "0.5668702", "0.56455106", "0.5636696", "0.56353...
0.6419223
0
Record a single apdex metric, merging the data with any data from prior apdex metrics with the same name.
def record_apdex_metric(self, metric): if not self.__settings: return # Note that because we are using a scope here of an empty string # we can potentially clash with an unscoped metric. Using None, # although it may help to keep them separate in the agent will # not make a difference to the data collector which treats None # as an empty string anyway. key = (metric.name, '') stats = self.__stats_table.get(key) if stats is None: stats = ApdexStats(apdex_t=metric.apdex_t) self.__stats_table[key] = stats stats.merge_apdex_metric(metric) return key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_apdex_metrics(self, metrics):\n\n if not self.__settings:\n return\n\n for metric in metrics:\n self.record_apdex_metric(metric)", "def merge_apdex_metric(self, metric):\n\n self[0] += metric.satisfying\n self[1] += metric.tolerating\n self[2] +...
[ "0.7010535", "0.6634994", "0.5894368", "0.579922", "0.57742566", "0.5767345", "0.5742764", "0.5742764", "0.56948036", "0.5694517", "0.56521934", "0.564671", "0.5620353", "0.56121796", "0.552094", "0.53992915", "0.5386446", "0.52903515", "0.5282726", "0.52693814", "0.5267927",...
0.74796903
0
Record the apdex metrics supplied by the iterable for a single transaction, merging the data with any data from prior apdex metrics with the same name.
def record_apdex_metrics(self, metrics): if not self.__settings: return for metric in metrics: self.record_apdex_metric(metric)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_transaction(self, transaction):\n\n if not self.__settings:\n return\n\n settings = self.__settings\n\n # Record the apdex, value and time metrics generated from the\n # transaction. Whether time metrics are reported as distinct\n # metrics or into a rollup ...
[ "0.6160698", "0.56689644", "0.5492042", "0.53796333", "0.5373829", "0.5285188", "0.52515113", "0.52226347", "0.522238", "0.52220243", "0.5142877", "0.51234", "0.5087667", "0.50747657", "0.50630915", "0.5057553", "0.5049021", "0.50429595", "0.5004636", "0.49941427", "0.4935158...
0.6819747
0
Record a single time metric, merging the data with any data from prior time metrics with the same name and scope.
def record_time_metric(self, metric): if not self.__settings: return # Scope is forced to be empty string if None as # scope of None is reserved for apdex metrics. key = (metric.name, metric.scope or '') stats = self.__stats_table.get(key) if stats is None: stats = TimeStats(call_count=1, total_call_time=metric.duration, total_exclusive_call_time=metric.exclusive, min_call_time=metric.duration, max_call_time=metric.duration, sum_of_squares=metric.duration ** 2) self.__stats_table[key] = stats else: stats.merge_time_metric(metric) return key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_time_metrics(self, metrics):\n\n if not self.__settings:\n return\n\n for metric in metrics:\n self.record_time_metric(metric)", "def record_custom_metric(self, name, value):\n if isinstance(value, dict):\n if len(value) == 1 and 'count' in value:\...
[ "0.6278324", "0.62258005", "0.6140665", "0.6003981", "0.58658415", "0.5658924", "0.5652999", "0.5612092", "0.5606227", "0.5472987", "0.5470835", "0.54608715", "0.5427048", "0.53969103", "0.53553826", "0.533382", "0.52751833", "0.5262168", "0.52570385", "0.52540565", "0.522785...
0.7506857
0
Record the time metrics supplied by the iterable for a single transaction, merging the data with any data from prior time metrics with the same name and scope.
def record_time_metrics(self, metrics): if not self.__settings: return for metric in metrics: self.record_time_metric(metric)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flush(self):\n with self._lock:\n batch = self._batch\n timestamps = self._timestamps\n\n items = []\n for identity, value in batch.items():\n metric = {}\n typ, name, tags = identity\n metric[\"name\"] = name\n ...
[ "0.6077945", "0.5785074", "0.5715007", "0.5492405", "0.5340035", "0.5287281", "0.5276565", "0.5246753", "0.524385", "0.5236754", "0.5186013", "0.5171279", "0.5168675", "0.51627535", "0.51169103", "0.51088405", "0.5038848", "0.5023717", "0.49753776", "0.49482045", "0.4947367",...
0.6196177
0
Record a single value metric, merging the data with any data from prior value metrics with the same name.
def record_custom_metric(self, name, value): key = (name, '') if isinstance(value, dict): if len(value) == 1 and 'count' in value: new_stats = CountStats(call_count=value['count']) else: new_stats = TimeStats(*c2t(**value)) else: new_stats = TimeStats(1, value, value, value, value, value**2) stats = self.__stats_table.get(key) if stats is None: self.__stats_table[key] = new_stats else: stats.merge_stats(new_stats) return key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log(self, metric_name: str, value: float) -> None:\n if metric_name in self.metrics:\n self.metrics[metric_name].append(value)\n else:\n self.metrics[metric_name] = [value]", "def record_custom_metric(self, name, value):\n if isinstance(value, dict):\n if...
[ "0.72274554", "0.69380003", "0.68785536", "0.683132", "0.6480525", "0.6403055", "0.6216645", "0.61926883", "0.61354136", "0.6075729", "0.6063117", "0.6036601", "0.59779376", "0.5955456", "0.5926401", "0.5891051", "0.5852286", "0.5779409", "0.5769437", "0.576314", "0.5720652",...
0.6751963
4
Record the value metrics supplied by the iterable, merging the data with any data from prior value metrics with the same name.
def record_custom_metrics(self, metrics): if not self.__settings: return for name, value in metrics: self.record_custom_metric(name, value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, current_iter, *metrics, **named_metrics):\n\n # Same order as __init__() in python>=3.6\n if len(metrics) > 0:\n for key, metric in zip(self.metrics.keys(), metrics):\n self.metrics[key].append((current_iter, metric))\n \n # Random order wi...
[ "0.67049134", "0.60828054", "0.59038454", "0.5789189", "0.57760006", "0.5761314", "0.5761024", "0.57179546", "0.5702051", "0.5690251", "0.56831443", "0.56656265", "0.55119264", "0.55036944", "0.54828936", "0.5461199", "0.54519856", "0.54256064", "0.54026794", "0.5388167", "0....
0.59415793
2
Record a single sql metric, merging the data with any data from prior sql metrics for the same sql key.
def record_slow_sql_node(self, node): if not self.__settings: return key = node.identifier stats = self.__sql_stats_table.get(key) if stats is None: # Only record slow SQL if not already over the limit on # how many can be collected in the harvest period. settings = self.__settings maximum = settings.agent_limits.slow_sql_data if len(self.__sql_stats_table) < maximum: stats = SlowSqlStats() self.__sql_stats_table[key] = stats if stats: stats.merge_slow_sql_node(node) return key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_apdex_metric(self, metric):\n\n if not self.__settings:\n return\n\n # Note that because we are using a scope here of an empty string\n # we can potentially clash with an unscoped metric. Using None,\n # although it may help to keep them separate in the agent will\...
[ "0.6167947", "0.59710056", "0.59208757", "0.5898851", "0.58011967", "0.5774532", "0.5704721", "0.5638924", "0.5566081", "0.5514177", "0.5501307", "0.54829776", "0.5433093", "0.5422249", "0.5399425", "0.53741735", "0.53741735", "0.5347321", "0.5339919", "0.533079", "0.53289974...
0.5720255
6
Check if transaction is the slowest transaction and update accordingly.
def _update_slow_transaction(self, transaction): slowest = 0 name = transaction.path if self.__slow_transaction: slowest = self.__slow_transaction.duration if name in self.__slow_transaction_map: slowest = max(self.__slow_transaction_map[name], slowest) if transaction.duration > slowest: # We are going to replace the prior slow transaction. # We need to be a bit tricky here. If we are overriding # an existing slow transaction for a different name, # then we need to restore in the transaction map what # the previous slowest duration was for that, or remove # it if there wasn't one. This is so we do not incorrectly # suppress it given that it was never actually reported # as the slowest transaction. if self.__slow_transaction: if self.__slow_transaction.path != name: if self.__slow_transaction_old_duration: self.__slow_transaction_map[ self.__slow_transaction.path] = ( self.__slow_transaction_old_duration) else: del self.__slow_transaction_map[ self.__slow_transaction.path] if name in self.__slow_transaction_map: self.__slow_transaction_old_duration = ( self.__slow_transaction_map[name]) else: self.__slow_transaction_old_duration = None self.__slow_transaction = transaction self.__slow_transaction_map[name] = transaction.duration
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_database_with_block(self, block):\n\n txs = sorted(block['txs'], key=lambda x: x['count'] if 'count' in x else -1)\n\n for tx in txs:\n result = self.update_database_with_tx(tx, block['length'])\n if not result:\n return False\n\n return True", ...
[ "0.5796732", "0.56013685", "0.5567382", "0.5438813", "0.52951", "0.527724", "0.5276468", "0.52692777", "0.51808035", "0.5144416", "0.5136642", "0.51107734", "0.5102024", "0.5087963", "0.50874853", "0.5072691", "0.5062309", "0.503474", "0.49916357", "0.49607188", "0.4943801", ...
0.78206486
0
Check if transaction is a synthetics trace and save it to __synthetics_transactions.
def _update_synthetics_transaction(self, transaction): settings = self.__settings if not transaction.synthetics_resource_id: return maximum = settings.agent_limits.synthetics_transactions if len(self.__synthetics_transactions) < maximum: self.__synthetics_transactions.append(transaction)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isSStx(tx):\n try:\n checkSStx(tx)\n\n except Exception as e:\n log.debug(\"isSStx: {}\".format(e))\n\n else:\n return True", "def save(self, trade: Trade) -> Trade:\n\n pass # pragma: no cover", "def is_transaction(self) -> bool:\n return False", "def isTx(se...
[ "0.54398495", "0.5149518", "0.51403934", "0.51361316", "0.5022585", "0.48563206", "0.48534927", "0.48511583", "0.4807828", "0.47867486", "0.46448067", "0.46145433", "0.45834467", "0.4583097", "0.45755658", "0.4567124", "0.45389777", "0.45228583", "0.45225585", "0.45150757", "...
0.64152426
0
Record any apdex and time metrics for the transaction as well as any errors which occurred for the transaction. If the transaction qualifies to become the slow transaction remember it for later.
def record_transaction(self, transaction): if not self.__settings: return settings = self.__settings # Record the apdex, value and time metrics generated from the # transaction. Whether time metrics are reported as distinct # metrics or into a rollup is in part controlled via settings # for minimum number of unique metrics to be reported and thence # whether over a time threshold calculated as percentage of # overall request time, up to a maximum number of unique # metrics. This is intended to limit how many metrics are # reported for each transaction and try and cut down on an # explosion of unique metric names. The limits and thresholds # are applied after the metrics are reverse sorted based on # exclusive times for each metric. This ensures that the metrics # with greatest exclusive time are retained over those with # lesser time. Such metrics get reported into the performance # breakdown tab for specific web transactions. self.record_apdex_metrics(transaction.apdex_metrics(self)) self.merge_custom_metrics(transaction.custom_metrics.metrics()) self.record_time_metrics(transaction.time_metrics(self)) # Capture any errors if error collection is enabled. # Only retain maximum number allowed per harvest. error_collector = settings.error_collector if (error_collector.enabled and settings.collect_errors and len(self.__transaction_errors) < settings.agent_limits.errors_per_harvest): self.__transaction_errors.extend(transaction.error_details()) self.__transaction_errors = self.__transaction_errors[: settings.agent_limits.errors_per_harvest] if (error_collector.capture_events and error_collector.enabled and settings.collect_error_events): events = transaction.error_events(self.__stats_table) for event in events: self._error_events.add(event, priority=transaction.priority) # Capture any sql traces if transaction tracer enabled. if settings.slow_sql.enabled and settings.collect_traces: for node in transaction.slow_sql_nodes(self): self.record_slow_sql_node(node) # Remember as slowest transaction if transaction tracer # is enabled, it is over the threshold and slower than # any existing transaction seen for this period and in # the historical snapshot of slow transactions, plus # recording of transaction trace for this transaction # has not been suppressed. transaction_tracer = settings.transaction_tracer if (not transaction.suppress_transaction_trace and transaction_tracer.enabled and settings.collect_traces): # Transactions saved for Synthetics transactions # do not depend on the transaction threshold. self._update_synthetics_transaction(transaction) threshold = transaction_tracer.transaction_threshold if threshold is None: threshold = transaction.apdex_t * 4 if transaction.duration >= threshold: self._update_slow_transaction(transaction) # Create the transaction event and add it to the # appropriate "bucket." Synthetic requests are saved in one, # while transactions from regular requests are saved in another. if transaction.synthetics_resource_id: event = transaction.transaction_event(self.__stats_table) self._synthetics_events.add(event) elif (settings.collect_analytics_events and settings.transaction_events.enabled): event = transaction.transaction_event(self.__stats_table) self._transaction_events.add(event, priority=transaction.priority) # Merge in custom events if (settings.collect_custom_events and settings.custom_insights_events.enabled): self.custom_events.merge(transaction.custom_events) # Merge in span events if (settings.distributed_tracing.enabled and settings.span_events.enabled and settings.collect_span_events): if settings.infinite_tracing.enabled: for event in transaction.span_protos(settings): self._span_stream.put(event) elif transaction.sampled: for event in transaction.span_events(self.__settings): self._span_events.add(event, priority=transaction.priority)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_slow_transaction(self, transaction):\n\n slowest = 0\n name = transaction.path\n\n if self.__slow_transaction:\n slowest = self.__slow_transaction.duration\n if name in self.__slow_transaction_map:\n slowest = max(self.__slow_transaction_map[name], slow...
[ "0.57431966", "0.56813395", "0.5386816", "0.5268158", "0.52590114", "0.5248265", "0.51790476", "0.51674783", "0.51302767", "0.5116144", "0.5102775", "0.5091443", "0.50542235", "0.5050009", "0.5020564", "0.50163", "0.50032055", "0.4916298", "0.48824197", "0.4858216", "0.484667...
0.7942365
0
Returns a list containing the low level metric data for sending to the core application pertaining to the reporting period. This consists of tuple pairs where first is dictionary with name and scope keys with corresponding values, or integer identifier if metric had an entry in dictionary mapping metric (name, scope) as supplied from core application. The second is the list of accumulated metric data, the list always being of length 6.
def metric_data(self, normalizer=None): if not self.__settings: return [] result = [] normalized_stats = {} # Metric Renaming and Re-Aggregation. After applying the metric # renaming rules, the metrics are re-aggregated to collapse the # metrics with same names after the renaming. if self.__settings.debug.log_raw_metric_data: _logger.info('Raw metric data for harvest of %r is %r.', self.__settings.app_name, list(six.iteritems(self.__stats_table))) if normalizer is not None: for key, value in six.iteritems(self.__stats_table): key = (normalizer(key[0])[0], key[1]) stats = normalized_stats.get(key) if stats is None: normalized_stats[key] = copy.copy(value) else: stats.merge_stats(value) else: normalized_stats = self.__stats_table if self.__settings.debug.log_normalized_metric_data: _logger.info('Normalized metric data for harvest of %r is %r.', self.__settings.app_name, list(six.iteritems(normalized_stats))) for key, value in six.iteritems(normalized_stats): key = dict(name=key[0], scope=key[1]) result.append((key, value)) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_metric_list(self) -> List[str]:\n ...", "def get_all_metrics(self):\n up_time = self.uptime()\n down_time = self.downtime()\n customer_sla = self.sla()\n objective = self.slo()\n indicator = self.sli()\n avail_percentage = self.availability()\n mt_b...
[ "0.63188374", "0.61312807", "0.59498423", "0.59364164", "0.59249073", "0.58868825", "0.5866983", "0.5859181", "0.57975364", "0.5722001", "0.57070863", "0.57040983", "0.5697402", "0.5691452", "0.5689769", "0.5687561", "0.5686129", "0.5646755", "0.56391305", "0.5638463", "0.563...
0.5418441
37
Returns a count of the number of unique metrics.
def metric_data_count(self): if not self.__settings: return 0 return len(self.__stats_table)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metrics_count(self):\n\n return len(self.__stats_table)", "def get_count(cls):\n total = 0\n for counter in SimpleCounterShard.objects.all():\n total += counter.count\n return total", "def count(self):\n return self._reduce_for_stat_function(F.count, only_numer...
[ "0.71416634", "0.688916", "0.6736414", "0.65794754", "0.6549508", "0.6549508", "0.6549508", "0.6549508", "0.6548206", "0.65326285", "0.64953864", "0.64506423", "0.64230627", "0.64027196", "0.6389793", "0.6381835", "0.6377822", "0.6373317", "0.6364511", "0.63238037", "0.629012...
0.67860687
2
Returns a to a list containing any errors collected during the reporting period.
def error_data(self): if not self.__settings: return [] return self.__transaction_errors
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getErrorsList(self):\n return self.__errors", "def errors(self) -> List[Error]:", "def getErrors(self) -> java.util.Collection:\n ...", "def get_errors(self):\n return [result for result in self.values() if result.outcome == Result.ERROR]", "def errors(self) -> List[Error]:\n ...
[ "0.7021791", "0.70215106", "0.6847071", "0.6754863", "0.6702647", "0.6692272", "0.65891427", "0.65589136", "0.65341383", "0.65235007", "0.65032333", "0.65032333", "0.6477152", "0.6440303", "0.642983", "0.6413375", "0.6399626", "0.6374042", "0.6354887", "0.6273033", "0.6271302...
0.59131587
38
Returns a list of slow transaction data collected during the reporting period.
def transaction_trace_data(self, connections): _logger.debug('Generating transaction trace data.') if not self.__settings: return [] # Create a set 'traces' that is a union of slow transaction, # and Synthetics transactions. This ensures we don't send # duplicates of a transaction. traces = set() if self.__slow_transaction: traces.add(self.__slow_transaction) traces.update(self.__synthetics_transactions) # Return an empty list if no transactions were captured. if not traces: return [] # We want to limit the number of explain plans we do across # these. So work out what were the slowest and tag them. # Later the explain plan will only be run on those which are # tagged. agent_limits = self.__settings.agent_limits explain_plan_limit = agent_limits.sql_explain_plans_per_harvest maximum_nodes = agent_limits.transaction_traces_nodes database_nodes = [] if explain_plan_limit != 0: for trace in traces: for node in trace.slow_sql: # Make sure we clear any flag for explain plans on # the nodes in case a transaction trace was merged # in from previous harvest period. node.generate_explain_plan = False # Node should be excluded if not for an operation # that we can't do an explain plan on. Also should # not be one which would not be included in the # transaction trace because limit was reached. if (node.node_count < maximum_nodes and node.connect_params and node.statement.operation in node.statement.database.explain_stmts): database_nodes.append(node) database_nodes = sorted(database_nodes, key=lambda x: x.duration)[-explain_plan_limit:] for node in database_nodes: node.generate_explain_plan = True else: for trace in traces: for node in trace.slow_sql: node.generate_explain_plan = True database_nodes.append(node) # Now generate the transaction traces. We need to cap the # number of nodes capture to the specified limit. trace_data = [] for trace in traces: transaction_trace = trace.transaction_trace( self, maximum_nodes, connections) data = [transaction_trace, list(trace.string_table.values())] if self.__settings.debug.log_transaction_trace_payload: _logger.debug('Encoding slow transaction data where ' 'payload=%r.', data) json_data = json_encode(data) level = self.__settings.agent_limits.data_compression_level level = level or zlib.Z_DEFAULT_COMPRESSION zlib_data = zlib.compress(six.b(json_data), level) pack_data = base64.standard_b64encode(zlib_data) if six.PY3: pack_data = pack_data.decode('Latin-1') root = transaction_trace.root if trace.record_tt: force_persist = True else: force_persist = False if trace.include_transaction_trace_request_uri: request_uri = trace.request_uri else: request_uri = None trace_data.append([transaction_trace.start_time, root.end_time - root.start_time, trace.path, request_uri, pack_data, trace.guid, None, force_persist, None, trace.synthetics_resource_id, ]) return trace_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slow_transaction_data(self):\n\n # XXX This method no longer appears to be used. Being replaced\n # by the transaction_trace_data() method.\n\n if not self.__settings:\n return []\n\n if not self.__slow_transaction:\n return []\n\n maximum = self.__setti...
[ "0.7311632", "0.5812507", "0.571646", "0.57079303", "0.5684339", "0.55696833", "0.55493486", "0.553089", "0.5528401", "0.5502346", "0.548358", "0.544936", "0.544525", "0.54149175", "0.5411108", "0.54054636", "0.5394847", "0.5392003", "0.53741133", "0.5357601", "0.5319892", ...
0.6642906
1
Returns a list containing any slow transaction data collected during the reporting period. NOTE Currently only the slowest transaction for the reporting period is retained.
def slow_transaction_data(self): # XXX This method no longer appears to be used. Being replaced # by the transaction_trace_data() method. if not self.__settings: return [] if not self.__slow_transaction: return [] maximum = self.__settings.agent_limits.transaction_traces_nodes transaction_trace = self.__slow_transaction.transaction_trace( self, maximum) data = [transaction_trace, list(self.__slow_transaction.string_table.values())] if self.__settings.debug.log_transaction_trace_payload: _logger.debug('Encoding slow transaction data where ' 'payload=%r.', data) json_data = json_encode(data) level = self.__settings.agent_limits.data_compression_level level = level or zlib.Z_DEFAULT_COMPRESSION zlib_data = zlib.compress(six.b(json_data), level) pack_data = base64.standard_b64encode(zlib_data) if six.PY3: pack_data = pack_data.decode('Latin-1') root = transaction_trace.root trace_data = [[root.start_time, root.end_time - root.start_time, self.__slow_transaction.path, self.__slow_transaction.request_uri, pack_data]] return trace_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transaction_trace_data(self, connections):\n\n _logger.debug('Generating transaction trace data.')\n\n if not self.__settings:\n return []\n\n # Create a set 'traces' that is a union of slow transaction,\n # and Synthetics transactions. This ensures we don't send\n ...
[ "0.6520807", "0.5953189", "0.5941957", "0.5698872", "0.56704205", "0.55845326", "0.55000305", "0.54975384", "0.53581554", "0.5356301", "0.5327412", "0.53010184", "0.5276863", "0.52720934", "0.5257284", "0.52468723", "0.5164559", "0.5162055", "0.51554185", "0.5149581", "0.5126...
0.72200763
0
Resets the accumulated statistics back to initial state and associates the application settings object with the stats engine. This should be called when application is first activated and combined application settings incorporating server side settings are available. Would also be called on any forced restart of agent or a reconnection due to loss of connection.
def reset_stats(self, settings, reset_stream=False): self.__settings = settings self.__stats_table = {} self.__sql_stats_table = {} self.__slow_transaction = None self.__slow_transaction_map = {} self.__slow_transaction_old_duration = None self.__transaction_errors = [] self.__synthetics_transactions = [] self.reset_transaction_events() self.reset_error_events() self.reset_custom_events() self.reset_span_events() self.reset_synthetics_events() # streams are never reset after instantiation if reset_stream: self._span_stream = StreamBuffer( settings.infinite_tracing.span_queue_size)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stats_reset(self):\n self.stats.reset()", "def stats_reset(self):\n self.stats.reset()", "def reset_settings():\n settings = Settings()\n settings.reset()\n settings.save()", "def initialize(self):\n super(Stats, self).initialize()\n if not hasattr(self.application, '...
[ "0.5851397", "0.5851397", "0.5782384", "0.57592905", "0.56791097", "0.5615239", "0.5549352", "0.5518156", "0.5513039", "0.54954475", "0.54496795", "0.54446083", "0.54427564", "0.54313743", "0.5414981", "0.5411828", "0.5359997", "0.5353914", "0.5333628", "0.53336173", "0.53336...
0.5501668
9
Resets the accumulated statistics back to initial state for metric data.
def reset_metric_stats(self): self.__stats_table = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self):\n self.sum_metric = 0.\n self.num_inst = 0.\n self.metrics.reset_stats()", "def reset_metric_stats(self):\n self.__stats_table = {}", "def stats_reset(self):\n self.stats.reset()", "def stats_reset(self):\n self.stats.reset()", "def reset(self) -> ...
[ "0.8448358", "0.83412653", "0.83299094", "0.83299094", "0.8270503", "0.8153123", "0.79735655", "0.7772603", "0.77270293", "0.77003264", "0.76665866", "0.7614711", "0.75709176", "0.7540221", "0.75036174", "0.75036174", "0.7490715", "0.7471787", "0.74488425", "0.74488425", "0.7...
0.84143066
1
Resets the accumulated statistics back to initial state for sample analytics data.
def reset_transaction_events(self): if self.__settings is not None: self._transaction_events = SampledDataSet( self.__settings.event_harvest_config. harvest_limits.analytic_event_data) else: self._transaction_events = SampledDataSet()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stats_reset(self):\n self.stats.reset()", "def stats_reset(self):\n self.stats.reset()", "def reset(self) -> None:\n self.statistics = defaultdict(float)", "def reset(self) -> None:\n self.statistics = defaultdict(int)", "def reset(self):\n self.stats = {}", "def re...
[ "0.8175733", "0.8175733", "0.81559753", "0.81235486", "0.78766066", "0.78731924", "0.77236235", "0.76826066", "0.7648331", "0.7643053", "0.75607705", "0.7420023", "0.73855245", "0.735026", "0.735026", "0.735026", "0.7306659", "0.7305569", "0.72605497", "0.72255266", "0.714615...
0.0
-1
Resets the accumulated statistics back to initial state for Synthetics events data.
def reset_synthetics_events(self): if self.__settings is not None: self._synthetics_events = LimitedDataSet( self.__settings.agent_limits.synthetics_events) else: self._synthetics_events = LimitedDataSet()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset(self) -> None:\n self.statistics = defaultdict(float)", "def stats_reset(self):\n self.stats.reset()", "def stats_reset(self):\n self.stats.reset()", "def reset(self) -> None:\n self.statistics = defaultdict(int)", "def reset(self):\n self.stats = {}", "def re...
[ "0.7742906", "0.76873755", "0.76873755", "0.7634818", "0.75161463", "0.7410027", "0.7406162", "0.7288068", "0.72181994", "0.7202865", "0.7152267", "0.7146272", "0.69828737", "0.6976172", "0.6946784", "0.6946784", "0.6946784", "0.6941798", "0.69132906", "0.6901035", "0.6886194...
0.71011585
12
Creates a snapshot of the accumulated statistics, error details and slow transaction and returns it. This is a shallow copy, only copying the top level objects. The originals are then reset back to being empty, with the exception of the dictionary mapping metric (name, scope) to the integer identifiers received from the core application. The latter is retained as should carry forward to subsequent runs. This method would be called to snapshot the data when doing the harvest.
def harvest_snapshot(self, flexible=False): snapshot = self._snapshot() # Data types only appear in one place, so during a snapshot it must be # represented in either the snapshot or in the current stats object. # # If we're in flexible harvest, the goal is to have everything in the # whitelist appear in the snapshot. This means, we must remove the # whitelist data types from the current stats object. # # If we're not in flexible harvest, everything excluded from the # whitelist appears in the snapshot and is removed from the current # stats object. if flexible: whitelist_stats, other_stats = self, snapshot snapshot.reset_non_event_types() else: whitelist_stats, other_stats = snapshot, self self.reset_non_event_types() event_harvest_whitelist = \ self.__settings.event_harvest_config.whitelist # Iterate through harvest types. If they are in the list of types to # harvest reset them on stats_engine otherwise remove them from the # snapshot. for nr_method, stats_methods in EVENT_HARVEST_METHODS.items(): for stats_method in stats_methods: if nr_method in event_harvest_whitelist: reset = getattr(whitelist_stats, stats_method) else: reset = getattr(other_stats, stats_method) reset() return snapshot
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_flat_results(self):\n test_results, error_dict, framestats = self.get_results()\n test_results = self._merge_test_results(test_results, error_dict)\n\n results = copy.deepcopy(test_results)\n results.update(framestats)\n\n return results", "def __copy__(self) :\n ...
[ "0.5934949", "0.58573073", "0.5802806", "0.5787985", "0.5758199", "0.5758142", "0.57447433", "0.57192504", "0.56812185", "0.56527025", "0.5649071", "0.56446093", "0.5642422", "0.5546954", "0.5542068", "0.5531035", "0.5524276", "0.55112106", "0.54917693", "0.54811484", "0.5465...
0.0
-1
Creates and returns a new empty stats engine object. This would be used to distill stats from a single web transaction before then merging it back into the parent under a thread lock.
def create_workarea(self): stats = copy.copy(self) stats.reset_stats(self.__settings) return stats
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create( ):\n \n uuid = generate_uuid( 10 )\n\n stats = Stats( key_name = uuid,\n uuid = uuid,\n )\n stats.put()\n return stats", "def empty_instance():\n from weighted_graph import Graph\n return Graph()", "def __init__(se...
[ "0.6012898", "0.54610676", "0.5434459", "0.5365949", "0.5345452", "0.53324264", "0.5254955", "0.5204557", "0.5093632", "0.50626856", "0.5004467", "0.498278", "0.49784213", "0.4975857", "0.49731496", "0.49413025", "0.49334928", "0.49183187", "0.49155334", "0.48889562", "0.4852...
0.53285325
6