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 |
|---|---|---|---|---|---|---|
>>> tfm = PSTransform() >>> LineSegment(Point(0, 0), Point(1, 0)).postscript(tfm) '306.0 396.0 lineto 378.0 396.0 moveto' | def postscript(self, tfm):
return (tfm.format('{0} {1} lineto ', self.p1) +
tfm.format('{0} {1} moveto', self.p2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postscript(self, tfm):\n k = 180. / PI\n if self.angle_range.clockwise():\n a, b = self.angle_range.start, self.angle_range.finish\n else:\n a, b = self.angle_range.finish, self.angle_range.start\n return (tfm.format('{0} {1} ', self.center) +\n ... | [
"0.58846533",
"0.5812993",
"0.5740526",
"0.5379793",
"0.5304976",
"0.5210837",
"0.5098128",
"0.5069906",
"0.5061781",
"0.5048277",
"0.50333875",
"0.50174236",
"0.50158346",
"0.49841657",
"0.49388242",
"0.49265838",
"0.48961708",
"0.48790273",
"0.48632494",
"0.4860366",
"0.485... | 0.7476756 | 0 |
>>> LineSegment(Point(0, 0), Point(1, 0)) LineSegment((0,0), (1,0)) | def __repr__(self):
return 'LineSegment({0}, {1})'.format(self.p1, self.p2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createLineSegment(self):\n return _libsbml.Curve_createLineSegment(self)",
"def createLineSegment(self):\n return _libsbml.Layout_createLineSegment(self)",
"def line(points):\n return LineString(points)",
"def createLineSegment(self):\n return _libsbml.GeneralGlyph_createLineSegme... | [
"0.72106606",
"0.70376474",
"0.6866702",
"0.6816661",
"0.67462677",
"0.6648129",
"0.6617927",
"0.65004915",
"0.6392701",
"0.63844943",
"0.6346983",
"0.6311228",
"0.6241615",
"0.62122416",
"0.6210177",
"0.6207314",
"0.6160868",
"0.6140412",
"0.60893387",
"0.60420334",
"0.60319... | 0.7115233 | 1 |
>>> p1, p2 = Point(0, 0), Point(1, 0) >>> seg = LineSegment(p1, p2) >>> seg.param_to_point(0) == p1 True >>> seg.param_to_point(1) == p2 True >>> seg.param_to_point(0.5) == Point(0.5, 0) True | def param_to_point(self, param):
return self.p1 + param * (self.p2 - self.p1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point_to_param(self, pt):\n r = self.p2 - self.p1\n return (pt - self.p1).dot(r) / r.square()",
"def dist_to_point(self, point):\n\t\treturn dist_to_line2d_seg((self.a.to_tuple(),self.b.to_tuple()), point.to_tuple())",
"def line_param(point_a, point_b, t):\n new_point = point_a - point_b\n... | [
"0.6876588",
"0.66193455",
"0.6241705",
"0.6213389",
"0.6163717",
"0.6000711",
"0.5991964",
"0.59617895",
"0.5959313",
"0.5918417",
"0.59099036",
"0.58839566",
"0.5865199",
"0.58155835",
"0.5796937",
"0.57824886",
"0.5776108",
"0.57577264",
"0.5738541",
"0.57312596",
"0.57235... | 0.74114805 | 0 |
>>> seg = LineSegment(Point(0, 0), Point(1, 0)) >>> seg.point_to_param(Point(0, 1)) 0 >>> seg.point_to_param(Point(1, 1)) 1 | def point_to_param(self, pt):
r = self.p2 - self.p1
return (pt - self.p1).dot(r) / r.square() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def param_to_point(self, param):\n return self.p1 + param * (self.p2 - self.p1)",
"def line_param(point_a, point_b, t):\n new_point = point_a - point_b\n return point_b + t*new_point",
"def point_to_parameter(self, pt):\n uv = ShapeAnalysis_Surface(self.surface()).ValueOfUV(\n gp... | [
"0.67098206",
"0.58437604",
"0.5808367",
"0.5781741",
"0.57216614",
"0.5697626",
"0.56160396",
"0.55942684",
"0.5469736",
"0.54624003",
"0.5426168",
"0.5413337",
"0.53801966",
"0.53713965",
"0.5358662",
"0.5308702",
"0.52752256",
"0.52395874",
"0.52279246",
"0.521795",
"0.519... | 0.70094305 | 0 |
>>> AngleRange(0, 1).intersection(AngleRange(2, 3)) | def intersection(self, other):
a, b = min(self.start, self.finish), max(self.start, self.finish)
c, d = min(other.start, other.finish), max(other.start, other.finish)
a1 = normalize(a, 0, TWO_PI)
a, b = a1, b + a1 - a
c1 = normalize(c, 0, TWO_PI)
c, d = c1, d + c1 - c
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interval_intersect(b, a, d, c):\n return (d <= a) and (b <= c) # int2 lower <= int1 upper AND int1 lower <= int2 upper",
"def interval_intersect(a, b, c, d):\r\n return (c <= b) and (a <= d)",
"def ranges_overlap(start1, end1, start2, end2):\n return start1 <= end2 and end1 >= start2",
"def inte... | [
"0.6961142",
"0.68901646",
"0.66428983",
"0.65814406",
"0.6556519",
"0.64353484",
"0.6413068",
"0.63258123",
"0.6324006",
"0.6293021",
"0.62256324",
"0.618209",
"0.617776",
"0.6167389",
"0.61051816",
"0.6082974",
"0.6061148",
"0.6060571",
"0.60537374",
"0.6049184",
"0.6048017... | 0.7063069 | 0 |
>>> tfm, center = PSTransform(), Point(1, 0) upper half circle >>> Arc(center, 1, PI, 0).postscript(tfm) '378.0 396.0 72 0.0 180.0 arc' >>> Arc(center, 1, 0, PI).postscript(tfm) '378.0 396.0 72 0.0 180.0 arc' lower half circle >>> Arc(center, 1, PI, TWO_PI).postscript(tfm) '378.0 396.0 72 180.0 360.0 arc' >>> Arc(cente... | def postscript(self, tfm):
k = 180. / PI
if self.angle_range.clockwise():
a, b = self.angle_range.start, self.angle_range.finish
else:
a, b = self.angle_range.finish, self.angle_range.start
return (tfm.format('{0} {1} ', self.center) +
'{0} '.forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postscript(self, tfm):\n return (tfm.format('{0} {1} lineto ', self.p1) +\n tfm.format('{0} {1} moveto', self.p2))",
"def output(self):\n xpos, ypos = self.arcpoints[2]\n startxy = np.array([xpos, ypos]) # start point\n xpos, ypos = self.arcpoints[1]\n ... | [
"0.58153826",
"0.5513635",
"0.534185",
"0.5338048",
"0.53348184",
"0.53150916",
"0.5297564",
"0.52517813",
"0.5235955",
"0.5168656",
"0.5148232",
"0.51290214",
"0.51076967",
"0.50502115",
"0.5047317",
"0.50382435",
"0.503397",
"0.501881",
"0.5012607",
"0.49682286",
"0.4956724... | 0.7833728 | 0 |
>>> p1, p2 = Point(0, 0), Point(2, 0) >>> Arc.from_endpoints(p1, p2, 1) Arc((1.0,0.0),1,180.0,0.0) >>> Arc.from_endpoints(p1, p2, 1) Arc((1.0,0.0),1,180.0,360.0) >>> Arc.from_endpoints(p2, p1, 1) Arc((1.0,0.0),1,360.0,180.0) >>> Arc.from_endpoints(p2, p1, 1) Arc((1.0,0.0),1,0.0,180.0) >>> p1, p2, r = Point(1, 1), Point... | def from_endpoints(cls, p1, p2, radius):
# radius > 0 means we go clockwise from p1 to p2, radius < 0 means we go counter-clockwise
x = p2 - p1
if radius**2 < 0.25 * x.dot(x):
raise Exception("radius is too small for this arc, make it bigger")
w = (radius**2 - 0.25 * x.dot(x)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Arc( x, y0, y1, r):\n return 0.5 * r*r * ( np.arctan( (y1).astype(float)/(x).astype(float) ) - np.arctan( (y0).astype(float)/(x).astype(float) ) )",
"def createArc(self, start, finish):\n return Arc(start, finish)",
"def Arc(self, center=(0.,0.), radius=1., nrad=16, ncirc=40,\n start_angle... | [
"0.6723727",
"0.6515953",
"0.6461364",
"0.63957953",
"0.6276647",
"0.62342805",
"0.6219087",
"0.6149375",
"0.61468315",
"0.6137554",
"0.60967463",
"0.6093382",
"0.60369945",
"0.60079134",
"0.59980977",
"0.5988356",
"0.59547377",
"0.5905458",
"0.58958495",
"0.58899057",
"0.586... | 0.7708817 | 0 |
>>> me = Arc.from_endpoints(Point(0,0), Point(2,0), 1) >>> me.intersect('foo') | def intersect(self, other):
if isinstance(other, Arc):
if self.center == other.center:
if nearly_zero(self.radius - other.radius):
v = Arc(self.center, self.radius, 0, 0)
v.angle_range = self.angle_range.intersection(other.angle_range)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _arcArcIntersectXY(c1,c2,inside=True,params=False):\n x1=c1[0]\n x2=c2[0]\n r1=c1[1][0]\n r2=c2[1][0]\n\n # check for sample reverse condition\n sr1 = c1[1][3]==-2\n sr2 = c2[1][3]==-2\n\n ## first check for non-intersection due to distance between the\n ## centers of the arcs, treat... | [
"0.6679789",
"0.65497285",
"0.65160197",
"0.64776295",
"0.64027035",
"0.63585263",
"0.6221283",
"0.6192833",
"0.6165679",
"0.6152619",
"0.60648733",
"0.6053784",
"0.60018986",
"0.60005635",
"0.59932536",
"0.5963659",
"0.59488946",
"0.5945772",
"0.59424376",
"0.5927644",
"0.59... | 0.6790867 | 0 |
Create a user context based on a cluster's stored Keystone trust. | def make_cluster_context(cluster, show_deleted=False):
context = RequestContext(user_name=cluster.trustee_username,
password=cluster.trustee_password,
trust_id=cluster.trust_id,
show_deleted=show_deleted,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_context():\n return {'app': app, 'db': db, 'User': User}",
"def _make_context():\n return {'app': app, 'db': db, 'User': User}",
"def _make_context():\n return {'app': app,\n 'db': db,\n 'User': User\n }",
"def _make_context():\n\n return {\n 'app':... | [
"0.5965407",
"0.59498507",
"0.58217144",
"0.5815646",
"0.5801412",
"0.5688743",
"0.5554952",
"0.5467238",
"0.54271215",
"0.5412256",
"0.5404341",
"0.53961015",
"0.5374897",
"0.53746927",
"0.5358552",
"0.53158754",
"0.5300448",
"0.5287158",
"0.52825874",
"0.52765644",
"0.52642... | 0.63946825 | 0 |
Download the POJO for the leader model in AutoML to the directory specified by path. If path is an empty string, then dump the output to screen. | def download_pojo(self, path="", get_genmodel_jar=False, genmodel_name=""):
return h2o.download_pojo(self.leader, path, get_jar=get_genmodel_jar, jar_name=genmodel_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_mojo(self, path=\".\", get_genmodel_jar=False, genmodel_name=\"\"):\n return ModelBase.download_mojo(self.leader, path, get_genmodel_jar, genmodel_name)",
"def download_model(key, output_path):\n print(\"Looking fro model in {}\".format(output_path))\n if os.path.exists(output_path):\n ... | [
"0.6805856",
"0.5677127",
"0.5564327",
"0.5526138",
"0.54357004",
"0.54357004",
"0.54357004",
"0.54357004",
"0.54357004",
"0.54064924",
"0.5355542",
"0.53408563",
"0.52581507",
"0.52444184",
"0.52444184",
"0.52443415",
"0.52355677",
"0.5219559",
"0.5150729",
"0.514913",
"0.51... | 0.6896179 | 0 |
Retrieve a string indicating the project_name of the automl instance to retrieve. | def project_name(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_name(self) -> typing.Optional[str]:\n return self._values.get(\"project_name\")",
"def project_name(self) -> typing.Optional[str]:\n return self._values.get(\"project_name\")",
"def project_name(self) -> typing.Optional[str]:\n return self._values.get(\"project_name\")",
"def... | [
"0.75766367",
"0.75766367",
"0.75766367",
"0.75766367",
"0.75766367",
"0.75766367",
"0.75074005",
"0.75074005",
"0.75074005",
"0.75074005",
"0.75074005",
"0.75074005",
"0.74999297",
"0.74356097",
"0.74130285",
"0.73136413",
"0.7302438",
"0.72723585",
"0.72723585",
"0.72267807",... | 0.7629592 | 0 |
Retrieve the leaderboard from an H2OAutoML object | def leaderboard(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLeaderboard(self, **kwargs):\n board = []\n scores = sorted(self._players, key=lambda score: score.dct_net['total'])\n pos = 1\n prev_total = None\n for sc in scores:\n score_dct = {\n 'player': sc.doc,\n 'total' : sc.dct_net['total'],\n }\n if prev_total != None ... | [
"0.71753174",
"0.6814637",
"0.67305756",
"0.6534892",
"0.6010836",
"0.6006939",
"0.60041165",
"0.5990674",
"0.59727794",
"0.58822256",
"0.58502156",
"0.58502156",
"0.58473134",
"0.5838606",
"0.5764738",
"0.5730108",
"0.57219785",
"0.57013613",
"0.5653109",
"0.5608319",
"0.559... | 0.68511003 | 1 |
Retrieve the backend event log from an H2OAutoML object | def event_log(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLogs():",
"def getLogs():",
"def log(self):\r\n return self._log",
"def log(self):\n resp = requests.get(\"%s/api/log\"%self.urlbase, verify=False)\n return resp.json[\"log\"]",
"def get_eventlogs_detail(self, conn, id):\n path = urlJoin(urls.EVENT_LOG[\"GET\"], id)\n ... | [
"0.5895145",
"0.5895145",
"0.5818652",
"0.5775522",
"0.57516444",
"0.5684986",
"0.56431377",
"0.5545011",
"0.5513884",
"0.5493785",
"0.5493785",
"0.54921085",
"0.54801255",
"0.5439759",
"0.5415686",
"0.5415399",
"0.5406173",
"0.5406173",
"0.54029393",
"0.5401882",
"0.53920996... | 0.63432443 | 0 |
Get best model of a given family/algorithm for a given criterion from an AutoML object. | def get_best_model(self, algorithm=None, criterion=None):
from h2o.exceptions import H2OValueError
def _get_models(leaderboard):
return [m[0] for m in
leaderboard["model_id"].as_data_frame(use_pandas=False, header=False)]
higher_is_better = ["auc", "aucpr"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_model(self):\n return self.best_model",
"def get_best_model(res, model_type):\n if model_type == 'classification':\n # the best classification model according to f1 metric\n best = sorted([(k, v['f1']) for k, v in res.items()], key=lambda x: -x[1])[0]\n # the best regr... | [
"0.65354514",
"0.6436559",
"0.62489223",
"0.6159949",
"0.60301775",
"0.60104805",
"0.58534336",
"0.5849753",
"0.56639946",
"0.56572855",
"0.56554496",
"0.56159276",
"0.5615587",
"0.5601147",
"0.5595409",
"0.5568075",
"0.5552408",
"0.5526239",
"0.55151755",
"0.54995584",
"0.54... | 0.7380481 | 0 |
Get a cell's bounding box coordinates | def bounding_box(self, index_or_id):
cell_index = self.grid.insure_index(index_or_id)
left = self.cell_size[0] * cell_index[1] + self.origin[0]
top = self.cell_size[1] * cell_index[0] + self.origin[1]
right = left + self.cell_size[0]
bottom = top + self.cell_size[1]
return (left, top, right, bottom) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boundingBox(self):\n y_max = np.max(self.points[:,0])\n x_max = np.max(self.points[:,1])\n y_min = np.min(self.points[:,0])\n x_min = np.min(self.points[:,1])\n \n return ((x_max, y_max), (x_min, y_min))",
"def bounding_box(self):\n latlon00 = self.ij_to_latlo... | [
"0.7524594",
"0.73899823",
"0.7318858",
"0.72919244",
"0.72919244",
"0.7288416",
"0.72778505",
"0.7215684",
"0.7214053",
"0.7175839",
"0.7171557",
"0.7171143",
"0.7126568",
"0.71247655",
"0.70768714",
"0.70758456",
"0.70705795",
"0.7025306",
"0.7002235",
"0.69995075",
"0.6991... | 0.77145386 | 0 |
Add some status fields, specific to this microservice, to give a clue about selffitnes. This method is called after gathering the base actor status. So changing existing status fields will overwrite the response. | def status(self, status: dict):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_status(self):\n if self.headers['Accept'] != CONTENT_TYPE_STATUS:\n raise NotAcceptable()\n\n body = self.server.status()\n self._write_response(\n 200, body,\n content_type='application/se.novafaen.smrt.status.v1+json'\n )\n self.serv... | [
"0.6502432",
"0.6343856",
"0.61346763",
"0.60640275",
"0.60640275",
"0.6054969",
"0.60468",
"0.6018417",
"0.6018417",
"0.6018417",
"0.6018417",
"0.6018417",
"0.6018417",
"0.6018417",
"0.60125935",
"0.5956768",
"0.58687556",
"0.58687556",
"0.58687556",
"0.58687556",
"0.5868755... | 0.66898763 | 0 |
return infos from a .desktop file | def get_info_desktop(desktopfile):
name, cmd, icon, generic= "", "", "", ""
nameloc = False
geneloc = False
lang = locale.setlocale(locale.LC_ALL, "")[0:2]
with open(desktopfile,'r') as d:
df = d.readlines()
for l in df:
if generic == "" or geneloc == False:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_info():\r\n app = application.Application()\r\n\r\n app.start(r\"C:\\\\AL50022\\\\Circ\\\\bin\\\\Circ.exe\")\r\n\r\n app.Circ.menu_select(\"View\")",
"def parse(self, file):\n IniFile.parse(self, file, [\"Desktop Entry\", \"KDE Desktop Entry\"])",
"def _parseMediaInfo(self):\n\t\t# the ... | [
"0.6534352",
"0.60698557",
"0.56144017",
"0.5599252",
"0.5479898",
"0.5462303",
"0.54253316",
"0.5415696",
"0.54109067",
"0.54053926",
"0.5390978",
"0.5381943",
"0.5322215",
"0.5285531",
"0.5283228",
"0.5276574",
"0.5265289",
"0.52510995",
"0.5244691",
"0.523948",
"0.52115786... | 0.79934424 | 0 |
Return active company based on user's profile | def get_active_company(request):
from project.models import get_user_profile_ex
profile = get_user_profile_ex(request.user)
try:
company = profile.active_company
except:
company = None
if company is None:
raise Exception('Please select active company in user\'s profile')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_active_company_pk(request):\n active_company = get_active_company(request)\n return active_company and active_company.pk or None",
"def get_company_users(self, company_referece, active=True):\n url = 'companies/{0}/users'.format(company_referece)\n if active:\n data = {'sta... | [
"0.6089149",
"0.6082637",
"0.6071943",
"0.5895015",
"0.5895015",
"0.5895015",
"0.5895015",
"0.5884712",
"0.58581364",
"0.5846359",
"0.57815146",
"0.57746136",
"0.5733336",
"0.5733336",
"0.56848305",
"0.5656476",
"0.5638435",
"0.55426466",
"0.5528021",
"0.5509426",
"0.54802394... | 0.82013434 | 0 |
Return active company pk based on user's profile | def get_active_company_pk(request):
active_company = get_active_company(request)
return active_company and active_company.pk or None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_active_company(request):\n from project.models import get_user_profile_ex\n profile = get_user_profile_ex(request.user)\n try:\n company = profile.active_company\n except:\n company = None\n if company is None:\n raise Exception('Please select active company in user\\'s ... | [
"0.7610169",
"0.6473127",
"0.6097654",
"0.6097654",
"0.6062279",
"0.58767855",
"0.5866891",
"0.5841073",
"0.57657206",
"0.575413",
"0.57436687",
"0.56769633",
"0.5620573",
"0.5589516",
"0.55817324",
"0.5542347",
"0.5498362",
"0.54776585",
"0.54737616",
"0.54366016",
"0.540474... | 0.7791624 | 0 |
Generate a suitable invoice number for given object; | def generate_next_invoice_number(obj):
queryset = obj.__class__.objects.filter(year=obj.year, company=obj.company)
max = queryset.aggregate(Max('number')).values()[0]
if max is None:
max = 0
return (max + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_invNo(self, obj):\n return str(obj.invDate.year) + str(obj.id)",
"def invoice(self, invoice_number):\r\n return inv.Invoice(self, invoice_number)",
"def create_invoice(self):\n sales_tax = 0.06\n item_sum = 0\n inv = f'Invoice#: {self.invoice_id}\\n'\n for key,... | [
"0.7300732",
"0.6198336",
"0.6160349",
"0.6044071",
"0.60314023",
"0.60062176",
"0.5938249",
"0.5898966",
"0.5887895",
"0.5809442",
"0.5789716",
"0.57646215",
"0.573949",
"0.5655809",
"0.5655787",
"0.5655787",
"0.5655787",
"0.55716646",
"0.5546775",
"0.5536652",
"0.5502589",
... | 0.72478 | 1 |
Reconstructs a list of contour coordinates from the fourier descriptors Takes the length of the original contours to know how much to pad. | def reconstruct(descriptors, length):
padded = pad_descriptors(descriptors, length) # Pad descriptors
inversed = np.fft.ifft(padded) # Inverse Fourier transform
reconstructed = np.rint(np.column_stack((inversed.real, inversed.imag))).astype('int') # Convert to coordinates
return reconstructed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_descriptors(descriptors, length):\n \n padded = np.zeros(length, dtype='complex')\n degree = len(descriptors)\n descriptors = np.fft.fftshift(descriptors)\n \n center_index = length / 2\n left_index = center_index - degree / 2 # Left index always round down\n right_index = int(round... | [
"0.63926274",
"0.52539974",
"0.51878995",
"0.5187165",
"0.5159146",
"0.5142736",
"0.5059244",
"0.5041294",
"0.50263",
"0.50123715",
"0.5000883",
"0.49830064",
"0.49202907",
"0.49104097",
"0.4898262",
"0.48702744",
"0.4861574",
"0.4837805",
"0.4827184",
"0.48218665",
"0.481173... | 0.66475296 | 0 |
Latent heat of vapourisation is approximated by a linear func of air temp (J kg1) | def latent_heat_vapourisation(self, tair):
return (2.501 - 0.00237 * tair) * 1E06 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_evaporation_latent_heat() -> float:\n theta = 28.0\n return 2500.8 - 2.3668 * theta",
"def heat_vaporization_func(ts):\n heat_vaporization = np.copy(ts).astype(np.float64)\n heat_vaporization -= 273.15\n heat_vaporization *= -0.00236\n heat_vaporization += 2.501\n heat_vaporization *... | [
"0.7173018",
"0.69608897",
"0.61423993",
"0.61281765",
"0.6077439",
"0.60561836",
"0.6050125",
"0.6003145",
"0.590397",
"0.58907586",
"0.58311015",
"0.58004564",
"0.57759726",
"0.577098",
"0.577019",
"0.57701373",
"0.5768532",
"0.576528",
"0.57489395",
"0.57373637",
"0.572774... | 0.7419154 | 0 |
Perform several steps of simulation with constant action | def _simulate(self, action=None):
for k in range(int(self.SIMULATION_FREQUENCY // self.config["policy_frequency"])):
if action is not None and \
self.time % int(self.SIMULATION_FREQUENCY // self.config["policy_frequency"]) == 0:
# Forward action to the spacecraft
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, steps):\n self.sim.run(steps)",
"def step_simulation(self, action):\n # target = np.zeros(6)\n # a = np.copy(action)\n # for i in range(6):\n # target[i] = a[i] + ref_pos[i + 3]\n\n target = action * 1.5\n # target = action + ref_pos[3:9]\n\n ... | [
"0.7152286",
"0.71506226",
"0.71068823",
"0.7042311",
"0.6963255",
"0.69249856",
"0.68964875",
"0.68964875",
"0.68496585",
"0.6815086",
"0.680374",
"0.6802927",
"0.67813265",
"0.6766567",
"0.67615855",
"0.6758372",
"0.67467135",
"0.6737128",
"0.6646202",
"0.6641702",
"0.66414... | 0.737022 | 0 |
Render the environment. Create a viewer if none exists, and use it to render an image. | def render(self, mode='human'):
self.rendering_mode = mode
if self.viewer is None:
self.viewer = EnvViewer(self, offscreen=self.offscreen)
self.enable_auto_render = not self.offscreen
# If the frame has already been rendered, do nothing
if self.should_update_render... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(self) -> Optional[np.ndarray]:\n if self.render_mode is None:\n assert self.spec is not None\n gym.logger.warn(\n \"You are calling render method without specifying any render mode. \"\n \"You can specify the render_mode at initialization, \"\n ... | [
"0.7304193",
"0.7073188",
"0.69786763",
"0.6757472",
"0.66534996",
"0.65286",
"0.6504135",
"0.62273604",
"0.617706",
"0.6072075",
"0.60463256",
"0.5997811",
"0.59711",
"0.59711",
"0.5969911",
"0.596902",
"0.5954911",
"0.5952626",
"0.5898475",
"0.5885439",
"0.58700675",
"0.5... | 0.7445947 | 0 |
Return a simplified copy of the environment where distant spacecrafts have been removed from the space. This is meant to lower the policy computational load while preserving the optimal actions set. | def simplify(self):
state_copy = copy.deepcopy(self)
state_copy.space.spacecrafts = [state_copy.spacecraft] + state_copy.space.close_spacecrafts_to(
state_copy.spacecraft, self.PERCEPTION_DISTANCE)
return state_copy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simplify(self) -> 'AbstractEnv':\n state_copy = copy.deepcopy(self)\n state_copy.road.vehicles = [state_copy.vehicle] + state_copy.road.close_vehicles_to(\n state_copy.vehicle, self.PERCEPTION_DISTANCE)\n\n return state_copy",
"def without(self, to_unset):\n modified = ... | [
"0.5691152",
"0.54813194",
"0.5258752",
"0.5244194",
"0.52369404",
"0.52155966",
"0.5172308",
"0.5151422",
"0.5110349",
"0.50940883",
"0.508118",
"0.50775474",
"0.5073993",
"0.50731057",
"0.50580597",
"0.5023523",
"0.5012307",
"0.49986777",
"0.49946648",
"0.49837384",
"0.4963... | 0.6686988 | 0 |
Build an object detection model from ResNet50 architecture pretrained on COCO | def build_detection_model(checkpoint_path='models/research/object_detection/test_data/checkpoint/ckpt-0',
pipeline_config='models/research/object_detection/configs/tf2/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.config',
freeze_batchnorm=True,
n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model():\n \n # load a model pre-trained pre-trained on COCO\n model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained = True)\n \n # replace the classifier with a new one, that has num_classes which is user-defined\n num_classes = 2 # 1 class (person) + background\n \... | [
"0.690004",
"0.66588193",
"0.6648487",
"0.6648473",
"0.66194236",
"0.6607208",
"0.6582919",
"0.6557827",
"0.6557827",
"0.6557827",
"0.6557827",
"0.6549903",
"0.65468943",
"0.6501333",
"0.64943516",
"0.6476868",
"0.6446595",
"0.6439272",
"0.6412864",
"0.63972425",
"0.6386676",... | 0.6721325 | 1 |
Assert a file contains the given text. | def assert_text(self, path, contents):
assert isinstance(contents, text_type)
data = self.fs.gettext(path)
self.assertEqual(data, contents)
self.assertIsInstance(data, text_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_in_file(file_path, text):\n with open(file_path, 'r') as f:\n content = f.read()\n return text in content",
"def assertFile(self, root_path, path, expected_content):\n full_path = os.path.join(root_path, path)\n self.assertFilePresent(root_path, path)\n with open(full_pat... | [
"0.7260009",
"0.6971656",
"0.68093544",
"0.67896724",
"0.66795635",
"0.6662553",
"0.65673757",
"0.64777285",
"0.6463219",
"0.6451605",
"0.6445072",
"0.63984907",
"0.63611096",
"0.6255968",
"0.6254223",
"0.62036115",
"0.62024397",
"0.61698884",
"0.61658216",
"0.61540717",
"0.6... | 0.7273277 | 0 |
Check an unknown purpose raises a NoURL error. | def test_geturl_purpose(self):
self.fs.create('foo')
with self.assertRaises(errors.NoURL):
self.fs.geturl('foo', '__nosuchpurpose__') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_is_good(url):\n return website_re.match(url)\n # possible validation of reachability of website\n # http_response = requests.get(url)\n # return http_response < 400:",
"def check_url(url: str) -> bool:\n try:\n potential_error = driver.find_element_by_xpath(\"/html/body/div[5]/div/d... | [
"0.65323013",
"0.64228904",
"0.6372937",
"0.63698536",
"0.63243103",
"0.6290938",
"0.628491",
"0.6269983",
"0.62446475",
"0.62388295",
"0.6238438",
"0.6221981",
"0.62093294",
"0.618238",
"0.61809975",
"0.6106003",
"0.60834146",
"0.60717535",
"0.6054798",
"0.6054236",
"0.60482... | 0.6870858 | 0 |
Make sure the version in the TOML file and in the __init__.py file are the same. | def test_version():
with open("pyproject.toml") as f:
tomllines = f.read().splitlines()
tomlversion = set([l for l in tomllines if "version =" in l])
initversion = set([f'version = "{mei2volpiano.__version__}"'])
# set is there to catch any duplicate/additional entries
assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_version(self) -> None:\n with open(\"pyproject.toml\") as f:\n for line in f:\n if \"version\" in line:\n version = line.split()[-1].replace('\"', \"\")\n break\n self.assertEqual(__version__, version)",
"def test_version():\n... | [
"0.63930917",
"0.62459564",
"0.5921642",
"0.587334",
"0.58482426",
"0.5747833",
"0.5688836",
"0.5572761",
"0.55282295",
"0.5525575",
"0.5509409",
"0.54920894",
"0.54500955",
"0.54486805",
"0.54486805",
"0.54486805",
"0.54453105",
"0.54453105",
"0.5420287",
"0.5393781",
"0.535... | 0.67833966 | 0 |
Find distances from start vertex to all vertices | def distances_bfs(self, start):
from queue import deque
assert start in self.graph
distance = {vertex: None for vertex in self.vertices()}
distance[start] = 0
queue = deque()
queue.append(start)
while queue:
current_vertex = queue.pop()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distances(self):",
"def one_to_all_bfs(start, num_vertexes, edges, INF=9223372036854775807):\n distances = [INF] * num_vertexes\n distances[start] = 0\n to_visit = [start]\n while to_visit:\n next_visit = []\n for frm in to_visit:\n for to in edges[frm]:\n ... | [
"0.67085356",
"0.6332678",
"0.6297563",
"0.62604505",
"0.62509423",
"0.6222758",
"0.61351496",
"0.61228406",
"0.60961115",
"0.60891247",
"0.6052529",
"0.60063326",
"0.5931734",
"0.5913894",
"0.59011626",
"0.58787453",
"0.5878429",
"0.58402365",
"0.58323824",
"0.58128625",
"0.... | 0.66886586 | 1 |
Return list of new mails | def get_new_mails(self):
if cint(self.settings.use_imap):
self.imap.select("Inbox")
if self.settings.no_remaining == '0' and self.settings.uidnext:
if self.settings.uidnext == self.settings.newuidnext:
return False
else:
#request all messages between last uidnext and new
return True
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_create_mail_messages(self):\n self.check_recipients()\n self.check_message()\n messages = self.env['mail.message']\n for recipient in self.recipient_ids:\n messages |= recipient._create_mail_message()\n return messages",
"def fetchmail(self):\n mail... | [
"0.67494476",
"0.6615385",
"0.649707",
"0.63677174",
"0.6357396",
"0.62726194",
"0.62524587",
"0.62359744",
"0.62353027",
"0.6214297",
"0.62103856",
"0.6176566",
"0.6172016",
"0.617097",
"0.6118627",
"0.60628283",
"0.60455704",
"0.60106045",
"0.60102516",
"0.6009126",
"0.6005... | 0.772635 | 0 |
Walk and process multipart email. | def parse(self):
for part in self.mail.walk():
self.process_part(part) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def payload_parse(self, mail):\n\t\tif mail.is_multipart():\n\t\t\tfor payload in mail.get_payload():\n\t\t\t\tif payload.get_content_maintype() == \"multipart\":\n\t\t\t\t\tself.payload_parse(payload)\n\t\t\t\telse:\n\t\t\t\t\tself.payload_handle(payload, mail)\n\t\t\t# Post deletion of payloads:\n\t\t\tself.payl... | [
"0.67589504",
"0.66122556",
"0.6362437",
"0.6281379",
"0.6234594",
"0.6232879",
"0.6215236",
"0.5973215",
"0.5962559",
"0.5891035",
"0.5818458",
"0.5751515",
"0.57384187",
"0.57365113",
"0.56827193",
"0.5681532",
"0.5662649",
"0.5645171",
"0.5585304",
"0.5525507",
"0.5516139"... | 0.7683323 | 0 |
Parse email `part` and set it to `text_content`, `html_content` or `attachments`. | def process_part(self, part):
content_type = part.get_content_type()
filename = part.get_filename()
if content_type == 'text/plain' and not filename:
self.text_content += self.get_payload(part)
elif content_type == 'text/html':
self.html_content += self.get_payload(part)
elif content_type == 'message/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_attachment(message_part):\n content_disposition = message_part.get(\"Content-Disposition\", None)\n if content_disposition:\n dispositions = content_disposition.strip().split(\";\")\n if bool(content_disposition and\n dispositions[0].lower() == \"attachment\"):\n\n ... | [
"0.65008265",
"0.62675315",
"0.61053777",
"0.6043412",
"0.59855354",
"0.5756961",
"0.5730942",
"0.56908387",
"0.55686265",
"0.5391659",
"0.53889847",
"0.53342295",
"0.5289718",
"0.5285181",
"0.52509284",
"0.5240541",
"0.5207104",
"0.51973563",
"0.519061",
"0.51662457",
"0.509... | 0.7365437 | 0 |
Save email attachments in given document. | def save_attachments_in_doc(self, doc):
saved_attachments = []
for attachment in self.attachments:
try:
file_data = save_file(attachment['fname'], attachment['fcontent'],
doc.doctype, doc.name, is_private=1)
saved_attachments.append(file_data)
if attachment['fname'] in self.cid_map:
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, *args, **kwargs):\n attachments_to_save = []\n for attachment_attr in self.attachment_list:\n attachments_to_save.append(self.validated_data.pop(attachment_attr))\n response = super().save(*args, **kwargs)\n for attachment in attachments_to_save:\n i... | [
"0.62436914",
"0.59777683",
"0.59250724",
"0.57655126",
"0.5627985",
"0.5609621",
"0.5494929",
"0.54716134",
"0.54674774",
"0.53962153",
"0.53697306",
"0.5364998",
"0.53576803",
"0.531556",
"0.52292156",
"0.5151667",
"0.5141445",
"0.51180977",
"0.5107516",
"0.50661355",
"0.50... | 0.73739046 | 0 |
Extract thread ID from `[]` | def get_thread_id(self):
l = re.findall('(?<=\[)[\w/-]+', self.subject)
return l and l[0] or None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_thread_id() -> str:\n with open('post_id.txt', 'r') as files:\n thread_id = files.read()\n\n return thread_id",
"def thread_id(self):\n return self._thread_id",
"def get_id(self):\n for id, thread in threading._active.items(): \n if thread is self: \n ... | [
"0.6504339",
"0.63808286",
"0.6294525",
"0.6185133",
"0.6185133",
"0.6119811",
"0.59977484",
"0.5948242",
"0.59146464",
"0.5836307",
"0.57658243",
"0.5746452",
"0.5704008",
"0.56813455",
"0.5670495",
"0.56559366",
"0.56556565",
"0.56350636",
"0.5596078",
"0.5571945",
"0.55274... | 0.7584884 | 0 |
Fetches all expenses for the house | def expenses(self):
return Expenses.objects.filter(
house=self.house,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_expenses(self, parameter=None):\n resp = zoho_http_client.get(base_url, self.details, self.headers, parameter)\n return parser.get_list(resp)",
"def get_all(self):\n total_expense_reports = []\n get_count = {\n 'query': {\n 'object': 'EEXPENSES',\n ... | [
"0.75546044",
"0.70506036",
"0.6988394",
"0.6264646",
"0.61877763",
"0.6160968",
"0.6022803",
"0.5791499",
"0.5791499",
"0.5714145",
"0.5632406",
"0.55389637",
"0.5473047",
"0.5467186",
"0.54195464",
"0.5417473",
"0.540191",
"0.53685397",
"0.5358989",
"0.5358788",
"0.5358726"... | 0.7608281 | 0 |
Fetches all approved jobs for the house | def approved_jobs(self):
return Job.objects.filter(
house=self.house,
approved=True,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_jobs(self, bill_id: int = 0, limit: int = 0) -> List[Job]:\n pass",
"async def get_jobs(): \n return mngr.getAllJobs()",
"def get(self):\n # TODO: auth\n return list(self.app.db.jobs.find())",
"def get_jobs_list(self, response):\n pass",
"def get_queryset(self):... | [
"0.64975166",
"0.64335525",
"0.6395426",
"0.6390087",
"0.6355305",
"0.6228912",
"0.61817175",
"0.6170959",
"0.61449194",
"0.6067417",
"0.60418403",
"0.6040219",
"0.6010533",
"0.6010371",
"0.6001975",
"0.5995996",
"0.5973105",
"0.59290487",
"0.5902574",
"0.5896722",
"0.5885378... | 0.79753345 | 0 |
Checks if the house has any active jobs. | def has_active_jobs(self, **kwargs):
if Job.objects.add_balance().filter(house=self.house, balance1__gt=0, approved=True, **kwargs).exists():
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isEmpty(self):\n return len(self.jobs) == 0",
"def check_jobs(self):\n # New/aborted jobs\n try:\n jobs = self.sm.get_job('%', phase = 'QUEUED')\n for job in jobs:\n self._launch_job(Job(job['job']))\n res = self.sm.get_aborted_jobs()\n aborts = [x['identifier'] for x ... | [
"0.7014045",
"0.66785365",
"0.657027",
"0.65535456",
"0.6546421",
"0.6463334",
"0.6436376",
"0.64134765",
"0.6412882",
"0.6411166",
"0.63975406",
"0.6359158",
"0.63180745",
"0.63032097",
"0.6299841",
"0.6295104",
"0.62680423",
"0.62680423",
"0.6257935",
"0.62511295",
"0.62323... | 0.7794764 | 0 |
Checks if the house has any rejected jobs. | def has_rejected_jobs(self, **kwargs):
if Job.objects.filter(house=self.house, rejected=True, **kwargs).exists():
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_job_completeness(self, jobs):\n for job in concurrent.futures.as_completed(jobs):\n if job.exception():\n raise (job.exception())",
"def check_jobs(self):\n # New/aborted jobs\n try:\n jobs = self.sm.get_job('%', phase = 'QUEUED')\n for job in jobs:\n ... | [
"0.66733396",
"0.63713294",
"0.62130815",
"0.61487967",
"0.6122383",
"0.60535616",
"0.59987134",
"0.5935412",
"0.591256",
"0.5887511",
"0.5864966",
"0.5847546",
"0.58341813",
"0.58134335",
"0.5810112",
"0.5805247",
"0.58052236",
"0.5803409",
"0.58024246",
"0.57649076",
"0.574... | 0.80535066 | 0 |
Calculates the budget for the house based on three variables | def budget(self):
budget = (_House.closing_cost*self.vars['after_repair_value']) - self.vars['purchase_price'] - self.vars['profit'] - _House.broker_fee
return float(round(budget, 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateCosts(self):\n self.costs = 0\n for house in self.houses:\n if not house.distance == 1000:\n self.costs += house.distance * 9\n for battery in self.batteries:\n self.costs += battery.costs\n return self.costs",
"def budget_problem3(bal... | [
"0.61505514",
"0.6089759",
"0.6038353",
"0.6015872",
"0.594914",
"0.5947916",
"0.59439886",
"0.59188956",
"0.5887294",
"0.5822022",
"0.5820701",
"0.5790669",
"0.5781134",
"0.57606393",
"0.5755206",
"0.5702439",
"0.5691797",
"0.5668918",
"0.5665423",
"0.56606954",
"0.5652122",... | 0.67384696 | 0 |
Calculates the total amount spent for the house by adding all expenses and completed jobs. | def total_spent(self):
approved_jobs = self.approved_jobs()
expenses = self.expenses()
total = 0
for job in approved_jobs:
total += job.total_paid
for expense in expenses:
total += expense.amount
return float(round(total, 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_total_paid(self):\n total = 0.0\n for line in self.loan_ids:\n if line.pay:\n total += line.amount\n self.total_paid = total",
"def cash_sum(self, room):\n self.cash = room.price\n return self.cash",
"def calculateCosts(self):\n se... | [
"0.61278397",
"0.60141414",
"0.5883509",
"0.58684665",
"0.58504134",
"0.5818961",
"0.5803535",
"0.57970977",
"0.57137537",
"0.57137537",
"0.5711607",
"0.5659715",
"0.56533766",
"0.5646067",
"0.5616503",
"0.56072485",
"0.5606351",
"0.55777013",
"0.556878",
"0.5558684",
"0.5552... | 0.7208334 | 0 |
Calculates the balance budget and balance budget degree by taking the budget amount and subtracting the total spent amount. | def budget_balance(self):
budget_balance = round(self.budget() - self.total_spent(), 2)
budget_balance_degree = round( (9000 * self.total_spent()) / (self.budget()), 4) #convert to degrees and round to four decimal places
return (budget_balance, budget_balance_degree) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deposit(self, amount, budget):\r\n if budget != \"Total Balance\":\r\n assert budget in self.budgets, \"Specified budget doesn't exist\"\r\n self.budgets[budget] += float(amount)\r\n self.balance += float(amount)",
"def withdraw(self, amount, budget):\r\n if budget ... | [
"0.71001554",
"0.7028642",
"0.65880764",
"0.64517754",
"0.63420874",
"0.6261126",
"0.6258373",
"0.624599",
"0.62441903",
"0.6243866",
"0.6233808",
"0.61923677",
"0.6177002",
"0.61561537",
"0.61382204",
"0.61116695",
"0.6110295",
"0.60939896",
"0.60505503",
"0.60471076",
"0.60... | 0.79801476 | 0 |
Calculates how much of the budget has been used as a percentage. | def budget_used(self):
return int(self.total_spent() / self.budget() * 100.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percent_usage(value, total):\n if total:\n return float(value) * 100.0 / (float(total) + float(value))\n else:\n return 100.0",
"def pct(self):\n\t\treturn self.bottle.pct()",
"def percentage_used(self):\n return self.volume_used/self.total_volume * 100.0",
"def percentage(coun... | [
"0.7384314",
"0.7322966",
"0.7174507",
"0.7170255",
"0.7124505",
"0.7116485",
"0.6982112",
"0.6959819",
"0.6915842",
"0.68807685",
"0.68467945",
"0.68159556",
"0.6778811",
"0.67623633",
"0.6761943",
"0.67319983",
"0.672578",
"0.66812664",
"0.66812664",
"0.66636133",
"0.666242... | 0.7920088 | 0 |
Internal function to check pivot conditions and return an intersection of pivot on the signals | def _get_signal_pivots(self):
sig_a_info = self._parser.inspect(self._a)
sig_b_info = self._parser.inspect(self._b)
if sig_a_info["pivot"] != sig_b_info["pivot"]:
raise RuntimeError("The pivot column for both signals" +
"should be same (%s,%s)"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkintersection(p1,p2,p3,p4):\n def isonsegment(i,j,k):\n return ((i.x <= k.x or j.x <= k.x) and (k.x <= i.x or k.x <= j.x) and\n (i.y <= k.y or j.y <= k.y) and (k.y <= i.y or k.x <= j.y))\n\n def computedirection(i,j,k):\n a = (k.x - i.x) * (j.y - i.y);\n b = (j.x - i.x) * (k.y - i.y);\... | [
"0.5798268",
"0.57260567",
"0.5718751",
"0.5637867",
"0.548589",
"0.5389251",
"0.5360851",
"0.53357774",
"0.52946544",
"0.5293057",
"0.52463186",
"0.523002",
"0.51608384",
"0.5152872",
"0.51508623",
"0.5137729",
"0.51251626",
"0.5122858",
"0.50904095",
"0.5083667",
"0.5052751... | 0.71306324 | 0 |
Interpolate to xout xout must be a float or a ndarray of floats if xout.size > serial_cutoff, use parallel version | def __call__(self, xout, fout=None):
if isinstance(xout, np.ndarray):
if xout.size > serial_cutoffs[1]:
func = PAR_INTERP_1D[self.k]
else:
func = SER_INTERP_1D[self.k]
m = int(np.prod(xout.shape))
copy_made = False
if fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, xout, yout, fout=None):\n if isinstance(xout, np.ndarray):\n if xout.size > serial_cutoffs[2]:\n func = PAR_INTERP_2D[self.k]\n else:\n func = SER_INTERP_2D[self.k]\n m = int(np.prod(xout.shape))\n copy_made = False... | [
"0.55407476",
"0.55230695",
"0.5466127",
"0.5298338",
"0.5192844",
"0.5180324",
"0.51104575",
"0.5090676",
"0.50120974",
"0.49926928",
"0.4980818",
"0.49528757",
"0.49429956",
"0.49377602",
"0.49207413",
"0.4907824",
"0.490474",
"0.49029276",
"0.49015373",
"0.48381254",
"0.48... | 0.5808691 | 0 |
Test navigates through the 'Documentation' tabs and verifies the links to tabs by asserting expected titles against given ones. | def test_documentation_path_links(self):
main_page = DogMainPage(self.driver)
dog_page = main_page.navigate_documentation()
# Switch to 'List all breeds' tab
all_breeds_page = dog_page.switch_tab(dog_page.ALL_BREEDS)
all_breeds_expected = all_breeds_page.get_expected_header(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_menu_path_links(self):\r\n main_page = DogMainPage(self.driver)\r\n # Navigate to Title (main) page\r\n title_page = main_page.navigate_main()\r\n title_expected_header = title_page.get_expected_header()\r\n title_header = title_page.get_header()\r\n # Assert the ... | [
"0.68019795",
"0.67768544",
"0.6687646",
"0.6620972",
"0.64275634",
"0.63891387",
"0.63046104",
"0.62972707",
"0.6277566",
"0.62297547",
"0.621474",
"0.6169982",
"0.6162793",
"0.6142867",
"0.61180085",
"0.61172885",
"0.6100911",
"0.60956544",
"0.6092831",
"0.6066643",
"0.6065... | 0.79340965 | 0 |
Test navigates through the menu options and verifies the page links by asserting expected titles against given ones. | def test_menu_path_links(self):
main_page = DogMainPage(self.driver)
# Navigate to Title (main) page
title_page = main_page.navigate_main()
title_expected_header = title_page.get_expected_header()
title_header = title_page.get_header()
# Assert the title by sub-stri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_navigates_to_about_page_then_index_page_then_about_page_success(w_driver):\n #1.) Navigate to about page, click link for index page\n w_driver.get('localhost:8000/about')\n\n element=w_driver.find_element_by_link_text('back to Kasner').click()\n #find index page info\n results=w_driver.page... | [
"0.6868659",
"0.6848145",
"0.6782984",
"0.67550534",
"0.6732094",
"0.65861976",
"0.6546698",
"0.6540386",
"0.6496603",
"0.64781463",
"0.64476573",
"0.64316386",
"0.6419403",
"0.6395801",
"0.6340467",
"0.63370305",
"0.6316351",
"0.6306604",
"0.6289248",
"0.62697625",
"0.625604... | 0.79684585 | 0 |
For testing email text field | def test_email_form(self):
dummy_email = 'dummy@d.c'
main_page = DogMainPage(self.driver)
main_page.populate_email(dummy_email)
self.assertEqual(dummy_email, main_page.get_value_email(), 'Expected conditions failed.') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_email(self):\r\n \r\n self.assertEqual('maryc123@yahoo.com', self.user.email)",
"def test_text_field():",
"def test_compose_email_good(self): \n pass",
"def get_email(self,text):\r\n return self.driver.find_element(*SinginPage.email).send_keys(text)",
"def test_compose_... | [
"0.7379854",
"0.73666507",
"0.7336404",
"0.71672654",
"0.71310836",
"0.71121943",
"0.70770097",
"0.7010115",
"0.6885396",
"0.6848203",
"0.68398523",
"0.68151253",
"0.68076175",
"0.67020476",
"0.6701801",
"0.666361",
"0.66532904",
"0.66501975",
"0.6637231",
"0.66144276",
"0.65... | 0.771166 | 0 |
Run the simulation and write resutls in report_file_name. This function runs the actual simulation by running a turn by turn simulation and writes the result in report_file_name. | def simulate(self, report_file_name):
current_turn = 1
last_turn = 0
# Process all customers entry
for next_customer in self._scenario:
# While we did not reach the turn that this customer enters the
# restaurant, process turns one by one
while curre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(sim_attr_generator):\n#TODO: clean\n#TODO: integrate analyses\n def analyze_and_save(simulation,simulation_attributes):\n#? Ugly conf file analyses integration.\n if simulation_attributes.analyses and Args.output_file != None:\n verbose_print(\"Saving analyses for {0}.\".format(simulat... | [
"0.6596672",
"0.6571582",
"0.64502853",
"0.6428246",
"0.64214563",
"0.63550687",
"0.630784",
"0.6306099",
"0.6249517",
"0.62216187",
"0.6202602",
"0.6120247",
"0.6079604",
"0.5939629",
"0.5922156",
"0.5920404",
"0.58797896",
"0.5826667",
"0.58249176",
"0.581223",
"0.5811084",... | 0.66220045 | 0 |
Wrapper for single or multigene figures. If multiple genes are provided, each will be rendered as its own axis in a vertical stack and each will be labeled with a single uppercase letter, as would be suitable for a multipanel figure in a manuscript. | def plot_figure(
df: pd.DataFrame, genes: Union[Mapping, Sequence[Mapping]]
) -> matplotlib.figure.Figure:
if isinstance(genes, Mapping): # convert single genes into a list of length 1
genes = [genes]
fig = plt.figure(figsize=(10, 2 * len(genes)), tight_layout="true")
spec = gridspec.GridSpec(n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Figure4Main(self, supplemental1=False):\n if not supplemental1:\n example_cells = [5, 9, 17, 30]\n else:\n example_cells = [2, 6, 10, 11, 13, 18]\n\n start_letter = \"A\"\n parent_figure = None\n\n if not supplemental1:\n sizer = {\n ... | [
"0.62391675",
"0.5573007",
"0.55273825",
"0.5471501",
"0.5401241",
"0.5400579",
"0.53350043",
"0.5321127",
"0.52325386",
"0.5185536",
"0.51851785",
"0.5162964",
"0.5139158",
"0.5105493",
"0.50971764",
"0.5093184",
"0.5092872",
"0.5075228",
"0.5068497",
"0.5068263",
"0.5064392... | 0.6132679 | 1 |
purge cache of a host | def purge(hostname):
config.purge(hostname)
log.info('OK') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _purge():\r\n _cache.clear()",
"def clear_cache():\n sudo('service varnish restart')",
"def purge_cache(self):\n\n self.local_store.purge_cache()",
"def destroy_cache():\n # TODO\n pass",
"def decache(self):",
"def purgeAndDeleteCache(webhook_cache, url):\n \n totalRe... | [
"0.7727345",
"0.73509437",
"0.7080226",
"0.7028563",
"0.69827265",
"0.6830749",
"0.68005484",
"0.6735831",
"0.67053866",
"0.66968954",
"0.66672283",
"0.6632626",
"0.66293",
"0.6593723",
"0.65836966",
"0.65826976",
"0.6574661",
"0.65719706",
"0.65687996",
"0.6507312",
"0.64658... | 0.7531293 | 1 |
install ca to system's certificate chain | def install_ca():
require_root()
config.proxy.install_ca_cert()
log.info('OK') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_ca():\n require_root()\n\n config.proxy.gen_ca_certs()\n log.info('OK')",
"def ca():\n return trustme.CA()",
"def initial_setup():\n\n if os.path.exists(cfg.ca_private_key_path()):\n pkey = _try_load_ca_private_key(cfg.ca_private_key_path())\n else:\n pkey = _generate_ca... | [
"0.7331956",
"0.6866141",
"0.6793719",
"0.6792014",
"0.6662008",
"0.6598612",
"0.64483553",
"0.63963974",
"0.6261553",
"0.6227196",
"0.6218202",
"0.61274976",
"0.61183465",
"0.6107496",
"0.6034503",
"0.6000411",
"0.5953046",
"0.59481186",
"0.59253514",
"0.58889574",
"0.588639... | 0.85667384 | 0 |
Populate relevant tables with formatted data stored in dictionary structures. The data will already be properly formatted in dictionary form (retrieved from a .csv file), so this function takes the preformatted data and stores it in Book and Author tables, since those should be populated upon initialization. | def populate_tables(self, data_book, data_author, datafile_name, initial_stock=20):
print("\nPopulating book table with input data from", datafile_name, "...", end='')
count = 0
failed_books = []
for book in data_book:
try:
date = datetime.datetime.strptime(b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _populate(self):\n\n # Assume the first word is what we want, and we can find well formed years\n # This sucks, but will work for these ones.\n # Roll on bibtex for citations in the CIM.\n\n citation_detail = self.doc.citation_detail\n author = citation_detail.split(',')[0]\n... | [
"0.67089665",
"0.6166051",
"0.61170274",
"0.6050481",
"0.5880672",
"0.5851863",
"0.5669068",
"0.5660942",
"0.5614498",
"0.5612204",
"0.5433636",
"0.5422656",
"0.54159504",
"0.5413617",
"0.5391802",
"0.53912425",
"0.53677887",
"0.5349724",
"0.5343896",
"0.5338233",
"0.5330698"... | 0.703236 | 0 |
Take in a (valid) set of user information and create a new manager. Also need to check if the user is currently a customer, and remove the user if so. | def add_manager(self, info):
self.cursor.execute("""SELECT COUNT(*) FROM managerpersonal WHERE phone=%s""", (int(info['phone']),))
if not self.cursor.fetchone()[0]:
self.cursor.execute("""INSERT INTO managerpersonal VALUES (%s,%s)""", (int(info['phone']), info['address']))
self.curso... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, new_user):\n new_user = User(user_name=new_user['user_name'], pin=new_user['pin'], user_type='customer')\n self.session.output(new_user.get_user_info(), '\\n[ New user created ]')",
"def test_with_manager_not_in_state(self):\n user_key = Key()\n user_id = user_k... | [
"0.65041286",
"0.64282334",
"0.6421729",
"0.6411341",
"0.6370367",
"0.6361717",
"0.6351803",
"0.628153",
"0.62290317",
"0.6224785",
"0.62097484",
"0.6164947",
"0.60557103",
"0.6002894",
"0.59604114",
"0.5946951",
"0.5930125",
"0.5885216",
"0.58720917",
"0.58694744",
"0.586690... | 0.6900736 | 0 |
Given a valid login ID, promote the user to a manager by removing their credentials from the customer tables and adding it to the manager tables. | def promote_to_manager(self, loginID):
self.cursor.execute("""SELECT * FROM customercredentials WHERE loginID=%s""", (loginID,))
creds = self.cursor.fetchone()
self.cursor.execute("""SELECT * FROM customerpersonal WHERE phone=%s""", (int(creds[5]),))
personal = self.cursor.fetchone()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_manager(self, loginID):\n try:\n self.cursor.execute(\"\"\"SELECT COUNT(*) FROM managercredentials WHERE loginID=%s\"\"\", (loginID,))\n if not self.cursor.fetchone()[0]:\n return False\n self.cursor.execute(\"\"\"DELETE FROM managercredentials WHER... | [
"0.59607804",
"0.5587557",
"0.5577293",
"0.5532288",
"0.54025316",
"0.5340027",
"0.5235987",
"0.52357197",
"0.5205971",
"0.5111072",
"0.5108285",
"0.50876516",
"0.5061663",
"0.5035165",
"0.5018789",
"0.4973354",
"0.4956313",
"0.49558786",
"0.4954053",
"0.49522933",
"0.4943693... | 0.7494607 | 0 |
Utility function to return a boolean value whether or not the login ID entered is the ID of the system super manager. | def is_super_manager(self, loginID):
self.cursor.execute("""SELECT managerID FROM managercredentials WHERE loginID=%s""", (loginID,))
user_key = self.cursor.fetchone()[0]
self.cursor.execute("""SELECT MIN(managerID) FROM managercredentials""")
if user_key == self.cursor.fetchone()[0]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_superuser():\n if sys.version > \"2.7\":\n for uid in os.getresuid():\n if uid == 0:\n return True\n else:\n if os.getuid() == 0 or os.getegid() == 0:\n return True\n return False",
"def is_superuser(self):\n sesh = self.get_session()\n ... | [
"0.6768197",
"0.65031356",
"0.64134824",
"0.6318678",
"0.6299954",
"0.62984467",
"0.62790716",
"0.6232972",
"0.615097",
"0.61283505",
"0.61260724",
"0.61119485",
"0.61034226",
"0.60718",
"0.60710406",
"0.6051024",
"0.60492224",
"0.60438657",
"0.6037717",
"0.6006233",
"0.59719... | 0.811737 | 0 |
Given an ISBN, find the book in the database and return the price, a boolean indicating whether or not | def valid_book(self, info):
self.cursor.execute("SELECT ISBN, title, price, stock FROM book WHERE ISBN=%s", (info['ISBN'],))
for book in self.cursor.fetchall():
return True, float(book[2]), book[1], book[3]
return False, 0, 0, 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_book_by_isbn(isbn):\n return Book.get_book(isbn)",
"def isbn_lookup(isbn):\n base = \"https://www.googleapis.com/books/v1/volumes?q=isbn=\"\n# Unfortunately we can't use the superior \"with spam as eggs\" syntax here...\n search = urlopen(base + isbn + \"&prettyprint=false\")\n lines = search... | [
"0.71685046",
"0.7099933",
"0.70221645",
"0.68731934",
"0.6789182",
"0.6749278",
"0.6529551",
"0.65249896",
"0.6510712",
"0.6385392",
"0.63603634",
"0.6330002",
"0.6277765",
"0.6264197",
"0.6224342",
"0.62236404",
"0.6164584",
"0.6158051",
"0.612079",
"0.60699725",
"0.6049452... | 0.72273356 | 0 |
Given a query entered by the user, return all books that match the search. Results must satisfy the provided filters. I will be making the result a dict so that duplicates are avoided. Also, because I may need to sort all of the books by a certain value, each filter check will add a subsection of the query and only one... | def find_books(self, query, filters, dates, order, descending, semantics, loginID):
if int(semantics):
# OR semantics
conjunction = ' UNION '
else:
# AND semantics
conjunction = ' INTERSECT '
results = {}
query_sections = ''
args = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_for_books(words, filters):\n db = get_db()\n books = {}\n\n if not filters:\n filters.append('title')\n\n for filter in filters:\n if filter == 'title':\n temp = Book(db).search(create_search_query(words))\n for book in temp:\n books[book['id']] = book\n elif filter == 'aut... | [
"0.7645307",
"0.6790778",
"0.6598476",
"0.641544",
"0.6351727",
"0.63514113",
"0.6336503",
"0.6308661",
"0.62955046",
"0.62509865",
"0.6181599",
"0.61077005",
"0.6104971",
"0.6099935",
"0.6044743",
"0.6006426",
"0.5989734",
"0.597283",
"0.58954346",
"0.5888524",
"0.58327734",... | 0.8094429 | 0 |
Given an author name and a degree of separation, return a list of books that are written by authors who share that degree separated from the specified author. | def find_books_by_author_separation(self, name, degree):
self.cursor.execute("""SELECT ID FROM author WHERE name=%s""", (name,))
original_author_id = int(self.cursor.fetchone()[0])
self.cursor.execute("""SELECT ISBN FROM wrote WHERE authorID=%s""", (original_author_id,))
first_degree_aut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_relations_among_authors():\n for book in books:\n if len(books[book]) > 1:\n for i in range(len(books[book])):\n known_relations[books[book][i]] = books[book][:i] + books[book][i+1:]",
"def books_by_author(self, author):\n request_url = \"%s?author=%s\" % (self... | [
"0.63213474",
"0.583642",
"0.576012",
"0.55486053",
"0.5524639",
"0.5456475",
"0.54263955",
"0.54165334",
"0.54048514",
"0.54046386",
"0.53530794",
"0.5344667",
"0.53124434",
"0.5257112",
"0.52389055",
"0.5231252",
"0.5223985",
"0.5173741",
"0.51708895",
"0.5150454",
"0.51119... | 0.796402 | 0 |
Utility function that determines if two authors are 1degree separated. | def is_one_degree_separated(self,author1, author2):
self.cursor.execute("""SELECT COUNT(*) FROM wrote W WHERE W.authorID = %s AND EXISTS
(SELECT * FROM wrote W2 WHERE W2.authorID = %s AND W.ISBN = W2.ISBN)""", (author1, author2))
if int(self.cursor.fetchone()[0]):
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_check(context, authors, poscom):\n displaynames = [x['author']['displayname'] for x in poscom]\n\n for author in authors:\n if author.user.username not in displaynames:\n context.assertFalse(True, \"%s not in list\" %author.user.username)",
"def isComrade(self, other): # are the... | [
"0.60600275",
"0.6000368",
"0.5961616",
"0.5815673",
"0.57547796",
"0.5678407",
"0.5665919",
"0.5462363",
"0.5437373",
"0.54316366",
"0.5408115",
"0.54073846",
"0.53969944",
"0.53969944",
"0.53861034",
"0.5378126",
"0.537463",
"0.5349241",
"0.53332996",
"0.5314922",
"0.529007... | 0.7722055 | 0 |
Given an ISBN number of a book, retrieve the entire tuple of that book as well as the authors. | def get_single_book_info(self, isbn):
self.cursor.execute("SELECT * FROM book WHERE ISBN=%s", (isbn,))
books = self.cursor.fetchall()
for book in books:
authors = []
self.cursor.execute("""SELECT name FROM Author A, Wrote W, Book B WHERE A.ID = W.authorID AND
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book_by_isbn(ISBN):\n data = {}\n for book in root.findall('Book'):\n for elem in book:\n isbn = book.find('ISBN').text\n if isbn == ISBN:\n data['id'] = book.attrib['id']\n data[elem.tag] = elem.text\n return data",
"def isbn_lookup(isbn):\... | [
"0.683065",
"0.6526513",
"0.6487258",
"0.625673",
"0.6255212",
"0.6182602",
"0.61770684",
"0.60605705",
"0.6013382",
"0.6001543",
"0.58569443",
"0.5854576",
"0.58373415",
"0.5809132",
"0.5758391",
"0.56655586",
"0.56175834",
"0.55987334",
"0.5571843",
"0.5569836",
"0.55333585... | 0.7923752 | 0 |
Given an order number, return a list of several (we'll say 10 max) suggestions of books for the user to purchase. Need to get all the books from this order, then search all other orders and recommend books those customers ordered. Also need to find all of the books this user has ordered in the past as well, since we do... | def get_recommended_books(self, orderNumber, loginID):
invalid_isbn_list = []
books_in_order = []
possible_isbn_list = []
self.cursor.execute("""SELECT orderNumber FROM orderlog WHERE loginID=%s""", (loginID,))
for order in self.cursor.fetchall():
self.cursor.execute(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_books_in_order(self, orderNumber):\n self.cursor.execute(\"\"\"SELECT ISBN, quantity FROM orderlog O, productof P WHERE O.orderNumber = P.orderNumber\n AND O.orderNumber=%s\"\"\",(orderNumber,))\n result = []\n for i in self.cursor.fetchall():\n result.append([i[0],i[... | [
"0.66760135",
"0.6438365",
"0.58706945",
"0.5765255",
"0.5621472",
"0.5576812",
"0.55767345",
"0.55294985",
"0.550628",
"0.5500204",
"0.54980177",
"0.54707557",
"0.5468065",
"0.5464387",
"0.5456998",
"0.5440048",
"0.5420678",
"0.5417453",
"0.53468436",
"0.529879",
"0.52903426... | 0.72850907 | 0 |
Given an isbn of a book and a quantity, add that many books to inventory. If successful, return true. Otherwise, return false (this means the user entered an ISBN that is not present in the database) | def restock_book(self, isbn, quantity):
self.cursor.execute("""SELECT COUNT(*) FROM book WHERE ISBN=%s""", (isbn,))
if self.cursor.fetchone()[0]:
self.cursor.execute("""UPDATE book set stock=stock+%s WHERE ISBN=%s""", (quantity, isbn))
self.db.commit()
return True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_book(self, data):\n exists = self.check_if_exists(data['isbn'])\n\n if exists:\n query = f\"\"\"UPDATE {TABLE} SET quantity = quantity + 10 WHERE bookID = '{data[\"isbn\"]}'\"\"\"\n else:\n query = f\"\"\"INSERT INTO {TABLE}(bookID, title, authors, avg_rating, rat... | [
"0.6657328",
"0.6105469",
"0.5910948",
"0.58885527",
"0.58784324",
"0.58568716",
"0.5847984",
"0.58228725",
"0.58056134",
"0.576493",
"0.57219106",
"0.5702976",
"0.56621385",
"0.55984473",
"0.5585517",
"0.55787504",
"0.5577667",
"0.55656403",
"0.5536493",
"0.5530911",
"0.5522... | 0.73372024 | 0 |
Given a unique login ID, find the details about all of the orders associated with that user and return in a | def get_user_orders(self, loginID):
order_details = {}
self.cursor.execute("""SELECT orderNumber, orderDate FROM orderlog WHERE loginID=%s
ORDER BY orderDate DESC, orderNumber DESC""", (loginID,))
for order in self.cursor.fetchall():
order_details[str(order[0])] = {'title': ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_one_user_orders(self,user_id):\n\n sql = \"SELECT * FROM parcel_orders WHERE user_id='{}'\".format(user_id)\n self.db_object.cursor.execute(sql)\n placed_orders = self.db_object.cursor.fetchall()\n return placed_orders",
"def test_get_all_orders_by_user(self):\n # Test ... | [
"0.6686448",
"0.64870703",
"0.6377364",
"0.63203555",
"0.59901",
"0.59260833",
"0.58946323",
"0.58818346",
"0.58209866",
"0.581566",
"0.5790411",
"0.5785189",
"0.57793796",
"0.57544464",
"0.5745315",
"0.5741415",
"0.569958",
"0.56847036",
"0.5682288",
"0.5681163",
"0.5678344"... | 0.75124234 | 0 |
Utility function to send a list of all ISBN's and their quantities in an order given an order number | def get_books_in_order(self, orderNumber):
self.cursor.execute("""SELECT ISBN, quantity FROM orderlog O, productof P WHERE O.orderNumber = P.orderNumber
AND O.orderNumber=%s""",(orderNumber,))
result = []
for i in self.cursor.fetchall():
result.append([i[0],i[1]])
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book(self, irc, msg, args, thing):\n self.db.deleteExpired(self.registryValue('orderExpiry'))\n results = self.db.getCurrencyBook(thing)\n if len(results) == 0:\n irc.error(\"No orders for this currency present in database.\")\n return\n if len(results) > self.... | [
"0.6369327",
"0.5828879",
"0.5790139",
"0.57637495",
"0.5735976",
"0.5667943",
"0.5600581",
"0.55803293",
"0.5573463",
"0.5555479",
"0.5546125",
"0.5471802",
"0.5466978",
"0.54046434",
"0.5401237",
"0.5364825",
"0.5308784",
"0.53080535",
"0.5262634",
"0.5256943",
"0.52493423"... | 0.66823083 | 0 |
Utility function to check if an order specified by orderNumber has no books associated with it. This is only ever called internally, so no need for validity checks. | def is_empty_order(self, orderNumber):
self.cursor.execute("""SELECT COUNT(*) FROM productof WHERE orderNumber=%s""", (orderNumber,))
if self.cursor.fetchone()[0]:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_book(self, book):\n return self.books.filter(lists_books.c.book_id == book.id).count() > 0",
"def is_book_available(self, book):\n request_url = \"%s?q=%s\" % (self.API_URL, book)\n json_data = self.make_request(request_url)\n if json_data and len(json_data['docs']) >= 1:\n ... | [
"0.5795934",
"0.5631788",
"0.5619639",
"0.56194794",
"0.5501485",
"0.5421667",
"0.52619696",
"0.52269924",
"0.5222976",
"0.51843566",
"0.5094807",
"0.5090388",
"0.49968106",
"0.49886924",
"0.49697027",
"0.49391702",
"0.49239758",
"0.49178872",
"0.48695588",
"0.48668623",
"0.4... | 0.68257135 | 0 |
Add a new comment from a particular user to a particular book. Since only one comment per user per book is allowed, this function first checks if this user has already commented on the book. If not, can just add a new comment. Otherwise, update the original comment since users are allowed to update their own comments. | def add_comment(self, comment_info):
self.cursor.execute("""SELECT commentID, score FROM comment WHERE loginID = %s AND ISBN = %s""",
(comment_info['loginID'], comment_info['ISBN']))
result = self.cursor.fetchall()
if result:
# found a comment, need to upd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_review_comment(self, doc, comment):\n if len(doc.reviews) != 0:\n if not self.review_comment_set:\n self.review_comment_set = True\n if validations.validate_review_comment(comment):\n doc.reviews[-1].comment = str_from_text(comment)\n ... | [
"0.625182",
"0.6067011",
"0.6059309",
"0.6050631",
"0.59851485",
"0.5965514",
"0.5910397",
"0.59039426",
"0.58771926",
"0.5862978",
"0.58472365",
"0.58253986",
"0.57115245",
"0.5697091",
"0.5649901",
"0.5633569",
"0.5633569",
"0.55912524",
"0.55813646",
"0.5577598",
"0.554871... | 0.6476383 | 0 |
Maintenance function for updating the average rating of the book with the given ISBN. This should be called any time the number of ratings/the total rating score are updated. | def update_average_book_rating(self, isbn):
self.cursor.execute("""UPDATE book SET avg_rating = total_rating_score / num_ratings WHERE
ISBN=%s""", (isbn,))
self.db.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_book_scores(self):\n self.cursor.execute(\"\"\"UPDATE book SET avg_rating=NULL, total_rating_score=0, num_ratings=0\"\"\")\n self.db.commit()\n self.cursor.execute(\"\"\"SELECT * FROM comment\"\"\")\n for comment in self.cursor.fetchall():\n self.cursor.execute(\"\... | [
"0.75978434",
"0.6865599",
"0.6308009",
"0.62638813",
"0.6142683",
"0.59501565",
"0.5932905",
"0.5863806",
"0.57942003",
"0.5734078",
"0.5721565",
"0.56398964",
"0.56119525",
"0.5606553",
"0.5602719",
"0.55716145",
"0.54950917",
"0.5487591",
"0.54631513",
"0.5462967",
"0.5453... | 0.8616785 | 0 |
Given the ISBN of a book, get n relevant information for all comments about that book. | def get_comments(self, isbn, n):
result = []
self.cursor.execute("""SELECT * FROM comment WHERE ISBN=%s ORDER BY avg_usefulness DESC LIMIT %s""",
(str(isbn), n))
for comment in self.cursor.fetchall():
result.append(comment)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments_by_book(self, book_id):\n # Implemented from template for\n # osid.resource.ResourceBinSession.get_resources_by_bin\n mgr = self._get_provider_manager('COMMENTING', local=True)\n lookup_session = mgr.get_comment_lookup_session_for_book(book_id, proxy=self._proxy)\n ... | [
"0.6394735",
"0.58236885",
"0.57772076",
"0.56973577",
"0.566967",
"0.55916137",
"0.5555044",
"0.5552309",
"0.5548011",
"0.54580206",
"0.54438627",
"0.5385552",
"0.5383615",
"0.5363736",
"0.5341239",
"0.5337437",
"0.5321707",
"0.5316787",
"0.5306555",
"0.5299457",
"0.52939415... | 0.79621714 | 0 |
Given a comment ID, update the average usefulness. This will only ever be called internally, so no need for validity checks. | def update_comment_avg_score(self, commentID):
self.cursor.execute("""UPDATE comment SET avg_usefulness=(2*veryUseful+useful)/(veryUseful+useful+useless)
WHERE commentID=%s""", (commentID,))
self.db.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_comment_usefulness(self):\n self.cursor.execute(\"\"\"UPDATE comment SET veryUseful=0, useful=0, useless=0, avg_usefulness=NULL\"\"\")\n self.db.commit()\n self.cursor.execute(\"\"\"SELECT * FROM rates\"\"\")\n for rating in self.cursor.fetchall():\n self.update_co... | [
"0.66975546",
"0.5790807",
"0.5765285",
"0.5579822",
"0.5506458",
"0.5442541",
"0.5431748",
"0.5343486",
"0.5267532",
"0.52481896",
"0.5233075",
"0.5226774",
"0.5194109",
"0.5163567",
"0.5147953",
"0.5120395",
"0.5106639",
"0.50918096",
"0.5082242",
"0.5078047",
"0.5047185",
... | 0.80525345 | 0 |
Maintenance function for updating all comment usefulness values. This should only be called in the case of a customer account being deleted. | def update_comment_usefulness(self):
self.cursor.execute("""UPDATE comment SET veryUseful=0, useful=0, useless=0, avg_usefulness=NULL""")
self.db.commit()
self.cursor.execute("""SELECT * FROM rates""")
for rating in self.cursor.fetchall():
self.update_comment_score(rating[0],... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_issue_delete_comment_deprecated(self):\n pass",
"def standardize_comments(df, column_name):\n # create a copy of the dataframe\n df_copy = df.copy()\n # remove rows that contain '[deleted]' or '[removed]' in the comment body\n df_copy = df_copy[(df[column_name] != '[removed]') & (df[c... | [
"0.5566898",
"0.5496297",
"0.5447388",
"0.53928477",
"0.53862935",
"0.5370087",
"0.52498823",
"0.5237984",
"0.5140959",
"0.5121164",
"0.5116408",
"0.5115946",
"0.50965947",
"0.50806594",
"0.5073641",
"0.5072741",
"0.50522643",
"0.5040005",
"0.5038804",
"0.5034418",
"0.5019661... | 0.6196248 | 0 |
Given a single login ID, see if that customer exists on the database. Return true if so, false if not. | def search_customers(self, loginID):
self.cursor.execute("""SELECT COUNT(*) FROM customercredentials WHERE loginID = %s""", (loginID,))
if self.cursor.fetchone()[0]:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_customer_id_exist(customer_id) -> bool:\n with MY_CONNECTION as connection:\n cursor = connection.cursor()\n cursor.execute(\"SELECT exists(SELECT 1 FROM Customers WHERE id_customer=?)\", (customer_id,))\n return cursor.fetchone()[0] == 1",
"def is_customer_exists(login, email):\n ... | [
"0.77798474",
"0.76868355",
"0.7255544",
"0.67962533",
"0.67014456",
"0.6624874",
"0.66193676",
"0.65199184",
"0.64875746",
"0.6345606",
"0.6319818",
"0.6297829",
"0.6292088",
"0.6242173",
"0.61170304",
"0.6070107",
"0.6045518",
"0.6015249",
"0.6007035",
"0.5990626",
"0.59881... | 0.77091205 | 1 |
Update the trust status given both usernames and the status. If a relationship between the two usernames exists, either update the status if it is changing the status OR delete the relationship if the status is the same (since we are removing the trust status). Otherwise, just create a new relationship. | def update_trust_status(self, loginID, otherLoginID, status):
self.cursor.execute("""SELECT trustStatus FROM trusts WHERE loginID=%s AND otherLoginID=%s""",
(loginID, otherLoginID))
result = self.cursor.fetchone()
if result:
if result[0] == status:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_signing_cert(self, cert_id, status, user_name=None):\r\n params = {'CertificateId' : cert_id,\r\n 'Status' : status}\r\n if user_name:\r\n params['UserName'] = user_name\r\n return self.get_response('UpdateSigningCertificate', params)",
"def _update_sta... | [
"0.51980627",
"0.51476276",
"0.5094613",
"0.5001692",
"0.49981746",
"0.4995808",
"0.49869204",
"0.4980151",
"0.49481377",
"0.4947407",
"0.49399808",
"0.49398693",
"0.49398693",
"0.487932",
"0.48444963",
"0.48431697",
"0.4832812",
"0.48214483",
"0.47978377",
"0.47910407",
"0.4... | 0.6515254 | 0 |
Given a single login ID, get basic info (name, number of orders made, number of books purchased, comments, total trust score, number trusted and untrusted, etc.). AVOID sensitive information (address, | def get_basic_userinfo(self, loginID, my_id):
info = {'loginID': '', 'firstName': '', 'lastName': '', 'orderCount': 0, 'books_purchased': 0,
'num_comments': 0,
'comments': [], 'books_commented': [], 'trusted': 0, 'untrusted': 0, 'personalStatus': ''}
self.cursor.execute("... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_orders(self, loginID):\n order_details = {}\n self.cursor.execute(\"\"\"SELECT orderNumber, orderDate FROM orderlog WHERE loginID=%s \n ORDER BY orderDate DESC, orderNumber DESC\"\"\", (loginID,))\n for order in self.cursor.fetchall():\n order_details[str(order[0... | [
"0.5838145",
"0.57874995",
"0.5712863",
"0.5696862",
"0.5646664",
"0.56201595",
"0.56026673",
"0.54782397",
"0.54718333",
"0.54540867",
"0.5419229",
"0.5384394",
"0.53752536",
"0.53589827",
"0.53411764",
"0.5340962",
"0.532667",
"0.53239703",
"0.53219485",
"0.5312928",
"0.531... | 0.75878596 | 0 |
Given the login ID of a customer, remove the customer from the database. Note that the ID passed in to this function is unchecked and so proper validity checks need to be in place. | def remove_customer(self, loginID):
try:
self.cursor.execute("""SELECT COUNT(*) FROM customercredentials WHERE loginID=%s""", (loginID,))
if not self.cursor.fetchone()[0]:
return False
self.cursor.execute("""DELETE FROM customercredentials WHERE loginID=%s""",... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_customer(customer_id):\n try:\n remove_user = cm.Customers.get(cm.Customers.customer_id == customer_id)\n remove_user.delete_instance()\n except cm.DoesNotExist:\n logging.info(\"Customer successfully deleted from database.\")",
"def delete_customer(customer_id):\n with c... | [
"0.78983843",
"0.7327206",
"0.72582763",
"0.72373587",
"0.7197035",
"0.7154331",
"0.70046926",
"0.6938491",
"0.69187766",
"0.69126296",
"0.6911033",
"0.6747551",
"0.6737351",
"0.6678386",
"0.65200084",
"0.64759135",
"0.64430314",
"0.63739216",
"0.62082744",
"0.60372424",
"0.5... | 0.77048546 | 1 |
Given a login ID of a manager, remove the manager from the database. Note that the ID passed in to this function is unchecked and so proper validity checks need to be in place. However, this function will only be called after an authority validation has taken place, so we do not need to ensure that the caller is a supe... | def remove_manager(self, loginID):
try:
self.cursor.execute("""SELECT COUNT(*) FROM managercredentials WHERE loginID=%s""", (loginID,))
if not self.cursor.fetchone()[0]:
return False
self.cursor.execute("""DELETE FROM managercredentials WHERE loginID=%s""", (l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manager_remove(self, manager):\n self.request('/v1.1/managers/configs/%s' % manager, 'DELETE')",
"def remove_store_manager(user_name: str, store_manager_name: str, store_name: str):\n\n user_name = auth.get_username_from_hash(user_name)\n permission_handler.is_permmited_to(user_name, Action.REMO... | [
"0.6349377",
"0.6214349",
"0.60781866",
"0.59333056",
"0.57762134",
"0.564966",
"0.54429406",
"0.5420275",
"0.54007703",
"0.54007703",
"0.5385557",
"0.53853744",
"0.53794116",
"0.53059447",
"0.5249178",
"0.5243765",
"0.5243492",
"0.52429736",
"0.5232355",
"0.5206753",
"0.5203... | 0.7577217 | 0 |
Given details needed to locate a book from a certain order and a quantity, create a return request for quantity amount of that book. | def request_return(self, orderNumber, ISBN, quantity):
date = datetime.date.today()
self.cursor.execute("""INSERT INTO returnrequest (orderNumber, requestDate, ISBN, quantity)
VALUES (%s,%s,%s,%s)""", (orderNumber, date, ISBN, quantity))
self.db.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):\n order = None\n args = book_return_parser.parse_args()\n order_id = args['order_id']\n copy_id = args['copy_id']\n if order_id is not None and copy_id is not None:\n return 'Only one parameter is needed', 400\n if order_id is not None:\n ... | [
"0.6053869",
"0.6048009",
"0.6044216",
"0.5897844",
"0.58446103",
"0.5696819",
"0.55940896",
"0.55275124",
"0.54358864",
"0.5434902",
"0.5411537",
"0.54063505",
"0.5378661",
"0.5351381",
"0.5297224",
"0.5285088",
"0.52831036",
"0.5255942",
"0.525464",
"0.5244282",
"0.52399427... | 0.6794005 | 0 |
Given a login ID, return a dict containing all of the return requests associated with the user. | def get_return_requests(self, loginID):
result = {'requestID': [], 'orderNumber': [], 'requestDate': [], 'ISBN': [], 'quantity': [], 'orderDate': [],
'status': [], 'title': []}
self.cursor.execute("""SELECT requestID, R.orderNumber, requestDate, B.ISBN, quantity, orderDate, status, B.t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_info_by_id(self, user_id: int) -> dict:",
"def get_all_requests(user_id):\n db = get_db()\n requests = db.requests\n \n # Check if the user_id is a string\n if not isinstance(user_id, str):\n raise APIException(status_code=400, message='user_id not a string')\n \n cursor ... | [
"0.55100137",
"0.53969973",
"0.53640866",
"0.5216878",
"0.5162285",
"0.51496017",
"0.5084875",
"0.50645024",
"0.5029313",
"0.5011257",
"0.49894708",
"0.49887967",
"0.49819955",
"0.49323818",
"0.4917424",
"0.49163958",
"0.48780292",
"0.4853705",
"0.4852659",
"0.48472676",
"0.4... | 0.6872694 | 0 |
Function to find all of the return requests with a status of "PENDING". This is for the manager view for when he/she wishes to accept or deny requests. | def get_pending_requests(self):
result = {'requestID': [], 'orderNumber': [], 'requestDate': [], 'ISBN': [], 'quantity': [], 'orderDate': [],
'title': []}
self.cursor.execute("""SELECT requestID, R.orderNumber, requestDate, B.ISBN, quantity, orderDate, B.title
FROM ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_pending_accounts(cls):\n return cls.query.filter_by(status=CfsAccountStatus.PENDING.value).all()",
"def get_pending_registration_requests(self,user,site):\n\n return self.filter(project=site,\n user=user,\n status=RegistrationRequest.... | [
"0.6479581",
"0.6326572",
"0.6316774",
"0.62999344",
"0.6126734",
"0.61056966",
"0.60382605",
"0.5866562",
"0.57933176",
"0.5786126",
"0.57370985",
"0.5717551",
"0.5700132",
"0.5696704",
"0.5616951",
"0.5557678",
"0.5550404",
"0.5544873",
"0.5542309",
"0.5527181",
"0.5525483"... | 0.7002635 | 0 |
Update the database once the manager makes a decision on a return request. The boolean parameter "approved" is passed to indicate whether the manager accepted or rejected the request. Upon approval, update the status of the return request, then update the order by removing the amount of books specified by quantity and ... | def update_request_status(self, requestID, ISBN, quantity, approved):
if approved:
self.cursor.execute("""SELECT orderNumber FROM returnrequest WHERE requestID=%s""", (requestID,))
orderNumber = self.cursor.fetchone()[0]
self.cursor.execute("""UPDATE returnrequest SET status=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_return(self, orderNumber, ISBN, quantity):\n\n date = datetime.date.today()\n\n self.cursor.execute(\"\"\"INSERT INTO returnrequest (orderNumber, requestDate, ISBN, quantity)\n VALUES (%s,%s,%s,%s)\"\"\", (orderNumber, date, ISBN, quantity))\n self.db.commit()",
"def on_up... | [
"0.6181021",
"0.5821405",
"0.5728504",
"0.5678125",
"0.56594336",
"0.5642089",
"0.5628899",
"0.5625057",
"0.56249446",
"0.5601221",
"0.5569007",
"0.5563893",
"0.55225724",
"0.55221975",
"0.5515816",
"0.5506918",
"0.5492608",
"0.5466435",
"0.54306227",
"0.5397892",
"0.5373693"... | 0.76989347 | 0 |
Return a list of all ISBN's in the database. This is used to randomly select books for orders in the mock data | def demo_get_all_books(self):
results = []
self.cursor.execute("""SELECT ISBN FROM book""")
for book in self.cursor.fetchall():
results.append(book[0])
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_books_in_order(self, orderNumber):\n self.cursor.execute(\"\"\"SELECT ISBN, quantity FROM orderlog O, productof P WHERE O.orderNumber = P.orderNumber\n AND O.orderNumber=%s\"\"\",(orderNumber,))\n result = []\n for i in self.cursor.fetchall():\n result.append([i[0],i[... | [
"0.68952596",
"0.68626666",
"0.68582714",
"0.6747548",
"0.6734756",
"0.64708024",
"0.6463513",
"0.633142",
"0.63001794",
"0.62979406",
"0.6250897",
"0.62271947",
"0.6175948",
"0.61665535",
"0.6147512",
"0.61141545",
"0.6082323",
"0.6067532",
"0.60593945",
"0.6036859",
"0.6009... | 0.81246585 | 0 |
Processes the tokenized articles and generates a DataFrame Returns pd.DataFrame | def process_wiki_tokenized() -> pd.DataFrame:
text_ids = []
text_string = []
articles = []
text_ids_intro = []
with open(WIKI_ARTICLES_TOKENIZED_PATH, "r") as json_file:
json_list = list(json_file)
for json_str in tqdm(json_list):
result = json.loads(json_str)
sections ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenization(dataframe):\n nlp = English()\n tokenizer = nlp.Defaults.create_tokenizer(nlp)\n stemmer = SnowballStemmer(\"english\")\n\n dataframe.loc[:, \"tokens\"] = dataframe.loc[:, \"content\"].apply(\n lambda cell: [\n token.lemma_\n for token in tokenizer(cell)\n ... | [
"0.65940297",
"0.65564024",
"0.65153795",
"0.64343864",
"0.6338675",
"0.6319045",
"0.62618953",
"0.6175134",
"0.61724496",
"0.6104356",
"0.60394055",
"0.60166335",
"0.5988761",
"0.59751725",
"0.5969283",
"0.59643435",
"0.5955965",
"0.5925812",
"0.592225",
"0.5913911",
"0.5912... | 0.76601696 | 0 |
Get list of installed kerneldevel packages. | def kdevel():
return subprocess.check_output([
"rpm", "-q", "-a", "kernel-devel"]).splitlines() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_installed_jdk_packages():\n # Convert to a set and back to a list again to uniqueify.\n return sorted(list(set(rpm_query_whatprovides('java-devel', 'java7-devel', 'jdk'))))",
"def get_installed_jre_packages():\n # Convert to a set and back to a list again to uniqueify.\n return sorted(list(se... | [
"0.73078793",
"0.6860375",
"0.6792763",
"0.66517985",
"0.6592715",
"0.6348581",
"0.63128823",
"0.6310863",
"0.6231832",
"0.6145637",
"0.61211216",
"0.61205536",
"0.61111844",
"0.60494787",
"0.6042742",
"0.598851",
"0.5966998",
"0.5907414",
"0.58974636",
"0.58636194",
"0.58604... | 0.7870529 | 0 |
Gets statistics about every english leauge game players competed in for the specified year (year must be between 2005 & 2010). If use_local is True, then if they exist, the shelved player games for the year will be returned without resorting to reparsing the fixtures for each team. | def get_player_games(self, year, use_local=True): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_player_stats_from_game(team, year, week):",
"def getPlayerBaseStat(self, year = 2014):\r\n \r\n year_next = (year % 100) + 1\r\n season = str(year) + '-' + str(year_next)\r\n \r\n stat_url = 'http://stats.nba.com/stats/leaguedashplayerstats?College=&'\\\r\n ... | [
"0.6519908",
"0.5899349",
"0.57082665",
"0.5681794",
"0.56795835",
"0.56269175",
"0.5610314",
"0.55635273",
"0.5557057",
"0.5533035",
"0.5482166",
"0.5445572",
"0.53892154",
"0.5381348",
"0.53558725",
"0.53406656",
"0.5335924",
"0.5334206",
"0.5321553",
"0.5291166",
"0.527081... | 0.7862858 | 0 |
Itera sobre los items del carrito y obtiene los productos de la base de datos | def __iter__(self):
ids_productos = self.carro.keys()
#obtiene los objetos producto y los agrega al carro
productos = Producto.objects.filter(id__in=ids_productos)
for producto in productos:
self.carro[str(producto.id)]['producto'] = producto
for item in self.carro.v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obtener_productos():\n\n # Se crea la lista de objetos Producto()\n productos = [\n Producto(\"Caja chica\", 5, 100.0),\n Producto(\"Caja mediana\", 3, 185.0),\n Producto(\"Caja grande\", 1, 299.0)\n ]\n\n return productos",
"def get_data(self):\n products_list = []\n ... | [
"0.7394557",
"0.7128512",
"0.70565516",
"0.69151694",
"0.686523",
"0.6854671",
"0.68118054",
"0.6673467",
"0.66018593",
"0.65965927",
"0.65736145",
"0.6560011",
"0.6546499",
"0.6536913",
"0.653328",
"0.6517128",
"0.65117145",
"0.6508801",
"0.6440741",
"0.6420369",
"0.6409673"... | 0.74252695 | 0 |
Agregar un producto al carrito o actualizar su cantidad. | def add(self, producto, cantidad = 1, actualizar_cantidad = False):
id_producto = str(producto.id)
if id_producto not in self.carro:
self.carro[id_producto] = {"cantidad":0,"precio":str(producto.precio)}
if actualizar_cantidad:
self.carro[id_producto]["cantidad"]= cantida... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def agregar_producto(self, producto):\n\n self.productos.append(producto)",
"def agregarProducto(self):\n itemActual=self.tableFactura.currentItem()\n producto = int(self.tableFactura.item(itemActual.row(),0).text())\n descuento = DescuentoModel.buscar(DescuentoModel.obra_social,self.... | [
"0.74455756",
"0.73769337",
"0.72791195",
"0.68235534",
"0.68147254",
"0.6459701",
"0.6367066",
"0.63326365",
"0.62502146",
"0.6228306",
"0.6128186",
"0.60275525",
"0.5993757",
"0.5993371",
"0.58744925",
"0.5865621",
"0.5846246",
"0.58283526",
"0.58283526",
"0.5824645",
"0.58... | 0.79951173 | 0 |
Test that enumeration are properly detected | def test_enum_detection():
grammar = """
IsEnum: "keyword1" | "keyword2" | "keyword3";
IsNotEnum: val="keyword1" | val="keyword2" | val="keyword3";
StillNotEnum: val="keyword1" | "keyword2" | "keyword3";
// identified as EDatatype with object type
NotEnumAgain: SubEnum | SubEnum2;
// this... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_test_enum_parameters(self):\n pass",
"def test_driver_enums(self):\n\n self.assert_enum_has_no_duplicates(DataParticleType())\n self.assert_enum_has_no_duplicates(ProtocolState())\n self.assert_enum_has_no_duplicates(ProtocolEvent())\n self.assert_enum_has_no_duplicate... | [
"0.72406197",
"0.6865994",
"0.678129",
"0.6744498",
"0.65896946",
"0.6527991",
"0.64988136",
"0.6457832",
"0.6426472",
"0.64170265",
"0.6393479",
"0.6368146",
"0.63569844",
"0.63335544",
"0.62593937",
"0.6241549",
"0.62227577",
"0.622051",
"0.62172335",
"0.6112095",
"0.608404... | 0.70447934 | 1 |
sign of x, i.e. +1 or 1; returns 1 for x == 0 | def sign(x):
if x >= 0:
return 1
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(x):\n if x >= 0:\n return 1\n else:\n return -1",
"def signum(x: float) -> float:\n if x < 0:\n return -1.0\n elif x > 0:\n return 1.0\n return 0.0",
"def sign(x):\n return(copysign(1, x))",
"def sign(num: float):\n return 1 if num >= 0 else -1",
"d... | [
"0.923454",
"0.83496517",
"0.8333785",
"0.82949734",
"0.8244531",
"0.8236217",
"0.7956602",
"0.78698367",
"0.7838812",
"0.7807624",
"0.75421077",
"0.742348",
"0.74220794",
"0.7420152",
"0.72951996",
"0.7290333",
"0.7282625",
"0.72503245",
"0.71639484",
"0.71388626",
"0.708815... | 0.92341864 | 1 |
gives the real roots of x2 + a1 x + a0 = 0 | def _realroots_quadratic(a1, a0):
D = a1*a1 - 4*a0
if D < 0:
return []
SD = math.sqrt(D)
return [0.5 * (-a1 + SD), 0.5 * (-a1 - SD)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _realroots_cubic(a2, a1, a0):\n # see http://mathworld.wolfram.com/CubicFormula.html for details\n\n Q = (3*a1 - a2*a2) / 9.0\n R = (9*a2*a1 - 27*a0 - 2*a2*a2*a2) / 54.0\n D = Q*Q*Q + R*R\n\n if D > 0: # one real and two complex roots\n SD = math.sqrt(D)\n if R + SD >= 0:\n... | [
"0.7072745",
"0.6673059",
"0.66104",
"0.65342593",
"0.6513323",
"0.6455991",
"0.64308345",
"0.6430545",
"0.6397649",
"0.63600725",
"0.6351306",
"0.6308762",
"0.6297681",
"0.62692684",
"0.62394047",
"0.6201631",
"0.61936194",
"0.61782265",
"0.6142859",
"0.6139535",
"0.6117559"... | 0.7336006 | 0 |
In order to split, there must be a token that is two words. That means there is at least one duplicated word_end that is not a word. | def split_precondition(
tokens: Sequence[str], words: Sequence[str], word_ends: Sequence[str]
) -> bool:
duplicated_word_ends = []
for end1, end2 in zip(word_ends, word_ends[1:]):
if end1 == end2:
duplicated_word_ends.append(end1)
if not duplicated_word_ends:
return False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subword_tokenize(self, word: str) -> List[str]:\r\n end_idx = min([len(word), self.ngram_max])\r\n sw_tokens = [self.SOW]\r\n start_idx = 0\r\n\r\n while start_idx < len(word):\r\n subword = word[start_idx:end_idx]\r\n if subword in self.bpe_vocab:\r\n ... | [
"0.65557843",
"0.6295449",
"0.6196509",
"0.6070473",
"0.6030138",
"0.5977965",
"0.5975292",
"0.5914505",
"0.58049476",
"0.5770824",
"0.5767611",
"0.5764669",
"0.57122844",
"0.5690039",
"0.5681785",
"0.5662937",
"0.5659659",
"0.56561136",
"0.5654984",
"0.5654885",
"0.56434584"... | 0.7395432 | 0 |
Returns a pandas dataframe denoting the total number of NA values and the percentage of NA values in each column. The column names are noted on the index. | def assess_NA(data):
# pandas series denoting features and the sum of their null values
null_sum = data.isnull().sum() # instantiate columns for missing data
total = null_sum.sort_values(ascending=False)
percent = (((null_sum / len(data.index)) * 100).round(2)). \
sort_values(ascending=False)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def na_count(df):\n print(\"Size of the current file is:\", df.shape)\n print(\"\")\n printmd(\"*__Percentage of Na per columns in the data:__*\")\n # Calculate the number of the NA values and its precentage\n df_temp = df.isnull().sum().reset_index()\n df_temp.columns = ['column_name', 'na_size'... | [
"0.76396763",
"0.7637532",
"0.7542576",
"0.72621375",
"0.7246462",
"0.7233",
"0.7130642",
"0.71104866",
"0.70493215",
"0.6875617",
"0.684683",
"0.6755909",
"0.6543785",
"0.6444147",
"0.64351976",
"0.6404165",
"0.6404165",
"0.62979305",
"0.62778085",
"0.62736887",
"0.62029946"... | 0.7825975 | 0 |
Optimized gif, jpg and png images. If the FLAG settings is set to True, just rename the file alread optimized. | def image_optimizer_finalized(pelican):
for dirpath, _, filenames in os.walk(pelican.settings['OUTPUT_PATH']):
for name in filenames:
if os.path.splitext(name)[1] in COMMANDS.keys():
if pelican.settings[FLAG]:
if '_optimized' in name:
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_gif():\n if MIGRATION:\n import imageio\n for n, JPG_DIR in enumerate(JPG_DIRS):\n images, image_file_names = [], []\n for file_name in os.listdir(JPG_DIR):\n if file_name.endswith('.jpg'):\n image_file_names.append(file_name) ... | [
"0.64518267",
"0.60565406",
"0.6031277",
"0.6013981",
"0.58980536",
"0.5897385",
"0.5897077",
"0.5859662",
"0.57910424",
"0.57670325",
"0.57307136",
"0.5720459",
"0.56009597",
"0.5590175",
"0.5568311",
"0.55400527",
"0.55328435",
"0.55229425",
"0.54522663",
"0.5441755",
"0.54... | 0.6643921 | 0 |
core function for parallel run_correlation | def run_correlation_worker(run_parameters, spreadsheet_df, phenotype_df, job_id):
# selects the ith row in phenotype_df
np.random.seed(job_id)
phenotype_df = phenotype_df.iloc[[job_id], :]
spreadsheet_df_trimmed, phenotype_df_trimmed, err_msg = datacln.check_input_value_for_gene_prioritazion(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_correlation(data):\n pass",
"def auto_correlation(arr):\n return cross_correlation(arr, arr)",
"def run_net_correlation_worker(run_parameters, spreadsheet_df, phenotype_df, network_mat,\n spreadsheet_genes_as_input, baseline_array, job_id):\n\n np.random... | [
"0.70680016",
"0.6528472",
"0.6504297",
"0.63749677",
"0.6360196",
"0.63229495",
"0.6294331",
"0.6224919",
"0.62199193",
"0.62124133",
"0.6204594",
"0.61613137",
"0.6061361",
"0.60537165",
"0.6026039",
"0.6024764",
"0.5963405",
"0.59373075",
"0.59083116",
"0.59070826",
"0.584... | 0.657478 | 1 |
core function for parallel run_bootstrap_correlation | def run_bootstrap_correlation_worker(run_parameters, spreadsheet_df, phenotype_df, n_bootstraps, job_id):
np.random.seed(job_id)
phenotype_df = phenotype_df.iloc[[job_id], :]
spreadsheet_df_trimmed, phenotype_df_trimmed, ret_msg = datacln.check_input_value_for_gene_prioritazion(
spreadsheet_df, ph... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_bootstrap_correlation(run_parameters):\n run_parameters[\"results_tmp_directory\"] = kn.create_dir(run_parameters[\"results_directory\"], 'tmp')\n\n phenotype_response_df = kn.get_spreadsheet_df(run_parameters[\"phenotype_name_full_path\"])\n spreadsheet_df = kn.get_spreadsheet_df(run_parameters[\... | [
"0.7209196",
"0.68485564",
"0.62561953",
"0.5953953",
"0.593656",
"0.58523387",
"0.58196706",
"0.57341266",
"0.5679761",
"0.563205",
"0.56270427",
"0.5559051",
"0.54862607",
"0.54845196",
"0.5357379",
"0.53566194",
"0.5339225",
"0.5313855",
"0.5287374",
"0.52761865",
"0.52660... | 0.70515513 | 1 |
core function for parallel run_net_correlation | def run_net_correlation_worker(run_parameters, spreadsheet_df, phenotype_df, network_mat,
spreadsheet_genes_as_input, baseline_array, job_id):
np.random.seed(job_id)
phenotype_df = phenotype_df.iloc[[job_id], :]
spreadsheet_df_trimmed, phenotype_df_trimmed, ret_msg = dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_net_correlation(run_parameters):\n run_parameters[\"results_tmp_directory\"] = kn.create_dir(run_parameters[\"results_directory\"], 'tmp')\n\n network_df = kn.get_network_df(run_parameters['gg_network_name_full_path'])\n\n node_1_names, node_2_names = kn.extract_network_node_names(network_df)\n ... | [
"0.6919708",
"0.6784384",
"0.6579483",
"0.61940783",
"0.6094425",
"0.586848",
"0.58443725",
"0.5801506",
"0.5733648",
"0.5731114",
"0.5730464",
"0.57225734",
"0.5692849",
"0.5674661",
"0.5672113",
"0.5648199",
"0.5641616",
"0.564092",
"0.5613428",
"0.5611891",
"0.55905354",
... | 0.7026125 | 0 |
sum to borda count with a contigous array added to borda count | def sum_array_ranking_to_borda_count(borda_count, corr_array):
num_elem = borda_count.size
# either assign (no duplicate case) or enumerate the correlation array
if num_elem == (np.unique(corr_array)).size:
borda_count[np.argsort(corr_array)] += np.int_(sorted(np.arange(0, corr_array.size) + 1))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def counts_scan_binned_add(counts,val_addr,val_timestamps,pixels,dwell_time,bin_time,x,y):\n\n counts1 = np.zeros(1,(np.ceil(dwell_time/bin_time),x,y,23))\n for i in range(x):\n for j in range(y):\n delta= 0\n while val_timestamps[pixels[i,j]+delta]- val_timestamps[pixels[i,j]]<d... | [
"0.6125926",
"0.6062502",
"0.6015958",
"0.59297216",
"0.5901682",
"0.5888271",
"0.58856165",
"0.58840656",
"0.5867621",
"0.5845964",
"0.58243126",
"0.58193743",
"0.57942975",
"0.57864875",
"0.57764876",
"0.576572",
"0.5749702",
"0.56927705",
"0.56662244",
"0.565349",
"0.56369... | 0.68930274 | 0 |
percent_sample x percent_sample random sample, from spreadsheet_mat. | def sample_a_matrix_pearson(spreadsheet_mat, rows_fraction, cols_fraction):
features_size = int(np.round(spreadsheet_mat.shape[0] * (1 - rows_fraction)))
features_permutation = np.random.permutation(spreadsheet_mat.shape[0])
features_permutation = features_permutation[0:features_size].T
patients_size =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_percent(self, percentage):\n count = int(len(self.features) * (percentage / 100))\n indices = np.random.randint(0, high=len(self.features), size=count)\n return ProcessedImageData(self.features[indices], self.labels[indices], indices)",
"def sample(self, percentage):\n if n... | [
"0.6161979",
"0.54894763",
"0.54406565",
"0.52323145",
"0.52166736",
"0.517619",
"0.51314974",
"0.51023704",
"0.50680196",
"0.5064273",
"0.5061932",
"0.5058372",
"0.5058371",
"0.5053124",
"0.5050355",
"0.50431114",
"0.5041083",
"0.5039392",
"0.5032886",
"0.50317216",
"0.50275... | 0.6506959 | 0 |
zscore by rows for genes x samples dataframe | def zscore_dataframe(genes_by_sample_df):
zscore_df = (genes_by_sample_df.sub(genes_by_sample_df.mean(axis=1), axis=0)).truediv(
np.maximum(genes_by_sample_df.std(axis=1), 1e-12), axis=0)
return zscore_df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zscore(vals):",
"def compute_z_score(stats, columns, col_name):\n if stats[col_name]['data_type'] != DATA_TYPES.NUMERIC:\n return {}\n\n z_scores = list(map(abs,(st.zscore(columns[col_name]))))\n threshold = 3\n z_score_outlier_indexes = [i for i in range(len(z_scores)) if z_scores[i] > th... | [
"0.66935366",
"0.6103009",
"0.6100811",
"0.5995226",
"0.5923462",
"0.5915038",
"0.5738564",
"0.5714042",
"0.5642529",
"0.56247556",
"0.5544849",
"0.55446357",
"0.5512652",
"0.5510265",
"0.5501829",
"0.5499937",
"0.548653",
"0.54845107",
"0.54658073",
"0.5465162",
"0.54583454"... | 0.8123862 | 0 |
Returns an object from a dot path. Path can either be a full path, in which case the `get_object` function will try to import the module and follow the path. Or it can be a path relative to the object passed in as the second argument. | def get_object(path='', obj=None):
if not path:
return obj
path = path.split('.')
if obj is None:
obj = importlib.import_module(path[0])
path = path[1:]
for item in path:
if isinstance(obj, types.ModuleType):
submodule = '{}.{}'.format(_package(obj), item)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_object(path):\n\n try:\n dot = path.rindex('.')\n except ValueError:\n raise ValueError(\"Error loading object '%s': not a full path\" % path)\n\n module, name = path[:dot], path[dot + 1:]\n mod = import_module(module)\n\n try:\n obj = getattr(mod, name)\n except Att... | [
"0.80234915",
"0.7997897",
"0.79645133",
"0.7956834",
"0.7715109",
"0.76952195",
"0.6850307",
"0.6848769",
"0.680444",
"0.6723199",
"0.66649795",
"0.66210204",
"0.6550689",
"0.6484591",
"0.6483146",
"0.6427085",
"0.641364",
"0.64006466",
"0.63594925",
"0.6324595",
"0.63090205... | 0.80496776 | 0 |
Load recursively all submodules of the modules and return all the subclasses of the provided class | def load_subclasses(klass, modules=None):
if modules:
if isinstance(modules, six.string_types):
modules = [modules]
loader = Loader()
loader.load(*modules)
return klass.__subclasses__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_class_modules(cls):\n if not issubclass(cls, spack.package_base.PackageBase) or issubclass(\n spack.package_base.PackageBase, cls\n ):\n return []\n result = []\n module = sys.modules.get(cls.__module__)\n if module:\n result = [module]\n for c in cls.__bases__:\n ... | [
"0.7165705",
"0.69359386",
"0.68156147",
"0.68128246",
"0.6774304",
"0.6754992",
"0.6701584",
"0.65855294",
"0.656538",
"0.655214",
"0.65020764",
"0.64865786",
"0.64505965",
"0.6402055",
"0.63457954",
"0.63250345",
"0.6317348",
"0.6310051",
"0.63073546",
"0.62523115",
"0.6204... | 0.72843313 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.