query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Successively applies each of the rotations stored in givens to H_col. | def apply_rotations(H_col: jax.ShapedArray, givens: jax.ShapedArray,
k: int) -> jax.ShapedArray:
rotation_carry = (H_col, 0, k, givens)
def loop_condition(carry):
i = carry[1]
k = carry[2]
return jax.lax.cond(i < k, lambda x: True, lambda x: False, 0)
def apply_ith_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_givens_rotation(H_col: jax.ShapedArray, givens: jax.ShapedArray,\n k: int) -> Tuple[jax.ShapedArray, jax.ShapedArray]:\n # This call successively applies each of the\n # Givens rotations stored in givens[:, :k] to H_col.\n H_col = apply_rotations(H_col, givens, k)\n\n ... | [
"0.73926467",
"0.5681619",
"0.549413",
"0.5357701",
"0.53283906",
"0.5293677",
"0.520022",
"0.519057",
"0.5088467",
"0.50847656",
"0.50769705",
"0.50462455",
"0.50274307",
"0.49993315",
"0.49852484",
"0.4983559",
"0.4973589",
"0.49634326",
"0.49592367",
"0.49521154",
"0.49075... | 0.7330481 | 1 |
Applies the Givens rotations stored in the vectors cs and sn to the vector H_col. Then constructs a new Givens rotation that eliminates H_col's k'th element, yielding the corresponding column of the R in H's QR decomposition. Returns the new column of R along with the new Givens factors. | def apply_givens_rotation(H_col: jax.ShapedArray, givens: jax.ShapedArray,
k: int) -> Tuple[jax.ShapedArray, jax.ShapedArray]:
# This call successively applies each of the
# Givens rotations stored in givens[:, :k] to H_col.
H_col = apply_rotations(H_col, givens, k)
cs_k, sn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_rotations(H_col: jax.ShapedArray, givens: jax.ShapedArray,\n k: int) -> jax.ShapedArray:\n rotation_carry = (H_col, 0, k, givens)\n\n def loop_condition(carry):\n i = carry[1]\n k = carry[2]\n return jax.lax.cond(i < k, lambda x: True, lambda x: False, 0)\n\n ... | [
"0.6138148",
"0.5132266",
"0.5044118",
"0.50204897",
"0.49985307",
"0.49635363",
"0.4903446",
"0.48277012",
"0.48053998",
"0.47816756",
"0.4768826",
"0.4737764",
"0.4733043",
"0.4726679",
"0.47147375",
"0.4713533",
"0.47095165",
"0.4691508",
"0.46743643",
"0.46470118",
"0.464... | 0.6756806 | 0 |
Check if quote already exists in Nostalgiabot's memory for this Person. | def has_said(self, quote: str) -> bool:
return any(q for q in self.quotes if q.content.lower() == quote.lower()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_term_exist(self, term):\n return term in self.postingDict",
"def check_existed_did(self):\n for wallet in self.wallet_state_manager.wallets.values():\n if (\n wallet.type() == WalletType.DECENTRALIZED_ID\n and self.did_info.origin_coin.name() == wall... | [
"0.5549986",
"0.5529568",
"0.55025846",
"0.54980576",
"0.54824877",
"0.54619014",
"0.5449591",
"0.52898127",
"0.52789867",
"0.5272745",
"0.5230741",
"0.52132195",
"0.5202484",
"0.5193138",
"0.5162743",
"0.5162743",
"0.5120887",
"0.51052827",
"0.5090298",
"0.50702953",
"0.5042... | 0.6199974 | 0 |
Updates the stay time of visit | def update_stay_time(self):
# It would not be better to simply self.stay_time = self.get_length() ??
self.stay_time = self.get_length() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_time(self):\n pass # Do nothing",
"def update(self):\n super().update()\n self.checkTimeToLive()",
"def update(self):\n if not self.exists:\n return\n if AT.TIME_TO_EXPIRE in self.attributes:\n if not self.calculate_time_left():\n ... | [
"0.6485091",
"0.63547605",
"0.6233127",
"0.5951948",
"0.59343076",
"0.58443356",
"0.58252096",
"0.57942843",
"0.5782025",
"0.5782025",
"0.5764802",
"0.5756116",
"0.57427424",
"0.5739974",
"0.57184714",
"0.5699622",
"0.56783235",
"0.56636465",
"0.56427634",
"0.56412554",
"0.56... | 0.75728226 | 0 |
Repeats a message multiple times. | async def repeat(self,ctx, times: int, content='repeating...'):
for i in range(times):
await ctx.send(content) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def repeat(ctx, times: int, content='repeating...'):\n for i in range(times):\n await ctx.send(content)",
"async def repeat(times : int, content='repeating...'):\n for i in range(times):\n await bot.say(content)",
"async def repeat(ctx, times : int, content='repeating...'):\n for i... | [
"0.75642896",
"0.75241643",
"0.74671906",
"0.6782859",
"0.6725025",
"0.66473454",
"0.6640616",
"0.6501877",
"0.6463185",
"0.6406237",
"0.62558305",
"0.6149078",
"0.61431366",
"0.61045724",
"0.60727173",
"0.60414445",
"0.6028678",
"0.59844077",
"0.59493715",
"0.59287435",
"0.5... | 0.7628505 | 0 |
create data that use Choice model | def create_choices(question_model, text="text", total_votes = 0):
return Choice.objects.create(question=question_model,
text=text,
total_votes=total_votes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, choice):\r\n self.choice = choice",
"def __init__(self, *args, **kwargs):\n super(ChoiceFieldType, self).__init__(*args, **kwargs)\n\n self.choices = self.get_field_info_key('choices')",
"def get_choicesdata(self):\n # selected_value = self.get_cleaned_value()\n ... | [
"0.6384629",
"0.637918",
"0.6361359",
"0.6212173",
"0.6101701",
"0.60345143",
"0.5951211",
"0.5886236",
"0.5857764",
"0.5848246",
"0.58469194",
"0.58059937",
"0.5702655",
"0.56995493",
"0.56930524",
"0.5691047",
"0.568869",
"0.5666549",
"0.56657976",
"0.5663346",
"0.5648866",... | 0.6831114 | 0 |
create data that use Answer model | def create_answer(question, user):
return Answer.objects.create(question=question,answered_by=user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_features(self, answer):\n # Get the teacher's stuff\n a_stopwords = sf.remove_stopwords(self.teacher_answer)\n a_stemmed = sf.stem_sentence(a_stopwords)\n a_stemmed_ordered = sf.order_sentence(a_stemmed)\n teacher_answers = [\n a_stemmed,\n a_stem... | [
"0.64814955",
"0.63967526",
"0.63827956",
"0.6260587",
"0.6246229",
"0.62410545",
"0.6156967",
"0.61112285",
"0.61091954",
"0.61057824",
"0.6091933",
"0.6012156",
"0.6009843",
"0.59592485",
"0.59487975",
"0.5926686",
"0.59090936",
"0.59057355",
"0.5905192",
"0.58983946",
"0.5... | 0.6539529 | 0 |
same as create_user but using user manager | def create_user_using_manager(username,password):
manager = UserManager()
return manager.create_user(username=username, password=password) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user(self):\n User.objects.create_user('test', 'testing@test.com', 'testing')",
"def create_user(self):\n return User.objects.create_user(**self.user_data)",
"def create_user(email, password, f_name, l_name):\n pass",
"def _create(cls, model_class, *args, **kwargs):\n manag... | [
"0.8181188",
"0.7908192",
"0.78201514",
"0.77046186",
"0.7671698",
"0.7660212",
"0.7622274",
"0.7616442",
"0.759572",
"0.7572086",
"0.7542684",
"0.75390494",
"0.7530234",
"0.7527077",
"0.75035036",
"0.7481546",
"0.74714476",
"0.74663395",
"0.74663395",
"0.74663395",
"0.742654... | 0.8066032 | 1 |
populate question object with random string and user | def populate_poll(user="",total=10):
user_list = None
#create random user only when user argument empty
if user == "":
create_random_user(20)
user_list = User.objects.all()
for i in range(total):
Question.objects.create(
created_by=random.choice(user_list) if use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, question):\n self.question = question\n self.responses = []",
"def __init__(self, question, answer):\n\n self.question = question\n self.answer = answer\n\n self.q_and_a = {\n 'Question:': self.question,\n 'Correct Answer:': self.answer,... | [
"0.6517821",
"0.6408259",
"0.6362986",
"0.6347021",
"0.6313082",
"0.61639714",
"0.6121847",
"0.6114391",
"0.6093224",
"0.6044101",
"0.6040264",
"0.5993357",
"0.59512204",
"0.5943956",
"0.5889812",
"0.58555055",
"0.5852014",
"0.58435476",
"0.58026284",
"0.57996535",
"0.5797478... | 0.69050956 | 0 |
create CreatePollQuestion dummy form | def create_dummy_form(title,text,fill_choice=[],choice_length=[]):
# fill it with blank for dummy choices
count=0
choices=[]
while count < 8:
choices.append(None)
count+=1
# fill choices based on value on fill_choice
for i in fill_choice:
try :
length = c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_freeform(cls, name, question, default_response, contacts, user): \n poll = Poll.objects.create(\n name=name,\n question=question,\n default_response=default_response, \n user=user,\n type=Poll.TYPE_TE... | [
"0.68965745",
"0.664663",
"0.66033286",
"0.6529158",
"0.64919966",
"0.64177126",
"0.6361779",
"0.6354872",
"0.6351356",
"0.6324996",
"0.62474936",
"0.62169385",
"0.6213089",
"0.62068975",
"0.6191489",
"0.6160336",
"0.61465067",
"0.6138712",
"0.6129136",
"0.61282086",
"0.61165... | 0.7856849 | 0 |
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... | {
"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 |
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 = sour... | {
"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 |
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('... | {
"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 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
... | {
"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]))
... | {
"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] * ... | {
"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(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(ad... | {
"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 |
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.a... | {
"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.li... | {
"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 |
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[n... | {
"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]
... | {
"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 lin... | {
"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 |
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 Attribute... | {
"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:
... | {
"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 |
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_ri... | {
"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")
... | {
"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... | {
"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 |
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... | {
"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 |
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 |
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 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 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... | {
"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 |
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 o... | {
"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
# no... | {
"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:... | {
"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 |
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)
... | {
"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_trans... | {
"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 con... | {
"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 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 ... | {
"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... | {
"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 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 |
Merges data from a single transaction. Snapshot is an instance of StatsEngine that contains stats for the single transaction. | def merge(self, snapshot):
if not self.__settings:
return
self.merge_metric_stats(snapshot)
self._merge_transaction_events(snapshot)
self._merge_synthetics_events(snapshot)
self._merge_error_events(snapshot)
self._merge_error_traces(snapshot)
self._m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_metric_stats(self, snapshot):\n\n if not self.__settings:\n return\n\n for key, other in six.iteritems(snapshot.__stats_table):\n stats = self.__stats_table.get(key)\n if not stats:\n self.__stats_table[key] = other\n else:\n ... | [
"0.5806089",
"0.50894815",
"0.5036111",
"0.50232536",
"0.49642876",
"0.4911518",
"0.487619",
"0.48526537",
"0.48363346",
"0.48321915",
"0.47403112",
"0.47268453",
"0.46747193",
"0.4672916",
"0.46666792",
"0.4641363",
"0.4636667",
"0.46207553",
"0.46078375",
"0.46022642",
"0.4... | 0.6420531 | 0 |
Performs a "rollback" merge after a failed harvest. Snapshot is a copy of the main StatsEngine data that we attempted to harvest, but failed. Not all types of data get merged during a rollback. | def rollback(self, snapshot):
if not self.__settings:
return
_logger.debug('Performing rollback of data into '
'subsequent harvest period. Metric data and transaction events'
'will be preserved and rolled into next harvest')
self.merge_metric_stats(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rollback(self, stage, enodes, exception):",
"def test_backup_merge_with_restore(self):\n gen = BlobGenerator(\"ent-backup\", \"ent-backup-\", self.value_size, end=self.num_items)\n self._load_all_buckets(self.master, gen, \"create\", 0)\n self.backup_create()\n self._take_n_backup... | [
"0.6461394",
"0.60570455",
"0.5918345",
"0.5801982",
"0.57985705",
"0.56479573",
"0.5587846",
"0.5585826",
"0.55499566",
"0.55391157",
"0.55083054",
"0.54737455",
"0.54621094",
"0.5453677",
"0.54407775",
"0.5388638",
"0.5380963",
"0.53626865",
"0.53533244",
"0.53509045",
"0.5... | 0.77395844 | 0 |
Merges metric data from a snapshot. This is used both when merging data from a single transaction into the main stats engine, and for performing a rollback merge. In either case, the merge is done the exact same way. | def merge_metric_stats(self, snapshot):
if not self.__settings:
return
for key, other in six.iteritems(snapshot.__stats_table):
stats = self.__stats_table.get(key)
if not stats:
self.__stats_table[key] = other
else:
stats.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(self, snapshot):\n\n if not self.__settings:\n return\n\n self.merge_metric_stats(snapshot)\n self._merge_transaction_events(snapshot)\n self._merge_synthetics_events(snapshot)\n self._merge_error_events(snapshot)\n self._merge_error_traces(snapshot)\n... | [
"0.72327065",
"0.5681518",
"0.5414538",
"0.509253",
"0.5089406",
"0.50668776",
"0.50477487",
"0.50349045",
"0.5023128",
"0.50017947",
"0.49228266",
"0.48627433",
"0.47599393",
"0.4753302",
"0.47469756",
"0.47447816",
"0.47401235",
"0.47382542",
"0.47220156",
"0.4715443",
"0.4... | 0.7712152 | 0 |
Merges in a set of custom metrics. The metrics should be provide as an iterable where each item is a tuple of the metric name and the accumulated stats for the metric. | def merge_custom_metrics(self, metrics):
if not self.__settings:
return
for name, other in metrics:
key = (name, '')
stats = self.__stats_table.get(key)
if not stats:
self.__stats_table[key] = other
else:
stats... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_metrics(self, metrics):\n for i, metric in enumerate(self.config.metrics):\n tf.summary.scalar(metric, metrics[i])",
"def aggregate(all_metrics, reducer, suffix):\n # Collect metric separately\n separated_metrics = {} # type: dict[frozenset, list[dict]]\n for el in... | [
"0.67883134",
"0.6653943",
"0.66358435",
"0.65713274",
"0.65646595",
"0.64966273",
"0.64369106",
"0.6254954",
"0.6035345",
"0.6030221",
"0.5992154",
"0.5904505",
"0.58831435",
"0.5876968",
"0.58738685",
"0.586156",
"0.58568037",
"0.58403516",
"0.58366096",
"0.5835867",
"0.582... | 0.8258332 | 0 |
Checks if player ready to be rendered on the character sheet | def is_player_ready(self):
player = self.base.game_instance['player_ref']
if (player
and base.player_states["is_alive"]
and base.player_states["is_idle"]
and not base.player_states["is_moving"]
and not base.player_states["is_running"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_ready(self):\n if self.game.has_started():\n return True\n return self.status == self.PLAYER_READY",
"def ready(self):\n return self.shader is not None and self.texturesReady()",
"def check_ready(self):\r\n print \"Checking ready\"\r\n\t\tif self.game.troug... | [
"0.69993716",
"0.6624655",
"0.6611897",
"0.6352339",
"0.6298705",
"0.62477887",
"0.6227472",
"0.6222125",
"0.6217452",
"0.6090686",
"0.607338",
"0.6063791",
"0.6063283",
"0.605453",
"0.60500675",
"0.6024416",
"0.6018847",
"0.5996054",
"0.5977044",
"0.5920064",
"0.5918121",
... | 0.6954562 | 1 |
Run the script at given path catching exceptions. This function should only be used internally by Pyto. | def runScriptAtPath(path):
sys.argv = [path]
for arg in PytoClasses.Python.shared.args:
sys.argv.append(str(arg))
def run() -> None:
os.system = PytoClasses.Python.shared.system
directory = os.path.expanduser(os.path.dirname(path))
sys.path.insert(0, directory)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runScript(path=None):\n if path:\n exec(compile(open(path, \"rb\").read(), path, 'exec'))",
"def do_exec(self, arg):\n self.run_file(arg['path'])",
"def _run_file(file_path, globals_):\n script_name = os.path.basename(file_path)\n\n sys.path = (_PATHS.script_paths(script_name) +\n ... | [
"0.72653073",
"0.6912623",
"0.68354243",
"0.67718136",
"0.67703193",
"0.65939707",
"0.6413898",
"0.63070154",
"0.61949843",
"0.61937946",
"0.6164765",
"0.6151639",
"0.60480416",
"0.60265625",
"0.60191596",
"0.6006073",
"0.5994495",
"0.59873414",
"0.5959248",
"0.58620226",
"0.... | 0.7851395 | 0 |
Expected defaults when no project exists | def test_no_project_defaults(self):
ep = exposed.ExposedProject()
self.assertIsNone(ep.display)
self.assertIsNone(ep.shared)
self.assertIsNone(ep.settings)
self.assertIsNone(ep.title)
self.assertIsNone(ep.id)
self.assertIsNone(ep.path())
with self.assertR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_project(self):\n pass",
"def _determine_default_project(project=None):\n if project is None:\n project = _get_gcd_project()\n\n if project is None:\n project = _helpers._determine_default_project(project=project)\n\n return project",
"def test_create_project(self):\n ... | [
"0.7302375",
"0.69367903",
"0.6899856",
"0.6899856",
"0.6899856",
"0.6896533",
"0.6896533",
"0.6896533",
"0.68203735",
"0.6759572",
"0.6759572",
"0.67091924",
"0.6589286",
"0.65550405",
"0.6552097",
"0.65425485",
"0.6540739",
"0.6533683",
"0.63593394",
"0.6352195",
"0.6341002... | 0.7610206 | 0 |
Should abort stopping and not raise an error when no internal step is available to stop. | def test_step_stop_aborted(self, _step: PropertyMock):
_step.return_value = None
es = exposed.ExposedStep()
es.stop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gracefully_stop(self):\n pass",
"def halt(*_, **kwargs):\n raise ExecutionFinished(\"Reached halt\")",
"def stop() -> None:",
"def abort() -> NoReturn:\n raise AbortSignal",
"def stop(self) -> None:\n ...",
"def stop(self) -> None:",
"def stop(self) -> None:",
"def abort(self... | [
"0.7060672",
"0.6969455",
"0.6947691",
"0.6831138",
"0.6816764",
"0.6798415",
"0.6798415",
"0.6757007",
"0.6750949",
"0.6735412",
"0.6730144",
"0.66933066",
"0.66833615",
"0.6682303",
"0.6665194",
"0.6663481",
"0.66407984",
"0.6631349",
"0.6631349",
"0.6631349",
"0.6631349",
... | 0.7588589 | 0 |
Should abort stopping and not raise an error when no internal project is available to stop. | def test_project_stop_aborted(self, get_internal_project: MagicMock):
get_internal_project.return_value = None
ep = exposed.ExposedProject()
ep.stop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stopBuild(reason=\"<no reason given>\"):",
"def _gracefully_stop(self):\n pass",
"def abort(self):\n try:\n self.acqRunning = False\n except:\n print('Cannot abort properly')",
"def stop() -> None:",
"def test_stop_project(self):\n support.create_projec... | [
"0.7033246",
"0.6999605",
"0.68412125",
"0.6814739",
"0.66516757",
"0.6600153",
"0.6580697",
"0.6565686",
"0.6565686",
"0.6565686",
"0.6565686",
"0.65105325",
"0.6509005",
"0.6509005",
"0.6490828",
"0.64628285",
"0.6435273",
"0.6418074",
"0.640065",
"0.6397539",
"0.63974357",... | 0.7577744 | 0 |
Should fail to get internal project and return None after eventually timing out. | def test_get_internal_project_fail(
self,
sleep: MagicMock,
time_time: MagicMock,
internal_project: PropertyMock
):
project = exposed.ExposedProject()
time_time.side_effect = range(20)
internal_project.return_value = None
result = proje... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_internal_project(\n self,\n sleep: MagicMock,\n internal_project: PropertyMock\n ):\n project = exposed.ExposedProject()\n internal_project.side_effect = [None, None, None, 'test']\n result = project.get_internal_project()\n self.assertEq... | [
"0.70699006",
"0.68557197",
"0.66254395",
"0.64616627",
"0.63413024",
"0.62891513",
"0.62088645",
"0.61985654",
"0.612253",
"0.60614514",
"0.60256624",
"0.6006625",
"0.5999078",
"0.59616834",
"0.5941112",
"0.5911068",
"0.5911068",
"0.59038454",
"0.5900037",
"0.5870759",
"0.58... | 0.7359438 | 0 |
Should write to the console using a write_source function call on the internal step report's stdout_interceptor. | def test_write_to_console(self, _step: PropertyMock):
trials = [2, True, None, 'This is a test', b'hello']
for message in trials:
_step_mock = MagicMock()
write_source = MagicMock()
_step_mock.report.stdout_interceptor.write_source = write_source
_step.re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_render_to_console(self, _step: PropertyMock):\n message = ' {{ a }} is not {{ b }}.'\n\n _step_mock = MagicMock()\n write_source = MagicMock()\n _step_mock.report.stdout_interceptor.write_source = write_source\n _step.return_value = _step_mock\n step = exposed.E... | [
"0.7060722",
"0.6297328",
"0.62191683",
"0.6036808",
"0.59491473",
"0.5853387",
"0.58372104",
"0.5825977",
"0.5810231",
"0.5803809",
"0.5773342",
"0.57336247",
"0.5707204",
"0.5692095",
"0.56633615",
"0.5617709",
"0.5614963",
"0.55947864",
"0.55731905",
"0.5567739",
"0.556441... | 0.7509089 | 0 |
Should render to the console using a write_source function call on the internal step report's stdout_interceptor. | def test_render_to_console(self, _step: PropertyMock):
message = ' {{ a }} is not {{ b }}.'
_step_mock = MagicMock()
write_source = MagicMock()
_step_mock.report.stdout_interceptor.write_source = write_source
_step.return_value = _step_mock
step = exposed.ExposedStep()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_write_to_console(self, _step: PropertyMock):\n trials = [2, True, None, 'This is a test', b'hello']\n\n for message in trials:\n _step_mock = MagicMock()\n write_source = MagicMock()\n _step_mock.report.stdout_interceptor.write_source = write_source\n ... | [
"0.7027907",
"0.6089574",
"0.59871966",
"0.5953501",
"0.5823776",
"0.58008",
"0.5722767",
"0.569426",
"0.5688539",
"0.5679437",
"0.56706893",
"0.5645537",
"0.5632503",
"0.5632419",
"0.5579383",
"0.55504066",
"0.54777354",
"0.5475465",
"0.547519",
"0.5462693",
"0.5446832",
"... | 0.75739104 | 0 |
Should raise a ValueError when there is no current step to operate upon by the write function call. | def test_write_to_console_fail(self, _step: PropertyMock):
_step.return_value = None
step = exposed.ExposedStep()
with self.assertRaises(ValueError):
step.write_to_console('hello') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _step(self) -> None:",
"def step(self):\r\n raise NotImplementedError",
"def step(self):\n raise NotImplementedError()",
"def step(self):\n raise NotImplementedError()",
"def step(self):\n raise NotImplementedError()",
"def step(self):\n raise NotImplementedError(\n... | [
"0.60865235",
"0.6002841",
"0.59607214",
"0.59607214",
"0.59607214",
"0.59400934",
"0.5931165",
"0.59239656",
"0.59183896",
"0.5840517",
"0.57957006",
"0.5792233",
"0.57350117",
"0.57000464",
"0.5628943",
"0.5625073",
"0.5619831",
"0.56141627",
"0.5597384",
"0.5548896",
"0.55... | 0.6328565 | 0 |
Should render an empty stack frame when the stack data is invalid. | def test_render_stop_display_error(
self,
get_formatted_stack_frame: MagicMock,
render_template: MagicMock
):
get_formatted_stack_frame.return_value = None
step = MagicMock()
exposed.render_stop_display(step, 'FAKE')
self.assertEqual({}, render_tem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_empty_stack() -> None:\n with raises(GrammarParseError):\n grammar_parser.parse(\"ab}\", lexer_mode=\"VALUE_MODE\")",
"def empty(self):\r\n return len(self.stack) == 0",
"def show_stack(self) -> None:\n print(\"Show stack: \")\n ok = 1\n for i in reversed(self.ite... | [
"0.6172748",
"0.6088951",
"0.6082694",
"0.6078208",
"0.6071998",
"0.6070815",
"0.604263",
"0.6012433",
"0.5990902",
"0.5990902",
"0.5970938",
"0.5947907",
"0.58997005",
"0.58715206",
"0.58715206",
"0.5864916",
"0.58454406",
"0.58197826",
"0.58059406",
"0.5792144",
"0.5775396"... | 0.61049175 | 1 |
Calculates % of alphanumeric characters in string. | def _alnum_percent(line):
total = len(line)
test_set = set()
for letter in string.ascii_letters:
test_set.add(letter)
test_set.add(' ')
# Return a failure (no good characters) if there are no characters
if total < 1:
return 0
alnum_count = 0
star_count = 0
bar_count = 0
for letter in line... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def letter_percent(s):\r\n\r\n alpha = 'abcdefghijklmnopqrstuvwxyz'\r\n s_lower = s.lower()\r\n s_length = 0\r\n letter_count = {} # empty dictionary\r\n keys = letter_count.keys()\r\n\r\n for char in s_lower:\r\n if char in alpha:\r\n s_length = s_length + 1\r\n if ... | [
"0.73372185",
"0.6893399",
"0.6517647",
"0.63861024",
"0.61528224",
"0.6047942",
"0.60439736",
"0.5990186",
"0.58984005",
"0.588371",
"0.5831391",
"0.58165365",
"0.57671547",
"0.5763353",
"0.57626456",
"0.57338387",
"0.5726077",
"0.5723785",
"0.5721825",
"0.57174385",
"0.5693... | 0.75368613 | 0 |
Analyzes text lines, in order read from OCR processing. Populates the MailFields object with information gathered from OCR. Uses information from each of the lines to best figure out who is the main addresssee and which box it is trying to reach. | def parse_text_lines(self, text_lines):
self.__fields = mail_fields.MailFields()
alphanum_threshold = 0.5
# Only evaluate lines that are predominantly alphanumeric
for line in text_lines:
if _alnum_percent(line) > alphanum_threshold:
try:
parsed = usaddress.tag(line)[0]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(self) -> None:\n self.parsed = email.message_from_bytes(self.rawmailcontent, policy=email.policy.EmailPolicy()) # type: email.message.EmailMessage\n\n self.subject = self.parsed[\"subject\"]\n\n if self.parsed[\"X-Jicket-Initial-ReplyID\"] is not None and self.parsed[\"X-Jicket-... | [
"0.60554934",
"0.58570105",
"0.5800822",
"0.57903785",
"0.5709253",
"0.5683452",
"0.56657594",
"0.5564154",
"0.54445773",
"0.5323824",
"0.52994883",
"0.5294524",
"0.5293484",
"0.5284312",
"0.52493984",
"0.5248615",
"0.5206312",
"0.51865774",
"0.5184688",
"0.5175195",
"0.51648... | 0.7433099 | 0 |
Test the clear method works for posixbased systems | def test_clear_posix(self):
with mock.patch("hangman.cli.screen.os.system") as mock_system:
hangman.cli.screen.Screen.clear()
mock_system.assert_called_with("clear") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear():\n\n # windows \n if os.name == \"nt\": \n _ = os.system(\"cls\") \n # mac and linux\n else: \n _ = os.system(\"clear\")",
"def clear(): \n if os.name == \"nt\":\n os.system(\"cls\")\n else:\n os.system(\"clear\")",
"def clear():\r\n if name == 'nt... | [
"0.7761506",
"0.7746805",
"0.7741762",
"0.772958",
"0.7596242",
"0.74570656",
"0.7336103",
"0.7284548",
"0.72207433",
"0.72207433",
"0.71165365",
"0.7097402",
"0.7097402",
"0.70822984",
"0.6909185",
"0.68754077",
"0.6858489",
"0.6781232",
"0.6764691",
"0.6755633",
"0.67161864... | 0.79437184 | 0 |
Test the goodbye method | def test_goodbye(self):
with mock.patch("builtins.print") as mock_print:
hangman.cli.screen.Screen.goodbye()
output = ",".join([str(x) for x in mock_print.call_args_list])
self.assertTrue("Goodbye" in output) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goodbye(self, args):\n\t\tself.write_line(\"GOODBYE\")\n\t\tself.close();",
"async def testgoodbye(self, ctx, *, member = None):\n\n # Check if we're suppressing @here and @everyone mentions\n if self.settings.getServerStat(ctx.message.guild, \"SuppressMentions\"):\n suppress = True\... | [
"0.7509933",
"0.6987562",
"0.6891158",
"0.6829135",
"0.68261707",
"0.68175083",
"0.6816748",
"0.6797453",
"0.6768984",
"0.6768984",
"0.6768984",
"0.67623085",
"0.67623085",
"0.67623085",
"0.67440975",
"0.66107154",
"0.658389",
"0.6566832",
"0.65569544",
"0.65374553",
"0.65335... | 0.7486902 | 1 |
Returns the total number of hives in this apiary. | def hives_count(self) -> int:
return self.hives.count() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(self) -> float:\n return pulumi.get(self, \"count\")",
"def count(self) -> int:\n return pulumi.get(self, \"count\")",
"def total_number_of_animals(self):\n animals = self.animal()\n print 'Total number of animals on island: {:4}'.format(\n animals[\"Herbivores\... | [
"0.6977683",
"0.6883911",
"0.6836276",
"0.6753868",
"0.6753868",
"0.6753868",
"0.6739675",
"0.67286235",
"0.67053115",
"0.66854024",
"0.6670815",
"0.66571957",
"0.6634862",
"0.6606549",
"0.65562564",
"0.6529486",
"0.6525879",
"0.65013546",
"0.64641476",
"0.64448",
"0.64448",
... | 0.8205529 | 0 |
Convenience method which overrides the call method to call the getExpansion function | def __call__(self, data):
return self.getExpansion(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getExpansion(self, data):\n pass",
"def expansion_method(self, expansion_method):\n\n self._expansion_method = expansion_method",
"def expand(self) -> List[TOKEN]:\n return [self.function, *self.args]",
"def get_expansion(block, expansion=None):\n if isinstance(expansion, int):\n ... | [
"0.74891585",
"0.5920144",
"0.54512185",
"0.5370277",
"0.53289384",
"0.5261651",
"0.5257707",
"0.5253625",
"0.5253625",
"0.5253625",
"0.5253625",
"0.5253625",
"0.525186",
"0.5245593",
"0.51983786",
"0.5187937",
"0.51806074",
"0.51613045",
"0.51613045",
"0.5146855",
"0.5107178... | 0.775161 | 0 |
Imports a database from the tmp directory. Use very carefully! (or just to remind yourself how to import mysql data) Modify this code directly if needed, as it hardwires the username, db name and filename. | def mysql_import():
# first make another copy of the db
run("mysqldump -u database_user database_name -p > ~/tmp/exported_db_temp.sql")
# then import from the backup
run("mysql -u database_user -p -D database_name < ~/tmp/exported_db.sql") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_db(import_file):\n import_data(import_file)",
"def test_load_database_from_path(tmp_path):\n path = tmp_path / \"test.db\"\n database = load_database(path_or_database=path, fast_logging=False)\n assert isinstance(database, DataBase)\n assert database.path is not None\n assert databas... | [
"0.68345016",
"0.64033103",
"0.6076044",
"0.6069602",
"0.60656613",
"0.6017671",
"0.59419686",
"0.59211564",
"0.5919211",
"0.5879916",
"0.57659775",
"0.5732443",
"0.5716429",
"0.5715574",
"0.5714675",
"0.5714328",
"0.568365",
"0.56806725",
"0.56564546",
"0.5650345",
"0.564375... | 0.7754526 | 0 |
Set up an ssh shortcut. Called by setup_ssh_keys. You can call it separately if desired. | def update_ssh_shortcut(output_keyfile, quickname=None):
if quickname:
with settings(warn_only=True):
local("touch $HOME/.ssh/config")
local(r"echo '' >> $HOME/.ssh/config")
local(r"echo 'Host %s' >> $HOME/.ssh/config" % quickname)
local(r"echo '' >> $HOME/.ssh/config")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createPuttyShortcuts(folder = \"Putty Connections\"):\n desktop = winshell.desktop()\n cpath = os.path.join(desktop, folder)\n\n if not os.path.exists(cpath):\n os.mkdir(cpath)\n \n for c in getPuttyConnections():\n if c.strip() != \"\":\n path = os.path.join(cpath, c + \".lnk\")\n ... | [
"0.6442464",
"0.64414567",
"0.6348135",
"0.61858404",
"0.61858267",
"0.6147583",
"0.6134668",
"0.6058073",
"0.59874713",
"0.58345175",
"0.5792532",
"0.5744603",
"0.572959",
"0.5720658",
"0.56933945",
"0.56765187",
"0.56707656",
"0.56636703",
"0.55993026",
"0.558472",
"0.55672... | 0.6833319 | 0 |
Generate a new SSH key and deliver it to the server. If quickname is provided, also set up an ssh shortcut. Use this to enable passwordless access to webfaction. | def setup_ssh_keys(output_keyfile="id_rsa", ssh_type="rsa", quickname=None):
with settings(warn_only=True):
local("mkdir -p $HOME/.ssh")
with cd("$HOME/.ssh"):
local("ssh-keygen -t %s -f %s" % (ssh_type, output_keyfile))
for host in env.hosts:
local("scp %s.pub %s:temp_id_key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_ssh_shortcut(output_keyfile, quickname=None):\n if quickname:\n with settings(warn_only=True):\n local(\"touch $HOME/.ssh/config\")\n local(r\"echo '' >> $HOME/.ssh/config\")\n local(r\"echo 'Host %s' >> $HOME/.ssh/config\" % quickname)\n local(r\"echo '' >> $HO... | [
"0.67290777",
"0.635065",
"0.6294067",
"0.62377936",
"0.61897206",
"0.5912573",
"0.58597594",
"0.5857335",
"0.5813296",
"0.5799843",
"0.57982856",
"0.5796951",
"0.5789643",
"0.56701356",
"0.56502396",
"0.5586603",
"0.5574599",
"0.5564199",
"0.5562149",
"0.55100757",
"0.549769... | 0.69770044 | 0 |
Installs pip itself if needed. | def install_pip():
with settings(warn_only=True):
run('mkdir $HOME/lib/python2.7')
run('easy_install-2.7 pip') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pip_install():\n _require_environment()\n remote(PIP_INSTALL_PREFIX)",
"def pipInstall(self):\n\n print \"Does Nothing\"",
"def _setup_pip(self, context):\n # We run ensurepip in isolated mode to avoid side effects from\n # environment vars, the current directory and anything else\... | [
"0.7695657",
"0.74213576",
"0.7209003",
"0.7197479",
"0.7096822",
"0.7030998",
"0.69859535",
"0.6862794",
"0.68612194",
"0.6831305",
"0.6793315",
"0.6789067",
"0.6607342",
"0.6605917",
"0.65682715",
"0.65639573",
"0.6522661",
"0.64693004",
"0.64424676",
"0.6357721",
"0.632134... | 0.7709263 | 0 |
Creates a new git repo on the server (do not include the .git ending in git_repo_name) | def create_prod_git_repo(git_repo_name):
with cd(git_dir):
run("git init --bare %s.git && cd %s.git && git config http.receivepack true" %
(git_repo_name,git_repo_name)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_storer_git_repo():\n # first make teh destination directory\n rel_repo_path = vmcheckerpaths.repository\n abs_repo_path = vmcheckerpaths.abspath(rel_repo_path)\n _mkdir_if_not_exist(abs_repo_path)\n\n # then, if missing, initialize a git repo in it.\n repo_path_git = os.path.join(abs_r... | [
"0.78584546",
"0.76648015",
"0.7265442",
"0.72380567",
"0.719079",
"0.7102667",
"0.709434",
"0.7067098",
"0.7028291",
"0.70168835",
"0.6969751",
"0.69651526",
"0.6953235",
"0.69130766",
"0.68735963",
"0.68264115",
"0.67686075",
"0.67527515",
"0.6737532",
"0.6696314",
"0.66333... | 0.805788 | 0 |
Adds the git repo on the server as the local .git repo's origin, and pushes master to it. (do not include the .git ending in git_repo_name) | def add_prod_repo_as_origin_and_push(git_repo_name):
local("""echo '[remote "origin"]' >> .git/config""")
local(r"echo ' fetch = +refs/heads/*:refs/remotes/origin/*' >> .git/config")
local(r"echo ' url = %s:webapps/git/repos/%s.git' >> .git/config" % (env.hosts[0], git_repo_name))
local(r"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(self):\n origin = self.git_repo.remotes.origin\n origin.push()",
"def push(ctx):\n dufl_root = ctx.obj['dufl_root']\n git = Git(ctx.obj.get('git', '/usr/bin/git'), dufl_root)\n git.run('push', 'origin', git.working_branch())",
"def push():\n branch = git.current_branch().name... | [
"0.74367875",
"0.7217327",
"0.7001284",
"0.68715334",
"0.6737078",
"0.6531534",
"0.65219814",
"0.6468138",
"0.6464436",
"0.6363024",
"0.632618",
"0.62762666",
"0.6264901",
"0.62638634",
"0.6229483",
"0.62241775",
"0.61916083",
"0.6184975",
"0.6179584",
"0.61400473",
"0.607894... | 0.81499577 | 0 |
Updates the apache httpd.conf file to point to the new project instead of the default 'myproject'. This is called as part of clone_into_project, or you can call | def update_conf_file():
filepath = remote_dir + "/apache2/conf/httpd.conf"
fabric.contrib.files.sed(filepath, 'myproject', project_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_project():\n _require_environment()\n\n # Grants write rights on log dir for the admin group\n log_dir = '%s/log' % _interpolate(VIRTUALENV_DIR)\n if files.exists(log_dir):\n sudo('chmod -R g+w %s' % log_dir)\n\n # Updates from git, issues Django syncdb, South migrate, Collecstatic... | [
"0.6472111",
"0.6156051",
"0.6123365",
"0.5980424",
"0.5979637",
"0.5878512",
"0.57706547",
"0.56331587",
"0.55369204",
"0.5507125",
"0.54162174",
"0.5402613",
"0.53572744",
"0.52999634",
"0.5277135",
"0.52048105",
"0.5179632",
"0.5174573",
"0.5156144",
"0.514356",
"0.5130455... | 0.72978866 | 0 |
Clones the git repo into the new webapp, deleting the default myproject project and updating the config file to point to the new project. Also adds a site_settings.py file to the project/project folder. | def clone_into_project(git_repo_name):
repo_dir = git_dir + "/%s.git" % git_repo_name
with cd(remote_dir):
run('rm -rf myproject')
run("git clone %s %s" % (repo_dir, project_name))
run("echo 'MY_ENV=\"prod\"' > %s/%s/site_settings.py" % (project_name,project_name))
update_conf_file() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_project():\n _require_environment()\n\n # Grants write rights on log dir for the admin group\n log_dir = '%s/log' % _interpolate(VIRTUALENV_DIR)\n if files.exists(log_dir):\n sudo('chmod -R g+w %s' % log_dir)\n\n # Updates from git, issues Django syncdb, South migrate, Collecstatic... | [
"0.6597053",
"0.6376039",
"0.6335648",
"0.61842006",
"0.6173729",
"0.6145058",
"0.6005152",
"0.59648216",
"0.595788",
"0.59347206",
"0.5933034",
"0.5923805",
"0.59103745",
"0.58390486",
"0.5812732",
"0.57964295",
"0.572337",
"0.56827134",
"0.5680887",
"0.5663389",
"0.56439286... | 0.7331329 | 0 |
Adds the "/static" and "/media" directories to the static webapp if needed, and deletes the default index.html. Also adds a project/project/static directory if there isn't one. | def add_dirs_to_static(static_webapp_name):
static_dir = '$HOME/webapps/%s' % static_webapp_name
with settings(warn_only=True):
with cd(static_dir):
run("mkdir static && mkdir media")
run("rm index.html")
run("touch index.html")
with cd(code_dir):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include_static_files(app):\n file_path = sphinx_prolog.get_static_path(STATIC_FILE)\n if file_path not in app.config.html_static_path:\n app.config.html_static_path.append(file_path)",
"def ensure_static_exists():\n for entry in html_static_path:\n static_path = os.path.join(__repo_doc... | [
"0.70106965",
"0.68311924",
"0.6625952",
"0.63648784",
"0.61918205",
"0.60434896",
"0.5981367",
"0.58381754",
"0.5810352",
"0.57726264",
"0.57547545",
"0.57248443",
"0.56464094",
"0.5618542",
"0.56139016",
"0.5593905",
"0.55286866",
"0.55245644",
"0.5519247",
"0.55121106",
"0... | 0.7912355 | 0 |
Initialises the database to contain the tables required for DjangoCMS with South. Runs syncdb all and migrate fake. | def initialise_database():
with cd(code_dir):
run(python_add_str + "python manage.py syncdb --all")
run(python_add_str + "python manage.py migrate --fake") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_database():\n from django.core.management import call_command\n from django import setup\n setup()\n call_command('migrate', verbosity=0, interactive=False)\n call_command('loaddata', data('initial_data.json'), verbosity=0, interactive=False)",
"def init_db():\n db = get_db()\n Pag... | [
"0.7663976",
"0.75398517",
"0.75250465",
"0.7471838",
"0.7441649",
"0.7391628",
"0.73528063",
"0.72446615",
"0.72148156",
"0.72110015",
"0.71857905",
"0.7177211",
"0.7132408",
"0.7070013",
"0.705777",
"0.7000869",
"0.69667584",
"0.69374496",
"0.6935844",
"0.6935844",
"0.68986... | 0.8100372 | 0 |
Binary mask from cv2 styled contour (gets filled) | def make_mask(shape, contour):
mask = np.zeros(shape, np.int32)
cv2.drawContours(mask, [contour], 0, (255), -1)
return mask | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_contour_features(mask,selectcell=\"centered\"):\r\n \r\n #binarize image (everything above 0 becomes 1)\r\n mask = np.clip(mask,a_min=0,a_max=1)\r\n\r\n #for contours, dont use RETR_TREE, but RETR_EXTERNAL as we are not interested in internal objects\r\n contours, _ = cv2.findContours(mask, ... | [
"0.7214323",
"0.70771843",
"0.694643",
"0.69156",
"0.6753374",
"0.6689051",
"0.66160184",
"0.66025215",
"0.65440816",
"0.6517318",
"0.65129876",
"0.64886975",
"0.6453866",
"0.64246404",
"0.64205784",
"0.6411343",
"0.63934743",
"0.6383716",
"0.6381961",
"0.6374727",
"0.6347511... | 0.7433139 | 0 |
Converts either bytes or unicode to `bytes`, using utf8 encoding for text. | def as_bytes(bytes_or_text, encoding='utf-8'):
if isinstance(bytes_or_text, _six.text_type):
return bytes_or_text.encode(encoding)
elif isinstance(bytes_or_text, bytes):
return bytes_or_text
else:
raise TypeError('Expected binary or unicode string, got %r' %
(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_bytes(value: Union[str, bytes]) -> bytes:\n return value if isinstance(value, bytes) else value.encode(\"utf-8\")",
"def ensure_utf8_bytes(v: Union[str, bytes]) -> bytes:\n if isinstance(v, str):\n v = v.encode(\"utf-8\")\n return v",
"def force_utf8(text):\n if isinstance(text, bina... | [
"0.78761524",
"0.78181183",
"0.78134924",
"0.77963704",
"0.7775173",
"0.77212256",
"0.7695007",
"0.76554793",
"0.76551324",
"0.76297563",
"0.7587289",
"0.75190413",
"0.74554324",
"0.74133134",
"0.74104327",
"0.74089986",
"0.73655003",
"0.73444015",
"0.72940016",
"0.72861797",
... | 0.7902959 | 0 |
Adds a node to the front of the list with value 'val' | def push_front(self, val):
new_node = Node(val, self.head)
if self.is_empty():
self.tail = new_node
self.head = new_node
self.size += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_front(self, val: Generic[T]) -> None:\n first_node = self.node.next\n\n self.node.next = Node(val)\n latest_first = self.node.next\n\n latest_first.prev = self.node #pushes the node to the front\n latest_first.next = first_node\n first_node.prev = latest_f... | [
"0.80221725",
"0.7826861",
"0.7751701",
"0.77292",
"0.7605654",
"0.75942093",
"0.75738394",
"0.755168",
"0.7545137",
"0.7532508",
"0.75297654",
"0.75297654",
"0.75270396",
"0.75006205",
"0.7481478",
"0.7417329",
"0.7411148",
"0.7410026",
"0.7406186",
"0.74055594",
"0.738027",... | 0.7917012 | 1 |
Adds a node to the back of the list with value 'val' | def push_back(self, val):
new_node = Node(val)
# Update current head and tail, if necessary
if self.is_empty():
self.head = new_node
else:
self.tail.next_node = new_node
# new_node is now the tail
self.tail = new_node
self.size += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_back(self, val: Generic[T]) -> None:\n last_node = self.node.prev\n self.node.prev = Node(val) #pushes the node to the back\n latest_first = self.node.prev\n\n latest_first.next = self.node #rearranges the list\n latest_first.prev = last_node\n ... | [
"0.8086445",
"0.7602821",
"0.75396514",
"0.74361414",
"0.7427383",
"0.7410255",
"0.74002004",
"0.7388654",
"0.73812497",
"0.7362498",
"0.7361017",
"0.73132956",
"0.73118097",
"0.7306703",
"0.72853166",
"0.7268352",
"0.72647965",
"0.7225639",
"0.7210625",
"0.7206143",
"0.71408... | 0.80715704 | 1 |
List all registered posts | def get(self):
return get_all_posts() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_all_posts():\n post = Post.query.all()\n\n return render_template('all-posts.html', post=post)",
"def get_posts(self):\n return self.blog_posts.all()",
"def post_list(request):\n # Only show the posts that have been published\n posts = Post.objects.filter(date_published__isnull=Fals... | [
"0.743275",
"0.69572014",
"0.687439",
"0.6832434",
"0.67154205",
"0.66296536",
"0.66215444",
"0.65834826",
"0.6543941",
"0.6530415",
"0.6451439",
"0.64244354",
"0.6422649",
"0.6408737",
"0.6408558",
"0.6405169",
"0.6393117",
"0.6386442",
"0.6368651",
"0.6358445",
"0.63418925"... | 0.7320014 | 1 |
get a post given its title | def get(self, title):
post = get_a_post(title)
if not post:
api.abort(404)
else:
return post | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_by_title(title: str) -> dict:\n post = Posts.query.filter_by(title=title).first()\n if post is None:\n return {\"status\": 404, \"message\": \"No Post Available\"}\n return {\n \"title\": post.title,\n \"body\": markdown.markdo... | [
"0.7257662",
"0.6715822",
"0.6635556",
"0.66111004",
"0.66026914",
"0.65306",
"0.64700407",
"0.6466437",
"0.64379615",
"0.62551534",
"0.6247926",
"0.6238597",
"0.6233855",
"0.6216439",
"0.61509603",
"0.61505276",
"0.6148375",
"0.6121378",
"0.61104965",
"0.60835755",
"0.603844... | 0.8569673 | 0 |
Reinvite an already invited user. | def reinvite_user(self, user, email):
if self.is_moderator and self.has_perm('accounts.invite_user'):
# Reset email, set a new token and update decision datetime
user.email = email
user.auth_token = generate_unique_id()
user.decision_datetime = timezone.now()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invite_user(request):\r\n params = request.params\r\n\r\n email = params.get('email', None)\r\n user = request.user\r\n\r\n if not email:\r\n # try to get it from the json body\r\n email = request.json_body.get('email', None)\r\n\r\n if not email:\r\n # if still no email, I ... | [
"0.6742321",
"0.65622705",
"0.6341691",
"0.618192",
"0.6178779",
"0.6154837",
"0.61355495",
"0.60448194",
"0.5970474",
"0.59555095",
"0.592783",
"0.59243935",
"0.59088224",
"0.590702",
"0.5906705",
"0.5898827",
"0.577978",
"0.5737973",
"0.5707441",
"0.57018846",
"0.56371075",... | 0.7661665 | 0 |
Approve a user's application | def approve_user_application(self, user):
if self.is_moderator and \
self.has_perm('accounts.approve_user_application'):
user.moderator = self
user.moderator_decision = user.APPROVED
user.decision_datetime = timezone.now()
user.auth_token = generate_uni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def approve(self):\n self._check_if_open()\n data = {\"approved\": True}\n return self.post(\"approve\", data)",
"def can_approve(self, user, **data):\n raise Return(False)",
"def approve_me(message):\n users = hf.get_users()\n for user in users:\n if user[\"id\"] == me... | [
"0.7413602",
"0.71029663",
"0.67888886",
"0.6747213",
"0.67318124",
"0.67286676",
"0.6719018",
"0.66766196",
"0.6670902",
"0.65097535",
"0.64031065",
"0.63882875",
"0.63717735",
"0.63500285",
"0.634869",
"0.63414145",
"0.63078153",
"0.6297645",
"0.62773865",
"0.6240185",
"0.6... | 0.79233325 | 0 |
Reject a user's application | def reject_user_application(self, user):
if self.is_moderator \
and self.has_perm('accounts.reject_user_application'):
user.moderator = self
user.moderator_decision = user.REJECTED
user.decision_datetime = timezone.now()
user.save()
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_reject(user):\n if user.comments in (None or \"\"):\n return\n\n subject = \"ECE/CIS Account - Account Application rejected for %s\" % user.username\n application = \"https://www.eecis.udel.edu/NewAccount/\"\n helprequest = \"https://www.eecis.udel.edu/service\"\n sponsor = \"%s@eec... | [
"0.6770561",
"0.6585959",
"0.65521705",
"0.6491148",
"0.6487616",
"0.646831",
"0.63601846",
"0.63346696",
"0.6136011",
"0.61090565",
"0.607409",
"0.6064712",
"0.60478044",
"0.59528744",
"0.5923107",
"0.5874209",
"0.5872581",
"0.5852314",
"0.58413756",
"0.58047056",
"0.5798305... | 0.7710392 | 0 |
Return a user's profiency in a particular skill as a percentage, based on the position of the proficiency in PROFICIENCY_CHOICES. | def get_proficiency_percentage(self):
choice_values = [choice[0] for choice in self.PROFICIENCY_CHOICES]
if '' in choice_values:
choice_values.remove('') # Remove the empty proficiency choice
choice_values.sort() # Ensure values are in the correct order
value = choice_valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_opinion_percent(self):\n return (self.get_percent()+100)/2",
"def profit_per_item_percentage(self, pk=None):\n total_profit_percentage = 0\n total_cost = self.item_cost + self.shipping_cost + self.listing_fee + self.final_value_fee\n total_paid = self.shipping_paid + self.item... | [
"0.624777",
"0.5969812",
"0.58800423",
"0.57505316",
"0.57186955",
"0.57097393",
"0.57036775",
"0.56423104",
"0.5622649",
"0.5582169",
"0.5582169",
"0.55723554",
"0.5554754",
"0.55056655",
"0.5428772",
"0.53997266",
"0.53909737",
"0.53796136",
"0.53647095",
"0.53647095",
"0.5... | 0.8257786 | 0 |
Generate the preparation files for the projects in a run | def format_preparation_files(run_dir, sample_sheet, output_dir, pipeline,
verbose):
sample_sheet = KLSampleSheet(sample_sheet)
df_sheet = sample_sheet_to_dataframe(sample_sheet)
if pipeline == 'atropos-and-bowtie2':
click.echo('Stats collection is not supported for pipe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task_generate_tasks():\n \n yield {\n 'basename': 'generate_tasks',\n 'name': None,\n # 'doc': 'docs for X',\n 'watch': ['trains/'],\n 'task_dep': ['create_folders'],\n }\n \n for root, dirs, files in os.walk('trains/',topdown=False):\n for f in file... | [
"0.64848816",
"0.6330899",
"0.6330899",
"0.6330899",
"0.6284369",
"0.62667686",
"0.6219365",
"0.620572",
"0.6156918",
"0.6099373",
"0.60919136",
"0.60415375",
"0.60354227",
"0.60354227",
"0.6011478",
"0.6007769",
"0.5993345",
"0.59776956",
"0.59592646",
"0.59452546",
"0.59385... | 0.66563916 | 0 |
Return tokenized list of strings from raw text input using keras functionality | def tokenize_keras(raw_data):
from keras.preprocessing.text import text_to_word_sequence
return [text_to_word_sequence(d) for d in raw_data] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preproc_user_input(txt, model):\r\n txt = pre_process(txt)\r\n txt_tokenized = [word for word in txt.split(\" \") if word in model.wv.vocab]\r\n return \" \".join(txt_tokenized)",
"def input_new_phrase(self, text):\n \n x_new_tokens = [word_idx[word] for word in text.split()]\n \n pred ... | [
"0.70793176",
"0.6935871",
"0.6846465",
"0.6740176",
"0.66016084",
"0.6601571",
"0.65836084",
"0.6577888",
"0.656995",
"0.6567432",
"0.65455496",
"0.654399",
"0.6511661",
"0.65019155",
"0.6500425",
"0.649716",
"0.64943504",
"0.6473806",
"0.6438927",
"0.64235365",
"0.64078707"... | 0.8465603 | 0 |
Return True if word passes filter | def filter1(word):
if not word: return False
w = word.lower()
if w in STOPWORDS: return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_word_filter(self, fn):\n self._apply_filter(lambda ng, f: any(fn(w) for w in ng))",
"async def wordfilter(self, ctx):\n pass",
"async def wordfilter_test(self, ctx, *, message):\n found = self.test_sentence(message)\n if found:\n await ctx.send(f\"Message contai... | [
"0.74591035",
"0.7444302",
"0.7269609",
"0.71056175",
"0.7085896",
"0.69943607",
"0.6989586",
"0.68581426",
"0.6818804",
"0.67899287",
"0.6701206",
"0.6658593",
"0.66539127",
"0.6639391",
"0.6632937",
"0.66313547",
"0.6630455",
"0.6528471",
"0.65281737",
"0.6523878",
"0.65221... | 0.78754514 | 0 |
Return dict of wordtoid from raw text data If max_size is specified, vocab is truncated to set of highest frequency words within size. | def build_vocab(raw_data, max_size=None):
data = [w for doc in tokenize_keras(raw_data) for w in doc]
counter = collections.Counter(data)
count_pairs = sorted(counter.items(),
key=lambda x: (-x[1], x[0]))
if max_size: count_pairs = count_pairs[:max_size]
words, _ = list(zip(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vocab(self):\n word2id = {}\n for document in self.docs:\n for word in document:\n if word not in word2id.keys():\n word2id[word] = len(word2id)\n return word2id",
"def build_vocab(sentences, max_num_words):\n # Build vocabulary\n wo... | [
"0.6375627",
"0.6333941",
"0.63053066",
"0.6265616",
"0.6252101",
"0.6250396",
"0.62214345",
"0.6192168",
"0.6157442",
"0.60978895",
"0.6085281",
"0.6050244",
"0.6039959",
"0.6008718",
"0.6007198",
"0.6006812",
"0.59851426",
"0.59756815",
"0.59671265",
"0.5960956",
"0.5825441... | 0.7943447 | 0 |
Convert raw text data into integer ids | def raw_to_ids(raw_data, word_to_id):
docs = tokenize_keras(raw_data)
uid = word_to_id[UNKNOWN_WORD]
return [[word_to_id.get(w, uid) for w in doc] for doc in docs] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text2ids(self, text: str, length: int):\n # Tokenize\n tokens = self.tokenizer.tokenize(text)\n token_ids = self.tokenizer.tokens2ids(tokens)\n # Padding\n while len(token_ids) < length:\n token_ids.append(0)\n # Truncate\n if len(token_ids) > length:... | [
"0.672705",
"0.6686971",
"0.66411066",
"0.66214275",
"0.6610237",
"0.6563587",
"0.650595",
"0.6494439",
"0.6406515",
"0.6315634",
"0.6188173",
"0.6168283",
"0.6166879",
"0.6148879",
"0.60975975",
"0.6084565",
"0.6077067",
"0.6060543",
"0.60536844",
"0.60036033",
"0.59868073",... | 0.7270317 | 0 |
callback for when the detector has found a stop sign. Note that a distance of 0 can mean that the lidar did not pickup the stop sign at all | def stop_sign_detected_callback(self, msg):
# distance of the stop sign
corners = msg.corners
dx = corners[3] - corners[1]
dy = corners[2] - corners[0]
r = dx/dy # aspect ratio
rdist = np.array([.15, .20, .25, .30,.35, .40, .45, .50])
pixelheight = np.array([13... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _detect_stop(func):\n def wrapper(*args,**kwargs):\n self = args[0]\n self.episode_length -= 1\n if self.episode_length <=0:\n \"\"\"if the episode is end\"\"\"\n self.end = True\n else:\n if self.adsorption:\n ... | [
"0.59943485",
"0.56399006",
"0.5583566",
"0.5494318",
"0.54302335",
"0.54221815",
"0.5411941",
"0.5367256",
"0.53257966",
"0.53016096",
"0.5254286",
"0.52245134",
"0.5204961",
"0.5185182",
"0.5171382",
"0.5162159",
"0.5156524",
"0.51438564",
"0.5138958",
"0.51210594",
"0.5090... | 0.70093864 | 0 |
Custom collate_fn that is called with list of multivariate samples to yield a minibatch It preserves the data structure, e.g., if each sample is a dictionary, it outputs a dictionary with the same set of keys but batched Tensors as values (or lists if the values can not be converted into Tensors). | def collate_fn(sample_list):
x_ref_batch = []
x_pos_batch = []
x_negs_batch = []
label_batch = []
for sample in sample_list:
x_ref_batch.append(sample["x_ref"])
x_pos_batch.append(sample["x_pos"])
x_negs_batch.append(sample["x_negs"])
label_batch.append(sample["label... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collate_fn(batch):\n\n flattened_batch = []\n for data in batch:\n num_examples = len(data['image'])\n for i in range(num_examples):\n flattened_batch.append({\n k: v[i] for k, v in data.items()\n })\n\n return default_collate(flattened_batch)",
"de... | [
"0.71019036",
"0.6699454",
"0.66386545",
"0.6537352",
"0.65236694",
"0.6492617",
"0.64010304",
"0.6400702",
"0.6383652",
"0.6318756",
"0.62709737",
"0.6211533",
"0.6105718",
"0.59736997",
"0.59524226",
"0.5950687",
"0.5934938",
"0.5909209",
"0.5867133",
"0.58421636",
"0.57569... | 0.67624515 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.