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 |
|---|---|---|---|---|---|---|
Make a plot of the maximum sequential mismatch between i1, i and i+1 residues | def plot_seq_mismatch(self):
assign_df = self.assign_df
# Check that the assignment data frame has the right columns
if not all(pd.Series(['Max_mismatch_prev', 'Max_mismatch_next']).
isin(assign_df.columns)):
return(None)
else:
# Pad Re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max(self, i):\n x=self.val(i,0)\n lm=len(self)\n t=1\n while t<lm:\n y=self.val(i,t)\n if x<y:\n x=y\n t+=1\n return x",
"def plotLoss():\n # ssr\n ssr = np.log(gradientDescent(X, y)[1])\n # number of iterations \n ... | [
"0.5638885",
"0.5268173",
"0.52272654",
"0.5218005",
"0.5212134",
"0.51795375",
"0.5147306",
"0.50760937",
"0.5076005",
"0.5074581",
"0.50559086",
"0.50507396",
"0.50503904",
"0.5037063",
"0.503267",
"0.50312555",
"0.49910936",
"0.49882492",
"0.4977005",
"0.4960242",
"0.49589... | 0.61684155 | 0 |
Calculate the weighted sum for a neuron, given its input and weight vectors. | def weighted_sum(W, X):
if len(W) != len(X):
print("Dimension of weight vector should be same as input vector.")
return
else:
H = 0
for i in range(len(W)):
H += (W[i] * X[i])
return H | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weighted_sum(self, inputs):\r\n weighted_sum = 0\r\n for i in range(self.num_inputs):\r\n weighted_sum += self.weights[i]*inputs[i]\r\n return weighted_sum",
"def weighted_sum(self):\n return sum(self.wvalues)",
"def _weighted_sum(self, data, sum_func):\n if self.weights.shape !... | [
"0.8262816",
"0.75817716",
"0.7246132",
"0.7226751",
"0.72047585",
"0.7077777",
"0.69817436",
"0.6904803",
"0.68985677",
"0.6836026",
"0.6766364",
"0.67473817",
"0.674198",
"0.67321444",
"0.67050034",
"0.66920304",
"0.66566294",
"0.6549743",
"0.65466267",
"0.6509698",
"0.6499... | 0.82253754 | 1 |
Driver function to run the learning mechanism for the perceptron. | def perceptron_learning(train_data, W, epoch = 3):
for T in range(epoch):
print("\nEpoch:", T + 1)
for i in range(len(train_data)):
X = train_data[i][0]
target_Y = train_data[i][1]
W = forward_pass(X, target_Y, W)
print("\tUpdated Weights: {0}\n"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learn(self):\n total_error = 0\n threshold = 0.05\n\n counter = len(self._training_set)*len(self._perceptrons)\n total_error+=self.learning_step()\n\n while total_error/counter > threshold:\n counter += len(self._training_set)*len(self._perceptrons)\n to... | [
"0.6981663",
"0.6915945",
"0.6838345",
"0.6802857",
"0.6782908",
"0.6713921",
"0.6713921",
"0.6663933",
"0.66344196",
"0.6564113",
"0.6541689",
"0.6511968",
"0.6506996",
"0.6497437",
"0.6438588",
"0.6415237",
"0.64150244",
"0.64105755",
"0.6410079",
"0.64090526",
"0.640238",
... | 0.7032752 | 0 |
Generate run level workflow for a given model. | def fsl_run_level_wf(
model,
step,
bids_dir,
output_dir,
work_dir,
subject_id,
database_path,
smoothing_fwhm=None,
smoothing_level=None,
smoothing_type=None,
use_rapidart=False,
detrend_poly=None,
align_volumes=None,
smooth_autocorrelations=False,
despike=Fals... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(cls, model):\n label = model.label\n print(\"stage1: {label} model: initializing\".format(label=label))\n\n defs_input = model.define_api() # input, original definitions\n\n print(\"stage1: {label} model: analyzing API\".format(label=label))\n\n # Compute any needed deri... | [
"0.5979851",
"0.5947662",
"0.58736104",
"0.56282383",
"0.55874467",
"0.5533119",
"0.548299",
"0.548187",
"0.5464699",
"0.5408041",
"0.54019076",
"0.5401015",
"0.5399427",
"0.535001",
"0.53481996",
"0.5329211",
"0.5314387",
"0.5314296",
"0.53109103",
"0.52955836",
"0.52823305"... | 0.6554849 | 0 |
The typeconstraint decorator allows a function or method to be augmented with strict (runtime) type asserts for all passed function arguments and returned return values. | def typeconstraints(typelist, rvtype=None):
if __debug__:
#typelist should be a valid list of types and/or callables
_check_typelist(typelist)
if rvtype != None:
_check_typelist(rvtype)
def _type_constraint_assert(typelist, kwtypelist, args, kwargs, name):
#Ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _typechecked_func(func):\n\n # Preserve the function signature\n @functools.wraps(func)\n def arg_checking_func(*args, **kwargs):\n\n # Get the annotation dict from the arg spec\n spec = inspect.getfullargspec(func)\n annotations = spec.annotations\n\n # Get the dict of {ar... | [
"0.5998885",
"0.59794515",
"0.59155893",
"0.5889241",
"0.57771724",
"0.5747098",
"0.5705614",
"0.56124425",
"0.55982745",
"0.55633444",
"0.54601717",
"0.5405215",
"0.53899294",
"0.53824687",
"0.53795624",
"0.5372615",
"0.53357077",
"0.5326451",
"0.5321901",
"0.53003836",
"0.5... | 0.6596859 | 0 |
This is the public view that displays only published posts. The view also returns a UNIX timestamp of the most recently updated post. This timestamp is compared with the `LastUpdate` value to determine when the page should be refreshed. Every 5 seconds, the `latest` timestamp is compared with the `LastUpdate` timestamp... | def home(request):
posts = Post.objects.filter(published=True)
latest = 0
if posts:
latest = Post.objects.latest('updated').unix_time()
return render(request, 'posts/home.html', {'posts':posts, 'latest':latest}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latest_blog_posts(self, request, *args, **kwargs):\n context = self.get_context(request, *args, **kwargs)\n context[\"latest_posts\"] = MyblogDetailPage.objects.live().public()[:1] \n return render(request, \"myblog/latest_posts.html\", context)",
"def published_after(self) -> Typ... | [
"0.6776165",
"0.6743756",
"0.6695067",
"0.66566783",
"0.6569601",
"0.65293163",
"0.64894444",
"0.6426086",
"0.6265299",
"0.6210194",
"0.6209103",
"0.6209103",
"0.6161691",
"0.6156912",
"0.61490613",
"0.6107539",
"0.6084435",
"0.6003141",
"0.59963083",
"0.59963083",
"0.5974884... | 0.73351926 | 0 |
This view allows an authenticated staff user to publish or unpublish an article by clicking a button. Clicking the button toggles the current state of the selected Post's `published` field. It also updates the `LastUpdated` time to be the time when the Post was updated (saved), tracked by its `updated` field This field... | def toggle_publish(request,id):
instance = get_object_or_404(Post, id=id)
if request.method=="POST":
instance.published = not instance.published
instance.save()
t, created = LastUpdate.objects.get_or_create(id=1)
t.updated = instance.updated
t.save()
cach... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish(self):\n self.published_date = timezone.now()\n self.save()",
"def publish(self):\n self.published_date = timezone.now()\n self.save()",
"def publish(self):\n self.published_date = timezone.now\n self.save()",
"def website_publish_button(self):\n i... | [
"0.6913261",
"0.6913261",
"0.69051284",
"0.6778123",
"0.64782995",
"0.6146485",
"0.61441684",
"0.6107009",
"0.59210235",
"0.58698314",
"0.55893433",
"0.55619395",
"0.54609",
"0.54232895",
"0.5420573",
"0.540784",
"0.52936935",
"0.52819693",
"0.52533954",
"0.52210134",
"0.5220... | 0.79309267 | 0 |
This is the URL that is polled by the publicfacing page. It returns a UNIX timestamp of the last time an article was published or unpublished. This timestamp comes from the `LastUpdated`, a table that stores and updates only one row with one datetime column. Publishing and unpublishing are the only two actions that cle... | def refresh(request):
t, created = LastUpdate.objects.get_or_create(id=1)
if created:
t.save()
t = t.unix_time()
else:
t = t.unix_time()
latest = int(t) - 2
return JsonResponse({'latest':int(latest)}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\n posts = Post.objects.filter(published=True)\n latest = 0\n if posts:\n latest = Post.objects.latest('updated').unix_time()\n\n return render(request, 'posts/home.html', {'posts':posts, 'latest':latest})",
"def recently_modified(request):\n pages = models.Page.all().orde... | [
"0.6282459",
"0.6166355",
"0.60982287",
"0.6045766",
"0.5987405",
"0.5974829",
"0.59494257",
"0.5877963",
"0.5846805",
"0.5837598",
"0.581873",
"0.5734147",
"0.5724185",
"0.5709027",
"0.56886184",
"0.5575758",
"0.5515635",
"0.54900813",
"0.548668",
"0.5461982",
"0.5458926",
... | 0.62316936 | 1 |
Prints the relative amount of geotted photos for different tags. | def compute_geotag_usage():
year = 2014
for tag in TEST_TAGS:
tags = [tag]
query = FlickrQuery(tags=tags, year=year)
geotagged_query = FlickrQuery(tags=tags, year=year, only_geotagged=True)
total = flickr_api.count_photos(query)
geotagged = flickr_api.count_photos(geot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_all_tag_photo_counts(self):\n data = self.db.get_query_as_list(\n '''\n select * from tag\n '''\n )\n\n for tag in data:\n print()\n print(tag)\n # query for the number of photos using the tag\n # compare it... | [
"0.6251063",
"0.5938696",
"0.57594407",
"0.5677759",
"0.56281996",
"0.56245077",
"0.55723816",
"0.55710334",
"0.5567236",
"0.5516929",
"0.54854894",
"0.5460929",
"0.54543144",
"0.5304801",
"0.52602994",
"0.52292496",
"0.52052355",
"0.51712507",
"0.51568824",
"0.5136221",
"0.5... | 0.73562473 | 0 |
Check cash report validation. | def test_cash_report_validation(self):
self.assertEqual(self.cash_report.caffe, self.caffe)
with self.assertRaises(Exception):
CashReport.objects.create(
creator=self.kate,
caffe=self.filtry,
cash_before_shift=2000,
cash_after... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_report_cancellation(self):\n if self.pci_compliance_table_empty:\n return True\n else:\n raise AssertionError(\"ReportsPciCompliancePage: Report generated, cancel did not work. Traceback: %s\" %traceback.format_exc())",
"def checking_account(ctx, year=CURRENT_YEAR):... | [
"0.63391995",
"0.63245004",
"0.6288252",
"0.61693585",
"0.6160448",
"0.60249025",
"0.5959139",
"0.5932961",
"0.5905156",
"0.5881546",
"0.5858942",
"0.5831412",
"0.571367",
"0.5713528",
"0.57118255",
"0.56986815",
"0.5693883",
"0.5690262",
"0.56884676",
"0.5674444",
"0.5673302... | 0.70197654 | 0 |
This is where we execute the weak classifier (could be changed depends on how we use scikitlearn) | def run_weak_classifier(x: np.ndarray, c: svm.SVC) -> int:
x = x.reshape((1, 36))
return 1 if c.predict(x)[0] == 1 else 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.clf = DummyClassifier(strategy='most_frequent')",
"def apply_classifier(self):\n for detected_object in self.detected_objects:\n detected_object.predict_class(self.original_image)",
"def make_classifiers(NAMES) :\r\n\r\n# if len(data_shape) != 2:\r\n# ... | [
"0.6347355",
"0.6297496",
"0.6291746",
"0.6202337",
"0.6193591",
"0.6191824",
"0.618711",
"0.61780643",
"0.61642957",
"0.6145529",
"0.61319965",
"0.61310965",
"0.6052063",
"0.6018507",
"0.5970571",
"0.5958177",
"0.5944248",
"0.591131",
"0.5883216",
"0.5870525",
"0.58594894",
... | 0.63923275 | 0 |
Function to get the points density some kilometers around. | def get_points_density(df, around=5):
grad_to_lat = 1 / 111
grad_to_lon = 1 / 85
densities = np.empty((df.shape[0],), dtype="float64")
for i in tqdm(range(df.shape[0]), desc="GETTING POINTS DENSITY"):
lon, lat = df["lon"].iloc[i], df["lat"].iloc[i]
min_lon = lon - around * grad_to_lon
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dist_in_meters(coords, pt, is_geo=False):\n xe = coords[:, 0]\n ye = coords[:, 1]\n xp = pt[0]\n yp = pt[1]\n if is_geo:\n d = _get_dist_geo(xe, ye, xp, yp)\n else:\n d = np.sqrt(np.square(xe - xp) + np.square(ye - yp))\n return d",
"def getDensityEstimate(self):\n retur... | [
"0.6398064",
"0.6319087",
"0.6311549",
"0.61664116",
"0.61595094",
"0.60581064",
"0.6052638",
"0.6007596",
"0.6007596",
"0.6007596",
"0.59518933",
"0.5949224",
"0.59451354",
"0.59221363",
"0.59030116",
"0.59027517",
"0.58391166",
"0.5806915",
"0.58037716",
"0.579581",
"0.5765... | 0.65881675 | 0 |
Gets altitudes for each point in the dataset. | def get_altitude(points):
altitudes = np.zeros((len(points),), dtype="float64")
for i, point in tqdm(enumerate(points), desc="GETTING ALTITUDE"):
p = Point(point[0], point[1])
altitudes[i] = alt.NM_COTA.iloc[
np.argmin([p.distance(alt.geometry.iloc[j]) for j in range(alt.shape[0])])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def altitude_profile(self, alt):\n # checking if the units entered are km\n if alt.unit == u.km:\n if 150 <= alt.value < 500:\n alt_properties = self._altitude_profile(500)\n else:\n alt_properties = self._altitude_profile(alt.value)\n\n retu... | [
"0.63002145",
"0.6118353",
"0.6036766",
"0.59432745",
"0.5901361",
"0.5760974",
"0.5740872",
"0.5735877",
"0.5718014",
"0.5718014",
"0.5513645",
"0.54787827",
"0.5413163",
"0.5357624",
"0.5353968",
"0.5290058",
"0.52800673",
"0.52408457",
"0.5229023",
"0.521252",
"0.52060795"... | 0.74086666 | 0 |
Function to retrieve the postal code for points, where points are in the form (lon, lat). Using the cod_postales df, which has the polygons for each postal code, it checks which of those polygons each point falls into. | def get_postal_codes(pts):
codigos = np.zeros((len(pts),))
for i, p in tqdm(enumerate(pts), desc="GETTING POSTAL CODES"):
p = Point(p[0], p[1])
for j in range(cod_postales.shape[0]):
if cod_postales.geometry.iloc[j].contains(p):
codigos[i] = cod_postales.geocodigo.ilo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_coordinates(postal_code):\n # TODO IMPROVE: ideally we want the exact coordinates of postal_code not the ones of the closest...\n # TODO IMPROVE: ...postal code !!\n # we pre loaded PC_COORD to speed up computations\n name = PC_COORD.ix[(PC_COORD['Postal Code']-postal_code).abs().argsort()[0]]\... | [
"0.670823",
"0.6391476",
"0.6331876",
"0.62135416",
"0.6208245",
"0.61267316",
"0.61001396",
"0.6065855",
"0.60385805",
"0.59708697",
"0.59456575",
"0.5836735",
"0.5771706",
"0.5768379",
"0.5754186",
"0.5750127",
"0.57468444",
"0.5657628",
"0.5639917",
"0.5562164",
"0.5562164... | 0.7483414 | 0 |
Get nomecalles geopandas dfs and put them in a list so that it's easier to work with them. | def get_dfs(d):
dfs, nombres = [], []
for folder in tqdm(os.listdir(d), desc="GETTING DFS"):
try:
nombre = [
f
for f in os.listdir(f"{d}/{folder}/".replace(".zip", ""))
if ".shp" in f
][0]
dfs.append(
gpd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_full_df(self):\n\n galaxies = []\n for i, gal_name in enumerate(self.filenames):\n g_df = self.galaxies[gal_name].all_particle_properties(\n ).to_pandas()\n g_df['name'] = self.names[i]\n g_df['snap'] = self.snaps[i]\n galaxies.append... | [
"0.6158281",
"0.610895",
"0.60339415",
"0.6030847",
"0.59688616",
"0.5811073",
"0.575158",
"0.57174355",
"0.5686521",
"0.56752264",
"0.562989",
"0.5607882",
"0.5577681",
"0.5574744",
"0.556893",
"0.5491283",
"0.54881614",
"0.54848737",
"0.54663676",
"0.54194695",
"0.54155636"... | 0.6488763 | 0 |
Computes the closest point and the distance to that point between a node and a bunch of nodes. | def closest_node(node, nodes):
nodes = np.asarray(nodes)
deltas = nodes - node
dist_2 = np.einsum("ij,ij->i", deltas, deltas)
return np.argmin(dist_2), np.min(dist_2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest_distance(node_a, node_b):\n min_distance = 999999\n for loc_a in node_a.locations:\n for loc_b in node_b.locations:\n distance = abs(loc_a - loc_b)\n if distance < min_distance:\n min_distance = distance\n return min_distance",
"def nearest(node):\... | [
"0.7484746",
"0.7284081",
"0.70258313",
"0.6996472",
"0.69453377",
"0.68580085",
"0.6807555",
"0.680604",
"0.6757734",
"0.67107964",
"0.6644982",
"0.6607563",
"0.6567184",
"0.65596324",
"0.65584254",
"0.6546391",
"0.6523858",
"0.6522769",
"0.6504902",
"0.6490411",
"0.6470356"... | 0.7827218 | 0 |
Takes a name and, looking for the lat and lon inside the dictionary of that name, it applies a cluster over them and therefore we obtain a cluster assignation per observation. This is no longer used, as finally the nomecalles variables are merged by postal code, not by cluster. | def get_clusters(nombre):
lon, lat = mydic[nombre]["lon"], mydic[nombre]["lat"]
scaled_lon = scaler_lon.transform(np.array(lon).reshape(-1, 1))
scaled_lat = scaler_lat.transform(np.array(lat).reshape(-1, 1))
clusters = kmeans.predict(
pd.DataFrame({"x": [l for l in scaled_lat], "y": [l for l in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster(self):\n\n result_nominatim = self.nominatim()\n try:\n coord = [(float( i['lat'] ), float( i['lon'] )) for i in result_nominatim]\n except:\n return None\n #print( \"coord\", coord )\n kms_per_radian = 6371.0088\n # Augmenter cette valeur... | [
"0.64279515",
"0.6188523",
"0.59802896",
"0.589369",
"0.5795992",
"0.575479",
"0.573511",
"0.569162",
"0.56280583",
"0.55300635",
"0.54847544",
"0.5484267",
"0.5438558",
"0.5427215",
"0.5391092",
"0.5350719",
"0.53224",
"0.531496",
"0.53005534",
"0.5293131",
"0.5291993",
"0... | 0.65196955 | 0 |
Load a DOT file. | def load_dot(self, dot_file):
# print("Loading " + dot_file + "...")
self.load_data_from_filename(dot_file)
if self.name == None:
return
self.generate_signatures()
self.load_graph(dot_file)
if not self.is_graph_loaded():
return
self.add_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __loadDotFile(self):\n # Load the dot file into memory\n self.__graph = pgv.AGraph(self.__dotFile)\n\n self.__allNodes = self.__graph.nodes()\n\n # Prune the graph, as desired\n if len(self.__selectedNode) > 0:\n neighbors = self.__getNodeNeighbors(\n ... | [
"0.7347221",
"0.72265273",
"0.6770909",
"0.6640591",
"0.6497157",
"0.6453949",
"0.6340126",
"0.6323083",
"0.6307565",
"0.6283496",
"0.6217395",
"0.61632633",
"0.5969663",
"0.5943614",
"0.58987015",
"0.5830058",
"0.57968384",
"0.5749483",
"0.57455474",
"0.5722768",
"0.57088614... | 0.7882797 | 0 |
Add an ellipse node at the beginning of the method to mark its signature. | def add_title_node(self):
entry_nodes = self.get_entry_nodes()
if len(entry_nodes) > 1:
print("Warning: more than one entry node in this function")
self.graph.add_node(
self.signature, label = self.signature, shape = "ellipse",
soot_sig = self.soot_signature
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addEllipse(self, *__args): # real signature unknown; restored from __doc__ with multiple overloads\r\n pass",
"def ellipse(self, arg, fill='', outline=''):\n pass",
"def menu_insert_signature(self, event=None):\n if self.app.children:\n self.app.childActive.insert_signature(... | [
"0.6376878",
"0.57170963",
"0.5539549",
"0.5413758",
"0.5402646",
"0.53036994",
"0.52054834",
"0.51703304",
"0.51640564",
"0.5088683",
"0.50771916",
"0.5071829",
"0.5057118",
"0.503809",
"0.5013284",
"0.49871755",
"0.498681",
"0.4939894",
"0.49092045",
"0.48714626",
"0.483982... | 0.6093351 | 1 |
Get entry point nodes of the method (nodes without preds). | def get_entry_nodes(self):
top_nodes = []
for node in self.graph.nodes_iter():
if len(self.graph.predecessors(node)) == 0:
top_nodes.append(node)
return top_nodes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entry_nodes(self):\n return list(itertools.chain(*[arg.entry_nodes() for arg in self.args]))",
"def get_nodes(self):\n pass",
"def input_nodes(self):\n pass",
"def get_leaf_nodes(self):\n pass",
"def nodes(self): \n return [n for n in self.iternodes()]",
"def get_no... | [
"0.70175755",
"0.63566136",
"0.5968983",
"0.588462",
"0.5879318",
"0.5828153",
"0.57566226",
"0.5651104",
"0.55717236",
"0.5532742",
"0.5516347",
"0.55040836",
"0.55021334",
"0.5488619",
"0.5460288",
"0.54351",
"0.5424688",
"0.54184633",
"0.5410312",
"0.54096663",
"0.5407654"... | 0.6683985 | 1 |
Removes useless attributes left by Soot, like method labels. | def strip_useless_attributes(self):
graph_dict = self.graph.graph
if "node" in graph_dict and "label" in graph_dict["node"]:
graph_dict["node"].pop("label")
if "graph" in graph_dict:
graph_dict.pop("graph") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_attrs(self):\n self._attributes.clear()",
"def clear_attributes(self):\n self.attrs = etad.AttributeContainer()",
"def remove_keypoints_without_attrs(self, labels=None):\n filter_func = lambda keypoints: (\n (labels is not None and keypoints.label not in labels)\n ... | [
"0.682994",
"0.6528376",
"0.6433179",
"0.6423559",
"0.6386755",
"0.63230705",
"0.6288263",
"0.6193963",
"0.6177282",
"0.61718583",
"0.61718583",
"0.61643875",
"0.6127276",
"0.6082791",
"0.6073648",
"0.60697997",
"0.60180247",
"0.6010827",
"0.5982658",
"0.5942865",
"0.59170675... | 0.7530843 | 0 |
Apply GridPerslayWeight on a ragged tensor containing a list of persistence diagrams. | def call(self, diagrams):
grid_shape = self.grid.shape
indices = []
for dim in range(2):
[m,M] = self.grid_bnds[dim]
coords = tf.expand_dims(diagrams[:,:,dim],-1)
ids = grid_shape[dim]*(coords-m)/(M-m)
indices.append(tf.cast(ids, tf.int32))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_to_ragged(self, fn_name, fn_args, proto_list_key):\n self.run_benchmarks(fn_name, _get_prensor_to_ragged_tensor_fn, fn_args,\n proto_list_key)",
"def partial_pgs(dset: admix.Dataset, weight: np.ndarray):\n pass",
"def plotPersistenceDiagrams(dgm, **args):\n plot_diagram... | [
"0.505187",
"0.48486757",
"0.47904837",
"0.4789927",
"0.47169203",
"0.46511763",
"0.46181843",
"0.4612593",
"0.45639455",
"0.45487714",
"0.44996962",
"0.44986326",
"0.44867375",
"0.447961",
"0.4447541",
"0.44423646",
"0.44144452",
"0.44126138",
"0.44116172",
"0.44031096",
"0.... | 0.5493659 | 0 |
Apply PowerPerslayWeight on a ragged tensor containing a list of persistence diagrams. | def call(self, diagrams):
weight = self.constant * tf.math.pow(tf.math.abs(diagrams[:,:,1]-diagrams[:,:,0]), self.power)
return weight | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partial_pgs(dset: admix.Dataset, weight: np.ndarray):\n pass",
"def _degree_weight_weighted_matrices(self):\n for meta_edge, matrix in self.degree_weighted_matrices.items():\n self.degree_weighted_matrices[meta_edge] = matrix.multiply(self.weighted_adj_matrices[meta_edge])",
"def call(... | [
"0.51915765",
"0.5081694",
"0.5081576",
"0.50502217",
"0.48959988",
"0.48916382",
"0.4885628",
"0.4815553",
"0.48029017",
"0.47831574",
"0.47807053",
"0.4734466",
"0.47337383",
"0.47120807",
"0.4710764",
"0.4703239",
"0.46627197",
"0.46608517",
"0.46498558",
"0.4630649",
"0.4... | 0.5164082 | 1 |
initializing the retry count here | def __init__(self, retry_count):
self.retry_count = retry_count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, tries , exceptions=None, delay=0.01):\n self.tries = tries\n if exceptions is None:\n exceptions = Retry.default_exceptions\n self.exceptions = exceptions\n self.delay = delay",
"def _retry_occurred(self):",
"def __init__(self, tries, exceptions=None, ... | [
"0.73189306",
"0.72174746",
"0.70765644",
"0.69890004",
"0.69024",
"0.68728626",
"0.67899954",
"0.66362894",
"0.6589694",
"0.6540665",
"0.6505897",
"0.64784217",
"0.64057523",
"0.6338347",
"0.63177377",
"0.62741697",
"0.6261156",
"0.6214623",
"0.62011576",
"0.6127322",
"0.612... | 0.8368044 | 0 |
pull csv from path, using usecols, and then agg and sum using groupvar | def pull_data_aian(path, usecols, groupvar):
df = pd.read_csv(path, usecols = usecols)
df = df.groupby(groupvar).sum()
df = df.rename(columns=rename).reset_index()
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readCsv(variables, path, pathCsv, estacion):\n # os.makedirs('../data/totalData/')\n dataVa = df.DataFrame()\n variables = variables\n mypath = path\n patron = re.compile(variables + '_'+estacion+'_\\d\\d\\d\\d-\\d\\d-\\d\\d' + '.*')\n for base, dirs, filess in os.walk(mypath, topdown=False):... | [
"0.5905242",
"0.58667",
"0.55509806",
"0.5491086",
"0.53890735",
"0.538757",
"0.5260202",
"0.52415395",
"0.5187955",
"0.51510906",
"0.51304495",
"0.5112891",
"0.5110076",
"0.5104731",
"0.5070958",
"0.5068241",
"0.5062005",
"0.5049123",
"0.5018155",
"0.49976525",
"0.4997394",
... | 0.79186803 | 0 |
assuming the formatting of the jun20 DAS state files, add location cols | def add_loc_cols(df):
df['STATE'] = [int(i[1:3]) for i in df.gisjoin]
df['COUNTY'] = [int(i[4:7]) for i in df.gisjoin]
df['TRACT'] = [int(i[7:-4]) for i in df.gisjoin]
df['BLOCK'] = [int(i[-4:]) for i in df.gisjoin]
if df.STATE[0] > 9:
raise Exception("Warning! Code might be incorrect for states with f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_locations(db, openfile):\n pass",
"def add_loc(self):\n self.loc = 0\n for t in self.thys:\n with open(t, 'r') as f:\n for l in f:\n if l.strip():\n self.loc += 1",
"def read_states():\n loc_file = open(loc_file_pa... | [
"0.56568325",
"0.5588643",
"0.54796445",
"0.5389587",
"0.53848195",
"0.52786493",
"0.522803",
"0.52103066",
"0.51612204",
"0.515263",
"0.5148807",
"0.51473916",
"0.5134453",
"0.5119848",
"0.51158273",
"0.50954694",
"0.50944453",
"0.5077211",
"0.5021172",
"0.5020878",
"0.50044... | 0.59444934 | 0 |
A LazySubprocessTester that should fail. | def unavailable_process(**kwargs):
return LazySubprocessTester([sys.executable, "-c", "import sys; sys.exit(1)"], **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_subprocess_fails_with_no_command(self):\n with self.assertRaises(ValueError):\n LazySubprocessTester([])",
"def available_process(**kwargs):\n return LazySubprocessTester([sys.executable, \"-c\", \"import sys; sys.exit(0)\"], **kwargs)",
"def test_subprocess_fork_exception(self, m... | [
"0.81897885",
"0.7049909",
"0.66409194",
"0.656849",
"0.65147746",
"0.64995",
"0.64676017",
"0.6426523",
"0.6330409",
"0.62290996",
"0.62018615",
"0.6169046",
"0.61415625",
"0.6112118",
"0.6088542",
"0.60872054",
"0.60719585",
"0.60344416",
"0.6027196",
"0.60046923",
"0.60018... | 0.77774405 | 1 |
Context manager that mocks out the availability checker for a given dependency checker. The context manager returns the mockedout method. | def mock_availability_test(feature):
# We have to be careful with what we patch because the dependency managers define `__slots__`.
return mock.patch.object(type(feature), "_is_available", wraps=feature._is_available) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_mock_deck_conflict_check(\n decoy: Decoy, monkeypatch: pytest.MonkeyPatch\n) -> None:\n mock = decoy.mock(func=deck_conflict.check)\n monkeypatch.setattr(deck_conflict, \"check\", mock)",
"def oracle_arg_check(f):\n\n @functools.wraps(f)\n def wrapper(*args, **kwargs):\n getattr(a... | [
"0.57697463",
"0.5705675",
"0.5671225",
"0.5539538",
"0.55045426",
"0.5496847",
"0.5460075",
"0.54113513",
"0.53586954",
"0.53228885",
"0.53220475",
"0.532072",
"0.5277392",
"0.5257894",
"0.524676",
"0.5205289",
"0.5193228",
"0.5190968",
"0.5179606",
"0.51784945",
"0.5154114"... | 0.6323173 | 0 |
Check that the test of availability is only performed once. | def test_check_occurs_once(self, test_generator):
feature = test_generator()
with mock_availability_test(feature) as check:
check.assert_not_called()
if feature:
pass
check.assert_called_once()
if feature:
feature.require_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_availability(self):\n pass",
"def test_require_now_silently_succeeds_for_available_tests(self, test_generator):\n feature = test_generator()\n with mock_availability_test(feature) as check:\n check.assert_not_called()\n feature.require_now(\"no message\")\n ... | [
"0.7795118",
"0.6864407",
"0.6784055",
"0.65891606",
"0.6469235",
"0.6449086",
"0.6449086",
"0.6449086",
"0.6438792",
"0.6410927",
"0.6399462",
"0.6399462",
"0.6397757",
"0.6371293",
"0.63617784",
"0.63544583",
"0.63277864",
"0.63277864",
"0.63277864",
"0.63141257",
"0.631412... | 0.716146 | 1 |
Check that the callback is only called once. | def test_callback_occurs_once(self, test_generator):
callback = mock.MagicMock()
feature = test_generator(callback=callback)
callback.assert_not_called()
if feature:
pass
callback.assert_called_once_with(bool(feature))
callback.reset_mock()
if featu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def only_once(self) -> bool:\n return self.times == 1",
"def run_once(func):\n @wraps(func)\n def wrapper(*args, **kwargs):\n if not wrapper.has_run:\n result = func(*args, **kwargs)\n wrapper.has_run = True\n return result\n wrapper.has_run = False\n re... | [
"0.71477145",
"0.68855697",
"0.67632407",
"0.66056764",
"0.6440047",
"0.6399433",
"0.63867986",
"0.6381417",
"0.6380541",
"0.63763493",
"0.63403547",
"0.63035417",
"0.6235816",
"0.61101186",
"0.5984442",
"0.59627795",
"0.5937139",
"0.58908",
"0.5887816",
"0.5780287",
"0.57674... | 0.69543207 | 1 |
Test that the unavailable loaders loudly raise when the inner functions of decorators are called, and not before, and raise each time they are called. | def test_require_in_call_raises_for_unavailable_tests(self, test_generator):
# pylint: disable=function-redefined
with self.subTest("direct decorator"):
feature = test_generator()
with mock_availability_test(feature) as check:
check.assert_not_called()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_require_in_call_silently_succeeds_for_available_tests(self, test_generator):\n # pylint: disable=function-redefined\n\n with self.subTest(\"direct decorator\"):\n feature = test_generator()\n with mock_availability_test(feature) as check:\n check.assert_n... | [
"0.68638283",
"0.677899",
"0.65100783",
"0.6507785",
"0.64681846",
"0.64506567",
"0.6430449",
"0.6315167",
"0.62650514",
"0.6247918",
"0.6168915",
"0.6146314",
"0.6110981",
"0.6076096",
"0.6054128",
"0.5999914",
"0.59785134",
"0.5953366",
"0.58886665",
"0.5858137",
"0.5838372... | 0.7146015 | 0 |
Test that the unavailable loaders loudly raise when the inner classes of decorators are instantiated, and not before, and raise each time they are instantiated. | def test_require_in_instance_raises_for_unavailable_tests(self, test_generator):
# pylint: disable=function-redefined
with self.subTest("direct decorator"):
feature = test_generator()
with mock_availability_test(feature) as check:
check.assert_not_called()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_already_registered_002(self):\n\n class MyChecker(object):\n \"\"\"Do nothing.\"\"\"\n\n @staticmethod\n def get_long_code():\n \"\"\"Do nothing.\"\"\"\n return \"something\"\n\n @staticmethod\n def get_order():\n ... | [
"0.6465746",
"0.64068234",
"0.6365496",
"0.63547",
"0.6344793",
"0.6173017",
"0.6165048",
"0.6051807",
"0.6045441",
"0.5863995",
"0.5859404",
"0.5825915",
"0.58078605",
"0.57873416",
"0.5773508",
"0.57651246",
"0.5737789",
"0.5736117",
"0.57187396",
"0.5692837",
"0.56659615",... | 0.6785023 | 0 |
Check that the import tester can accept a dictionary mapping module names to attributes, and that these can be fetched. | def test_import_allows_attributes_successful(self):
name_map = {
"_qiskit_dummy_module_1_": ("attr1", "attr2"),
"_qiskit_dummy_module_2_": ("thing1", "thing2"),
}
mock_modules = {}
for module, attributes in name_map.items():
# We could go through the r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_import_allows_attributes_failure(self):\n # We can just use existing modules for this.\n name_map = {\n \"sys\": (\"executable\", \"path\"),\n \"builtins\": (\"list\", \"_qiskit_dummy_attribute_\"),\n }\n\n feature = LazyImportTester(name_map)\n sel... | [
"0.75701183",
"0.73270047",
"0.6760515",
"0.61833155",
"0.61603504",
"0.60724396",
"0.6072408",
"0.59776163",
"0.59364825",
"0.5916044",
"0.58996856",
"0.58946186",
"0.5882135",
"0.5880821",
"0.58579254",
"0.5850249",
"0.58356637",
"0.5807026",
"0.58056045",
"0.57850796",
"0.... | 0.7483799 | 1 |
Check that the import tester can accept a dictionary mapping module names to attributes, and that these are recognised when they are missing. | def test_import_allows_attributes_failure(self):
# We can just use existing modules for this.
name_map = {
"sys": ("executable", "path"),
"builtins": ("list", "_qiskit_dummy_attribute_"),
}
feature = LazyImportTester(name_map)
self.assertFalse(feature) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_attributes_exist(name, module_dict, attributes):\n for attribute in attributes:\n assert attribute in module_dict, \\\n f'{name} should define {attribute} in its __init__.py file.'",
"def test_import_allows_attributes_successful(self):\n name_map = {\n \"_qiskit_dumm... | [
"0.78747565",
"0.7399658",
"0.68359023",
"0.6587806",
"0.63916945",
"0.6318818",
"0.6311557",
"0.62650967",
"0.6217278",
"0.6209309",
"0.6164557",
"0.6145943",
"0.61441445",
"0.61428034",
"0.61202455",
"0.610316",
"0.60629624",
"0.60271865",
"0.60212964",
"0.59012246",
"0.589... | 0.78137124 | 1 |
converting documents to list | def docs_to_list(documents):
texts = []
for doc in documents:
texts.append(doc.split())
print (("The collection of documents contains {} documents").format(len(texts)))
return texts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, docs):\n return [doc for doc in docs]",
"def documents(self, **kw):\r\n \r\n doc_reader = self.doc_reader\r\n return (doc_reader[docnum] for docnum in self.document_numbers(**kw))",
"def transform(docs: Any) -> Any:\n return docs",
"def docs2ids(self):\n... | [
"0.7976173",
"0.69036657",
"0.6810291",
"0.67735416",
"0.66775036",
"0.6672783",
"0.6579844",
"0.65202856",
"0.65082407",
"0.6466133",
"0.63944095",
"0.6388551",
"0.6368003",
"0.63643974",
"0.63604033",
"0.6339122",
"0.6309226",
"0.6297858",
"0.62804544",
"0.6238001",
"0.6235... | 0.80017704 | 0 |
We ask user how long password he needs and check his input. | def ask_user():
password_lenght = 0
while password_lenght == 0:
try:
password_lenght = int(input("How long password you want? Enter the number... "))
if password_lenght <= 0:
print("Try to enter any number greater than 0...")
continue
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pwd_len():\r\n while True:\r\n password_length = input('How much length for password u want ? Minimum length is 6 and Maximum length is 25 : ')\r\n try:\r\n password_length = int(password_length)\r\n if 6 <= password_length <= 25:\r\n break\r\n e... | [
"0.78011656",
"0.7701192",
"0.7518886",
"0.74387705",
"0.7334134",
"0.73269546",
"0.7250354",
"0.7241142",
"0.72395444",
"0.71388704",
"0.7047825",
"0.700292",
"0.6970965",
"0.6967958",
"0.6955232",
"0.69144017",
"0.6911781",
"0.6842157",
"0.6795088",
"0.67729855",
"0.6754664... | 0.7884896 | 0 |
Checking input data and generating password of a given length. | def password_generator(password_lenght):
password = ""
try:
if password_lenght >=1:
for i in range(password_lenght):
choice = random.choice(symbols)
password += str(choice)
print(f"Your password is: {password} \nTnank you!")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_password(self): \n\n password = []\n length = input(\"Enter Length for Password (At least 8): \")\n\n if length.lower().strip() == \"exit\":\n raise UserExits\n elif length.strip() == \"\":\n raise EmptyField\n elif int(length) < 8:\n ... | [
"0.80016834",
"0.7713718",
"0.7691842",
"0.7674546",
"0.7602808",
"0.745968",
"0.7434886",
"0.74265397",
"0.73645675",
"0.73578537",
"0.7306634",
"0.7245226",
"0.72258425",
"0.722136",
"0.7210786",
"0.7204004",
"0.7192589",
"0.7185284",
"0.7154753",
"0.7152572",
"0.71438473",... | 0.77723056 | 1 |
Compose payload for Google geocoding request from latitude and longitude | def build_google_payload(latitude, longitude):
coordinates = latitude + ',' + longitude
payload = 'latlng=' + coordinates + "&language=es&client=" + GOOGLE_INFO['client'] + "&signature=" + GOOGLE_INFO['signature'] + "=&result_type=route"
return payload | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callGoogle(endpoint: str, params: dict) -> str:\n # hit API \n call = requests.get(endpoint, params=params)\n response = call.json()\n # grab first element in payload\n result: dict = response['results'][0]\n # format lat and lng to a string\n return f\"{result['geometry']['location']['lat... | [
"0.6447365",
"0.6406557",
"0.6257828",
"0.621978",
"0.6204813",
"0.6189891",
"0.6175926",
"0.6107424",
"0.60988945",
"0.6098107",
"0.60907376",
"0.6089002",
"0.5994251",
"0.5987267",
"0.59621227",
"0.5960496",
"0.59355795",
"0.5933392",
"0.5931399",
"0.59278697",
"0.5910453",... | 0.70541334 | 0 |
Compose payload for OSM geocoding request from latitude and longitude | def build_osm_payload(latitude, longitude):
payload = 'format=json&lat=' + latitude + '&lon=' + longitude + '&accept-language=es'
return payload | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_google_payload(latitude, longitude):\n coordinates = latitude + ',' + longitude\n payload = 'latlng=' + coordinates + \"&language=es&client=\" + GOOGLE_INFO['client'] + \"&signature=\" + GOOGLE_INFO['signature'] + \"=&result_type=route\"\n return payload",
"def form_params(self, lat, long):\n ... | [
"0.6464599",
"0.61917835",
"0.61780226",
"0.61156327",
"0.6072951",
"0.6040112",
"0.60156626",
"0.5973554",
"0.5948596",
"0.59034824",
"0.58640164",
"0.5820398",
"0.58157146",
"0.5761792",
"0.5710865",
"0.57058537",
"0.5698448",
"0.56795824",
"0.56614774",
"0.5659217",
"0.565... | 0.6856607 | 0 |
Extract util information (formatted_adddress) from Google geocoding response | def extract_data_from_google_response(geocoding_response):
root = ET.fromstring(geocoding_response)
for result in root.findall('result'):
data = result.find('formatted_address').text
if data != '':
return data
return 'Dirección desconocida' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_address_from_geocoding_response(geocoded_data: dict) -> str:\n return geocoded_data[\n 'response'][\n 'GeoObjectCollection'][\n 'featureMember'][0][\n 'GeoObject'][\n 'metaDataProperty'][\n 'GeocoderMetaData'][\n 'text']",
"def extract_data_from_nomin... | [
"0.70694596",
"0.67716753",
"0.6285671",
"0.6223366",
"0.61500823",
"0.6134836",
"0.60808057",
"0.59937346",
"0.5985139",
"0.59832895",
"0.5956585",
"0.5953152",
"0.588964",
"0.5876703",
"0.5864284",
"0.58485466",
"0.5839031",
"0.5825973",
"0.5824628",
"0.58133346",
"0.579503... | 0.7759524 | 0 |
Extract util information (formatted_adddress) from local Nominatim geocoding response | def extract_data_from_nominatim_response(geocoding_response):
root = ET.fromstring(geocoding_response)
for result in root.findall('result'):
data = result.find('formatted_address').text
if data != '':
return data
return 'Dirección desconocida' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_data_from_google_response(geocoding_response):\n root = ET.fromstring(geocoding_response)\n for result in root.findall('result'):\n data = result.find('formatted_address').text\n if data != '':\n return data\n return 'Dirección desconocida'",
"def parse_address_from_... | [
"0.6931076",
"0.67190886",
"0.6314702",
"0.62550384",
"0.61754876",
"0.60639644",
"0.60078025",
"0.59952563",
"0.59799385",
"0.59776604",
"0.5943858",
"0.59027654",
"0.5872913",
"0.58593607",
"0.58556724",
"0.5818427",
"0.5791358",
"0.5786825",
"0.57858485",
"0.5755049",
"0.5... | 0.743232 | 0 |
Get coordinates for tracking_id or event_id previously saved at MongoDB | def get_coordinates_from_id(tracking_id=None, event_id=None):
if tracking_id:
json_document = mongo.read_single_document(collection='TRACKING', filter={'_id':ObjectId(tracking_id)}, projection={'coordinates':True})
if not json_document:
json_document = mongo.read_single_document(collecti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_coords(data, id):\n return data[id]['lat'], data[id]['lon']",
"def get_coordinates(self):\n try:\n return self.__data['coordinates']['Guest Entrance']['gps']\n except:\n return None",
"def xy(event):\n return map(int, event.get_coords())",
"def get_coordinate... | [
"0.6570077",
"0.63433224",
"0.6250737",
"0.6032235",
"0.60078716",
"0.5985618",
"0.5917232",
"0.59076875",
"0.58935493",
"0.58243924",
"0.58243924",
"0.58240753",
"0.5796023",
"0.5786515",
"0.5761357",
"0.57470393",
"0.5737933",
"0.5736779",
"0.5724162",
"0.5720989",
"0.57077... | 0.8374382 | 0 |
Set geocoding for one tracking_id or/and event_id already saved at mongo | def sync_set_geocoding(provider, tracking_id, event_id):
coordinates = get_coordinates_from_id(tracking_id=tracking_id, event_id=event_id)
geocoding = None
if coordinates:
if not provider or provider == 'osm':
geocoding = get_osm_geocoding(coordinates)
if geocoding == None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def async_set_geocoding(provider, tracking_id=None, event_id=None):\n loop = asyncio.get_event_loop()\n loop.run_in",
"def upsert_location(self, location):",
"def save_venue(data, form):\n venue = form.save()\n\n venue.city = City.objects.get(id=int(data.get('city_identifier')))\n venue.country ... | [
"0.66236216",
"0.5750594",
"0.5534621",
"0.5486185",
"0.5475903",
"0.53973037",
"0.5376866",
"0.53746176",
"0.52781785",
"0.5267941",
"0.5249574",
"0.51544803",
"0.510455",
"0.5049198",
"0.50303984",
"0.5018541",
"0.50038713",
"0.49658647",
"0.4945134",
"0.49349305",
"0.48921... | 0.7847302 | 0 |
Async set geocoding for one tracking_id or/and event_id already saved at mongo | def async_set_geocoding(provider, tracking_id=None, event_id=None):
loop = asyncio.get_event_loop()
loop.run_in | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_set_geocoding(provider, tracking_id, event_id):\n coordinates = get_coordinates_from_id(tracking_id=tracking_id, event_id=event_id)\n geocoding = None\n if coordinates:\n if not provider or provider == 'osm':\n geocoding = get_osm_geocoding(coordinates)\n if geocoding... | [
"0.7760547",
"0.56120753",
"0.5221786",
"0.51678723",
"0.5166794",
"0.514101",
"0.5064939",
"0.49932906",
"0.4989875",
"0.49574724",
"0.4922727",
"0.48368183",
"0.4823165",
"0.48044357",
"0.4797293",
"0.476319",
"0.47610584",
"0.47597513",
"0.4741748",
"0.47209474",
"0.471701... | 0.74001074 | 1 |
Creates a feature stack from a given image. | def generate_feature_stack(image, features_specification : Union[str, PredefinedFeatureSet] = None):
image = cle.push(image)
# default features
if features_specification is None:
blurred = cle.gaussian_blur(image, sigma_x=2, sigma_y=2, sigma_z=2)
edges = cle.sobel(blurred)
stack = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_to_features(image):\n image = tf.keras.preprocessing.image.img_to_array(image)\n image = tf.keras.applications.mobilenet_v2.preprocess_input(image)\n image = np.expand_dims(image, axis=0)\n return image",
"def pixels_as_features(image, include_gabors=True):\n\n # roll axes to conventiona... | [
"0.6325164",
"0.6312676",
"0.6032002",
"0.6029791",
"0.6005733",
"0.6005733",
"0.58654207",
"0.58627045",
"0.5756856",
"0.57195675",
"0.5634049",
"0.56235486",
"0.56056416",
"0.55969757",
"0.559281",
"0.5586191",
"0.5547223",
"0.5543596",
"0.55217874",
"0.54858446",
"0.548562... | 0.7015756 | 0 |
Runs a function (successfully) only once. The running can be reset by setting the `has_run` attribute to False | def run_once(f):
@wraps(f)
def wrapper(*args, **kwargs):
if not wrapper.has_run:
result = f(*args, **kwargs)
wrapper.has_run = True
wrapper.result = result
return wrapper.result
wrapper.has_run = False
return wrapper | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_once(func):\n @wraps(func)\n def wrapper(*args, **kwargs):\n if not wrapper.has_run:\n result = func(*args, **kwargs)\n wrapper.has_run = True\n return result\n wrapper.has_run = False\n return wrapper",
"def checkrun(f):\n @functools.wraps(f)\n d... | [
"0.7920173",
"0.69057214",
"0.6666434",
"0.6500568",
"0.63373107",
"0.6152881",
"0.61234456",
"0.6073642",
"0.6047268",
"0.60086095",
"0.5982803",
"0.5916775",
"0.5853793",
"0.5757612",
"0.5724721",
"0.5718261",
"0.57124907",
"0.56969935",
"0.5689758",
"0.56775665",
"0.566766... | 0.7748125 | 1 |
Retrieves the given name from the symbolserver and places it in cache. Will fetch and extract compressed pdb versions if possible. Returns true if pdb was successfully retrieved and cached. | def retrievePdbFrom(name, guid, symbolserver):
# Try fetching compressed version
debug("Trying to fetch '%s' with GUID %s from '%s'", name, guid, symbolserver)
# What we currently have cached is outdated or non-existent, delete it
# so we don't clutter up the cache with stuff we'll never use a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrievePdb(name, guid):\r\n symbolservers = ['http://symbols.hacst.net/', 'http://mumble.info:8080/symbols/']\r\n \r\n for symbolserver in symbolservers:\r\n if retrievePdbFrom(name, guid, symbolserver):\r\n return True\r\n \r\n return False",
"def fetchPDB(name, path):\n ... | [
"0.6679852",
"0.60567683",
"0.59865505",
"0.5752231",
"0.5666071",
"0.5628215",
"0.5527856",
"0.5427909",
"0.5331094",
"0.53095376",
"0.5210802",
"0.5166333",
"0.5139973",
"0.5139737",
"0.51055",
"0.5084384",
"0.5046003",
"0.5025815",
"0.50115114",
"0.5008575",
"0.4991038",
... | 0.7803611 | 0 |
Attempts to retrieve the pdb from the known symbol servers. Returns true if the pdb was retrieved and is now in cache. | def retrievePdb(name, guid):
symbolservers = ['http://symbols.hacst.net/', 'http://mumble.info:8080/symbols/']
for symbolserver in symbolservers:
if retrievePdbFrom(name, guid, symbolserver):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrievePdbFrom(name, guid, symbolserver):\r\n # Try fetching compressed version\r\n debug(\"Trying to fetch '%s' with GUID %s from '%s'\", name, guid, symbolserver)\r\n \r\n # What we currently have cached is outdated or non-existent, delete it\r\n # so we don't clutter up the cache with stuff ... | [
"0.68411195",
"0.57176393",
"0.5578138",
"0.54507273",
"0.5332055",
"0.5306528",
"0.5280283",
"0.52030516",
"0.5144779",
"0.5070842",
"0.50417817",
"0.5030114",
"0.5029871",
"0.5012987",
"0.5004504",
"0.49996874",
"0.49991912",
"0.49862617",
"0.4954232",
"0.49337286",
"0.4905... | 0.74177545 | 0 |
Assembles the GUID used by symstore for symbolserver paths from the debug information in a plugins PE header and returns it. If no GUID can be extracted, the function returns None. | def getSymbolserverPdbGUID(filename):
path = cachePath(filename)
pe = pefile.PE(path)
# Find the CodeView entry in the PE file's debug directory.
header = None
for entry in getattr(pe, 'DIRECTORY_ENTRY_DEBUG', []):
dbgtype = entry.struct.Type
if pefile.DEBUG_TYPE.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug_guid(pe):\n if hasattr(pe, 'DIRECTORY_ENTRY_DEBUG'):\n for i in pe.DIRECTORY_ENTRY_DEBUG:\n if hasattr(i.entry, 'Signature_Data1'):\n return '{:08x}-{:04x}-{:-4x}-{}-{}{}'.format(\n i.entry.Signature_Data1,\n i.entry.Signature_Data... | [
"0.6834958",
"0.5616028",
"0.5451041",
"0.53552204",
"0.5327762",
"0.5267996",
"0.52642053",
"0.5237691",
"0.5231313",
"0.5221197",
"0.5219013",
"0.5204735",
"0.51650316",
"0.50862736",
"0.50184596",
"0.5008249",
"0.49988708",
"0.49924412",
"0.49825355",
"0.49651527",
"0.4950... | 0.67776614 | 1 |
Returns true if the given file is in cache and its hash matches the given one. | def isCached(filename, hash):
path = cachePath(filename)
if not os.path.exists(path):
return False
return hash == hashlib.sha1(open(path, 'rb').read()).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_if_file_exist_in_cache(self, file_path: Path) -> bool:\n file_md5_hash = FileUtils.get_file_md5_hash(file_path)\n if file_md5_hash in self.storage:\n self.update_usage_queue(file_md5_hash)\n return True\n return False",
"def check_md5checksum_in_cache_modified... | [
"0.7536288",
"0.73871",
"0.7067731",
"0.7058744",
"0.6941732",
"0.68807703",
"0.6817819",
"0.67803156",
"0.673369",
"0.6667041",
"0.6665917",
"0.6643461",
"0.6643253",
"0.65988046",
"0.6581203",
"0.6550915",
"0.64525205",
"0.64469206",
"0.639484",
"0.63493615",
"0.62931937",
... | 0.8617202 | 0 |
Downloads the given file from the public plugin server into the replacement cache. By default, this fetches the plugin from the Mumble | def cachePlugin(filename, fullpath=None):
path = cachePath(filename)
url = 'http://mumble.info:8080'
if fullpath is not None:
url += fullpath
else:
url += '/plugins/' + filename
res = requests.get(url)
if not res.ok:
raise Exception("Failed to fetch '%s'"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(self):\n file_url = posixpath.join(self.mirrors, self.resources)\n _urlretrieve(file_url, os.path.join(self.root, self.resources))",
"def download(self):\n file_url = posixpath.join(self.mirrors, self.resources)\n _urlretrieve(file_url, os.path.join(self.root, self.resour... | [
"0.6448135",
"0.6448135",
"0.6339576",
"0.6288373",
"0.6199233",
"0.60792047",
"0.60592866",
"0.60477453",
"0.604342",
"0.6030676",
"0.6006968",
"0.5988602",
"0.5972",
"0.59593344",
"0.5933221",
"0.5906073",
"0.59029144",
"0.59007585",
"0.58860075",
"0.58842313",
"0.5823192",... | 0.78268266 | 0 |
Makes sure the local cache contains all old plugin versions and collects their creation dates. The return value is a tuple consisting of the oldest creation datetime of all plugins and a dict of dll name to creation date mappings. | def collectPluginCreationDates(limitTo = None):
creation_dates = {}
oldest = None
info("Collecting plugin creation dates")
plugins = getPluginList(ver = args.version, os = args.os, abi = args.abi)
for plugin in plugins.findall('plugin'):
name = plugin.attrib['name']
hash... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determineUnchangedPlugins(oldest, creation_dates):\r\n info(\"Checking repo for new revisions\")\r\n \r\n old_plugins_to_use = creation_dates.copy()\r\n repo = git.Repo(args.repo)\r\n \r\n pluginmatch = re.compile(r'^plugins/(\\w+)/')\r\n \r\n for commit in repo.iter_commits(rev = args.... | [
"0.615663",
"0.5829495",
"0.56156164",
"0.5502401",
"0.5188302",
"0.516052",
"0.5158175",
"0.515296",
"0.51520973",
"0.5131585",
"0.5046755",
"0.5015455",
"0.49984476",
"0.4992277",
"0.49708667",
"0.49678186",
"0.49544036",
"0.49504858",
"0.4936771",
"0.4907399",
"0.4891792",... | 0.7314594 | 0 |
Checks the repository history for changes to the plugins cpp/pro file. If such changes are found and they are newer than the creation date of the plugin it is assumed the plugin needs to be updated. | def determineUnchangedPlugins(oldest, creation_dates):
info("Checking repo for new revisions")
old_plugins_to_use = creation_dates.copy()
repo = git.Repo(args.repo)
pluginmatch = re.compile(r'^plugins/(\w+)/')
for commit in repo.iter_commits(rev = args.rev, paths = 'plugins/')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_from_repo():\n\treturn",
"def _check_nothing_changed(self):\n if self.data['history_file'] is None:\n return\n nothing_yet = self.data['nothing_changed_yet']\n if nothing_yet not in self.data['history_last_release']:\n return\n # We want quotes around ... | [
"0.57368994",
"0.569129",
"0.56642866",
"0.5599712",
"0.5579627",
"0.5578169",
"0.55494976",
"0.5535771",
"0.5470089",
"0.54659414",
"0.54253894",
"0.5369983",
"0.53427875",
"0.5332052",
"0.53282195",
"0.53015476",
"0.5283704",
"0.5274186",
"0.5269086",
"0.5252387",
"0.524810... | 0.6759886 | 0 |
saves file in given directory in fiven format | def quicksavefile(directory, text, format=".out"):
print(text)
print(directory)
directory = directory.split(".")
del directory[-1]
directory.append(format)
s = "".join(directory)
file = open(s, "w")
file.write(text)
file.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, directory):\n pass # pragma: no cover",
"def save(self, dir):\n raise NotImplementedError",
"def _save_file(self, file_path, data):\n self._ensure_directory(os.path.dirname(file_path))\n with open(file_path, \"wb\") as f:\n f.write(data)",
"def save_uplo... | [
"0.69542944",
"0.6784516",
"0.6586304",
"0.646907",
"0.646907",
"0.64646924",
"0.646173",
"0.64489424",
"0.6413549",
"0.63707703",
"0.636943",
"0.6366998",
"0.6251524",
"0.62431943",
"0.6199475",
"0.61856925",
"0.6183431",
"0.61738455",
"0.6154798",
"0.6105204",
"0.61039716",... | 0.68918204 | 1 |
cuts tworow data into two seperate lists. Items are formatted as float | def cut_data(data):
out = [[], []]
data = data.split("\n")
for line in data:
line = line.split(" ")
line = remove_empty(line)
try:
out[0].append(float(line[0]))
out[1].append(float(line[1]))
except IndexError:
pass
file = open("test.txt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list_of_float2(self):\n pass",
"def clean_serial_data(data):\n clean_data = []\n line_data = []\n for line in data:\n print (line)\n #line = float(line)\n clean_data.append(int(line)/1000)\n \n return clean_data",
"def simulation_to_lines(data: List(Float)... | [
"0.659513",
"0.60295427",
"0.5937581",
"0.5928624",
"0.59095967",
"0.59016985",
"0.58180386",
"0.57835084",
"0.57043594",
"0.5704249",
"0.5697503",
"0.5664789",
"0.56309205",
"0.5576093",
"0.5548484",
"0.5536851",
"0.5529387",
"0.5526897",
"0.5519976",
"0.5518893",
"0.5511307... | 0.6672706 | 0 |
deletes empty elements with "space" in it | def del_empty_space(list):
for x in range(len(list)):
if " " in list[x - 1]:
del list[x - 1]
return list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_empty(data):\n out = []\n for item in data:\n if item == '':\n continue\n out.append(item)\n return out",
"def remove_blanks_list(src):\n return [el for el in src if el]",
"def strip_if_not_blank(value):\n if any([i != \" \" for i in value]):\n return v... | [
"0.70740354",
"0.6441092",
"0.6411609",
"0.6411026",
"0.628614",
"0.6270218",
"0.62398255",
"0.61921996",
"0.6180169",
"0.6155809",
"0.6145795",
"0.6137858",
"0.61009425",
"0.6069739",
"0.6066169",
"0.60659784",
"0.60256416",
"0.60116667",
"0.5990295",
"0.598116",
"0.59619135... | 0.694287 | 1 |
clears "" and " " in list | def clear_list(list):
for x in range(len(list)):
try:
list.remove("")
except ValueError:
pass
try:
list.remove(" ")
except ValueError:
pass
return list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clean_list(self, items):\n itemlist = list(filter(None, items))\n if len(itemlist) < 3:\n itemlist.append(\"\")\n return itemlist\n\n return itemlist",
"def remove_empty_string(str_list):\n return list(filter(None, str_list))",
"def clear_empty_strings(data):\... | [
"0.6993336",
"0.67472637",
"0.6665588",
"0.6663852",
"0.66530573",
"0.66164494",
"0.65982485",
"0.65378207",
"0.64414823",
"0.64241225",
"0.6393234",
"0.6379192",
"0.6354317",
"0.63430786",
"0.63430786",
"0.6309216",
"0.62884927",
"0.6196393",
"0.61716294",
"0.6169924",
"0.61... | 0.7400066 | 0 |
returns list with elements without char | def get_without(list, char="#"):
s = []
for line in list:
if char not in line:
s.append(line)
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_zero_components(self) :\n return list(self.parent().characters())",
"def remove_blanks_list(src):\n return [el for el in src if el]",
"def lstrip(self, chars=None):\n return asarray(lstrip(self, chars))",
"def strip(self, chars=None):\n return asarray(strip(self, chars))",
"... | [
"0.69478565",
"0.69181645",
"0.6862767",
"0.67110676",
"0.66015553",
"0.64761025",
"0.6465458",
"0.6461413",
"0.6424209",
"0.6413514",
"0.6345536",
"0.6273772",
"0.6232838",
"0.6180916",
"0.61602795",
"0.61453044",
"0.61323065",
"0.61319363",
"0.6124642",
"0.6120454",
"0.6120... | 0.75567555 | 0 |
Create and execute a CHARMM script for the IPRO suite of programs. | def execute_CHARMM_script(script, procedure = None, gn = None):
# Validate that the script is a string so it can be written to a file
if not isinstance(script, str):
text = "The execute_CHARMM_script requires a string as the 'script' "
text += "input to function, not:\n" + str(script)
ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n BASIC.run(PROGRAM)",
"def prepare_script(i):\n\n # Check vars\n if 'script_name' not in i: return {'cm_return':1, 'cm_error':'\"script_name\" is not defined in \"code prepare_script\"'}\n if 'target_os_uoa' not in i: return {'cm_return':1, 'cm_error':'\"target_os_uoa\" is not defined ... | [
"0.6183805",
"0.56829286",
"0.5650018",
"0.5609884",
"0.5606346",
"0.5410789",
"0.5394434",
"0.5389589",
"0.5373508",
"0.5347438",
"0.5308051",
"0.52814484",
"0.5231853",
"0.5224419",
"0.5222657",
"0.52210754",
"0.5175102",
"0.5156244",
"0.5154821",
"0.514988",
"0.50863",
"... | 0.63499105 | 0 |
Make sure the specified procedure can be used in naming things. | def validate_procedure(procedure):
# If it is not a string, use "charmm"
if not isinstance(procedure, str):
return "charmm"
else:
# Split on white space and replace it with underscores
items = procedure.split()
procedure = ''
for i, item in enumerate(items):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDefineCreateProc(self):\n\t\tcur = con.cursor()\n\n\t\tnull = System.Data.SqlTypes.SqlInt32.Null\n\t\tOwner = fwdb.fetchonevalue(con, \"SELECT Id FROM CmObject WHERE Guid$='1F6AE209-141A-40DB-983C-BEE93AF0CA3C';\")\n\t\ttarget = fwdb.fetchonevalue(con, \"SELECT CAST(Id AS NVARCHAR(10)) FROM CmObject WHERE ... | [
"0.61164176",
"0.6086573",
"0.6030379",
"0.60151833",
"0.5949518",
"0.5944582",
"0.585349",
"0.58051187",
"0.5540081",
"0.55158114",
"0.54724574",
"0.5401769",
"0.5387588",
"0.53475434",
"0.53464705",
"0.53346616",
"0.52846813",
"0.5208107",
"0.5195098",
"0.51464385",
"0.5144... | 0.66548413 | 0 |
Load the Topology and Parameter input files in a CHARMM script. | def load_input_files(experiment = None):
# Loop through topology and parameter data
sets = [["Topology", defaultCHARMMTopologies, "rtf"], \
["Parameter", defaultCHARMMParameters, "para"]]
# Store the output in this string
output = ''
for set in sets:
# Get the list of files that ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_from_file(self):\n self.src.load('start.00') \n self.oe1.load('start.01')\n #self.det.load('start.02')\n print('NOTE: variables loaded from start.00/start.01 files')",
"def load_params_from_file(self, input_file):\n\n ### FILL IN ###",
"def LoadBatch(filename):",
... | [
"0.6328106",
"0.5862831",
"0.5800639",
"0.5776452",
"0.5681414",
"0.56722814",
"0.5633423",
"0.5612569",
"0.55729264",
"0.5489291",
"0.5470198",
"0.546114",
"0.545212",
"0.54462844",
"0.5445238",
"0.5370905",
"0.5361699",
"0.53493184",
"0.5340609",
"0.53389937",
"0.5314643",
... | 0.72200245 | 0 |
Create text to load Molecules in a CHARMM script. | def load_molecules(molecules, procedure, who = defaultUser, which = "all"):
# This function assumes that the molecules and procedure have already been
# validated.
# Validate the which input
if which not in ['all', 'ALL', True, False]:
text = "The load_molecules function does not recognize the f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _vmd_script_molecule(mole, filename=\"molecule.xyz\"):\n output = \"# load new molecule\\n\"\n if len(mole.atom) == 0:\n raise ValueError(\"Need at least one molecule file with coordinates.\")\n atoms = mole.atom\n natoms = len(mole.atom[0:, 0])\n f = open(filename, \"w\")\n f.write(st... | [
"0.60499984",
"0.59223807",
"0.5772874",
"0.57414937",
"0.5643367",
"0.56091505",
"0.5550347",
"0.5488966",
"0.5298948",
"0.52671003",
"0.5246532",
"0.5229031",
"0.52114123",
"0.51994944",
"0.5194451",
"0.51818347",
"0.5163985",
"0.515581",
"0.51553047",
"0.5153074",
"0.51497... | 0.6260916 | 0 |
Generate the text to run an energy minimization in CHARMM. | def minimize(molecules, experiment, procedure, gn):
# It is assumed that the molecules and procedure have already been validated
# Get information about how and whether solvation should be used
solvation = SOLVATION.get_string(experiment, procedure)
# Don't include harmonic, NOE, or CDIH restraints duri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phast_cmmd(self):\n temp = '{prog} -R {rho} -C {ecov} -E {elen} -N {chrom} -i MAF {maf} {model} > {wig}\\n'.format(**self.dict)\n return temp.format(fnum=self.fnum)",
"def energy_line(experiment, procedure, h = '', n = '', c = '', s = ''):\n # It is assumed that the procedure has been valida... | [
"0.62186235",
"0.60976684",
"0.57640904",
"0.5736938",
"0.570432",
"0.5700379",
"0.56154275",
"0.5612268",
"0.5605229",
"0.5398097",
"0.5345621",
"0.5333687",
"0.52647763",
"0.5258067",
"0.5252585",
"0.52506256",
"0.5248988",
"0.5247445",
"0.5235633",
"0.5215722",
"0.52102387... | 0.61355656 | 1 |
Tell CHARMM to output the structures of Molecules. | def output_molecules(molecules, procedure, which = "all"):
# This function assumes the molecules and procedure have already been
# validated
# Validate the which input
if which not in ['all', 'ALL', True, False]:
text = "The output_molecules function does not recognize the following "
te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showMolecule(self, colorBy=None, label=False, dcdFN=None):\n # Write PDB file\n # To set Occupancy, change atom.occupancy\n # To set Beta, change atom.temperature_factor\n import os.path\n pdbFN = os.path.join(MMTK.Database.molecule_types.directory,\n 'showMolecule.pdb')\... | [
"0.64684266",
"0.62813777",
"0.6213274",
"0.61150444",
"0.5825615",
"0.5805206",
"0.5782927",
"0.5767169",
"0.5747765",
"0.5700098",
"0.5676539",
"0.5611531",
"0.5600111",
"0.55766654",
"0.55649245",
"0.55297834",
"0.5516984",
"0.54753894",
"0.54681623",
"0.5464425",
"0.54590... | 0.69198555 | 0 |
Load the structures of Molecules after a CHARMM script. | def load_structures(molecules, procedure, which = "all"):
# It is assumed that the molecules and procedure have been validated
# Check the which input
if which not in ['all', 'ALL', True, False]:
text = "The load_structures function does not recognize " + str(which)
text += " as a valid whic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_molecule(self):\n self.pymol = pybel.readstring(self.input_format, self.file_dic['input'])",
"def load_molecules(molecules, procedure, who = defaultUser, which = \"all\"):\n # This function assumes that the molecules and procedure have already been\n # validated.\n # Validate the which ... | [
"0.6783797",
"0.61807746",
"0.59067816",
"0.5854528",
"0.5719304",
"0.56569475",
"0.5425036",
"0.5408149",
"0.5290539",
"0.5244635",
"0.523718",
"0.52307755",
"0.51814115",
"0.5181116",
"0.51566774",
"0.5151144",
"0.51183134",
"0.5116236",
"0.511606",
"0.5114581",
"0.51020545... | 0.65413284 | 1 |
Add missing Atoms to Molecules. | def Missing_Atoms(molecules, experiment = None):
# Validate the Molecules
molecules, gn = validate_molecules(molecules)
# Declare the procedure, making sure it is OK (it is, but whatever)
procedure = validate_procedure("add_missing_atoms")
# Determine who is running this experiment
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_atoms_and_bonds(self, molecule):\n molecule_copy = Molecule()\n for atom in molecule.atoms:\n molecule_copy.add_atom(\n atom.atomic_number,\n atom.formal_charge,\n atom.is_aromatic,\n stereochemistry=atom.stereochemis... | [
"0.5802108",
"0.57705146",
"0.57424355",
"0.57209975",
"0.5653505",
"0.5321256",
"0.52975565",
"0.52427673",
"0.5129064",
"0.5048459",
"0.50448394",
"0.4976364",
"0.4963844",
"0.49598032",
"0.4954497",
"0.49362558",
"0.4921869",
"0.4917092",
"0.48898157",
"0.4856608",
"0.4803... | 0.74233854 | 0 |
Use CHARMM to calculate the complex energy of a group of Molecules. | def Energy(molecules, experiment = None, which = "all"):
# Validate the molecules
molecules, gn = validate_molecules(molecules)
# Create the procedure
procedure = validate_procedure("energy")
# Determine who is doing the calculation
try:
user = experiment["User"]
except (KeyError, Ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_hydration_energies(molecules, parameters):\n\n energies = dict() # energies[index] is the computed solvation energy of molecules[index]\n\n platform = openmm.Platform.getPlatformByName(\"Reference\")\n\n for molecule in molecules:\n # Create OpenMM System.\n system = openmm.Syste... | [
"0.6102931",
"0.6019462",
"0.5962269",
"0.5906023",
"0.5761142",
"0.5755507",
"0.57167214",
"0.57028973",
"0.56566876",
"0.56074214",
"0.56063014",
"0.5592461",
"0.5562213",
"0.5551486",
"0.5507442",
"0.5465821",
"0.5440099",
"0.5433445",
"0.54313534",
"0.54192346",
"0.540056... | 0.63414896 | 0 |
`/farms/{pk}/joinfarm/` Add the currently logged in `User` to this `Farm`. | def join_farm(self, request, pk):
farm = self.get_object()
user = request.user
farm.add_member(user)
return Response({}, status=status.HTTP_202_ACCEPTED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_member(self, request, pk):\n farm = self.get_object()\n user = request.data.get('user')\n farm.add_member(user)\n return Response({}, status=status.HTTP_202_ACCEPTED)",
"def join(self, request, *args, **kwargs):\n\n ride = self.get_object()\n\n serializer_class =... | [
"0.614371",
"0.56388605",
"0.5636513",
"0.54161614",
"0.5408255",
"0.53700006",
"0.53700006",
"0.5315713",
"0.5290479",
"0.5179916",
"0.5083087",
"0.50497824",
"0.5028001",
"0.49860078",
"0.49798116",
"0.4970577",
"0.49629772",
"0.49554673",
"0.49496973",
"0.49436402",
"0.493... | 0.82139915 | 0 |
`/farms/{pk}/leavefarm/` Remove the currently logged in `User` from this `Farm`. | def leave_farm(self, request, pk):
farm = self.get_object()
user = request.user
farm.remove_member(user)
return Response({}, status=status.HTTP_204_NO_CONTENT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_member(self, request, pk):\n farm = self.get_object()\n user = request.data.get('user')\n farm.remove_member(user)\n return Response({}, status=status.HTTP_204_NO_CONTENT)",
"def remove_user(self):\n self.currentuser = None\n self.carlocked = False",
"def re... | [
"0.6955627",
"0.6314787",
"0.5902678",
"0.5879287",
"0.5870993",
"0.5840002",
"0.5821149",
"0.5812009",
"0.57868904",
"0.56566715",
"0.5648229",
"0.56345135",
"0.5634099",
"0.5609749",
"0.56064785",
"0.56064785",
"0.56064785",
"0.5599789",
"0.5544361",
"0.55187434",
"0.551614... | 0.8487132 | 0 |
`/farms/{pk]/addmember/` Invite the specified `User` to join this `Farm`. | def add_member(self, request, pk):
farm = self.get_object()
user = request.data.get('user')
farm.add_member(user)
return Response({}, status=status.HTTP_202_ACCEPTED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_farm(self, request, pk):\n farm = self.get_object()\n user = request.user\n farm.add_member(user)\n return Response({}, status=status.HTTP_202_ACCEPTED)",
"def add_member():\n client = RequestManager()\n client.set_method(\"POST\")\n client.set_endpoint(\... | [
"0.7956005",
"0.72420937",
"0.6963823",
"0.6811299",
"0.6667502",
"0.6538611",
"0.64378905",
"0.63711953",
"0.6368376",
"0.63333774",
"0.63248056",
"0.6246403",
"0.6244292",
"0.61973894",
"0.6189578",
"0.60827667",
"0.6047275",
"0.5971067",
"0.5940765",
"0.5930914",
"0.589995... | 0.82120997 | 0 |
`/farms/{pk}/removemember/` Remove the specified `User` from this `Farm`. | def remove_member(self, request, pk):
farm = self.get_object()
user = request.data.get('user')
farm.remove_member(user)
return Response({}, status=status.HTTP_204_NO_CONTENT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_member(self, id, user):\n request = self.request_builder('orgs.teams.remove_member',\n id=id, user=user)\n return self._delete(request)",
"def remove_member(self, group_id: str, user_id: str):\n # If successful, this method returns 204 No Con... | [
"0.7634914",
"0.74602234",
"0.7206433",
"0.69761324",
"0.6942208",
"0.68900037",
"0.6838167",
"0.6770531",
"0.66664267",
"0.66381264",
"0.66182005",
"0.66095173",
"0.6604292",
"0.6589682",
"0.658884",
"0.65746456",
"0.6528085",
"0.6512394",
"0.6447883",
"0.64400554",
"0.64400... | 0.87344974 | 0 |
Converts a time range (ex. '1m', '5', 'max') to a datetime ojbect | def __time_range_to_date(time_range : str) -> dt.datetime:
if time_range.lower() == 'max':
return dt.datetime(1900,1,1)
multiplier, period = re.search("(\d+)([dwmy])", time_range.lower()).groups()
multiplier = int(multiplier)
if period == 'd': return dt.datetime.now() + relativedelta.relativede... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __time_range_to_date(time_range : str) -> dt.datetime:\n\n if time_range.lower() == 'max':\n return dt.datetime(1900,1,1)\n\n multiplier, period = re.search(\"(\\d+)([dwmy])\", time_range.lower()).groups()\n multiplier = int(multiplier)\n\n if period == 'd': return dt.datetime.now() + relative... | [
"0.7921445",
"0.62709147",
"0.6268865",
"0.6067156",
"0.580863",
"0.57697177",
"0.5648744",
"0.5644356",
"0.5632021",
"0.561408",
"0.5585713",
"0.5575347",
"0.5543593",
"0.5519087",
"0.55171835",
"0.55128515",
"0.5511257",
"0.5507609",
"0.5476374",
"0.5427873",
"0.5411636",
... | 0.793447 | 0 |
This function will retrieve historical trading data for the symbol and over the time range specified in a pandas DataFrame object. Returns None if the data is not retrievable | def GetHistoricalData(symbol : str, time_range : str) -> Optional[DataFrame]:
time_format = "%Y-%m-%d"
start_date = Equity.__time_range_to_date(time_range)
end_date = dt.datetime.now()
symbol_could_not_be_fixed = False
while True:
try:
df = DataReader(symbol, data_source='yahoo', st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_stock(symbol, interval):\n \n try:\n \n time_interval = TIME_INTERVALS[interval]\n \n if(time_interval == TIME_INTERVALS['Intraday']):\n json_data = requests.request('GET', 'https://www.alphavantage.co'+\n '/query?function=TIME_SERIES_INTR... | [
"0.723879",
"0.7216688",
"0.71670187",
"0.6946852",
"0.6873125",
"0.6863772",
"0.6836318",
"0.6772088",
"0.6769108",
"0.6758394",
"0.67355514",
"0.6728926",
"0.6721619",
"0.6713267",
"0.6661729",
"0.6596351",
"0.6578756",
"0.65484416",
"0.6540564",
"0.65378445",
"0.6526943",
... | 0.7930305 | 0 |
This function will get the percent change of equity share price of a set of different time ranges. | def GetPercentChangeOverTimeRanges(symbol : str, time_ranges : List[str]) -> List[dict]:
def get_percent_change(pd_dataframe):
"""
This will calculate the percent change of a share over some time frame by reading DataFrame values
"""
time_format = "%Y-%m-%d"
open_val = pd_datafra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percent_changes(self):\n\n # close_t = float(val[\"klines\"][\"1m\"].get(self.mw.cfg_manager.pair, {})[-5][4])\n klines_data = self.mw.klines.get(\"1m\")\n coin_data = klines_data.get(self.mw.cfg_manager.pair)\n\n if isinstance(coin_data, list):\n close_5m = float(self.mw... | [
"0.67339665",
"0.6160823",
"0.60994446",
"0.596452",
"0.5857888",
"0.57984257",
"0.5749799",
"0.5747567",
"0.57276505",
"0.57237655",
"0.5515268",
"0.54910296",
"0.54896593",
"0.5489438",
"0.54639006",
"0.54091835",
"0.5393975",
"0.5368517",
"0.5364089",
"0.53548366",
"0.5342... | 0.66125846 | 1 |
This will calculate the percent change of a share over some time frame by reading DataFrame values | def get_percent_change(pd_dataframe):
time_format = "%Y-%m-%d"
open_val = pd_dataframe.iloc[0]['Open']
close_val = pd_dataframe.iloc[-1]['Adj Close']
if open_val == 0:
return "N/A"
else:
return round((close_val - open_val) / open_val * 100, 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percent_change(df, lag):\n\n def _pc(window):\n today = float(window[-1][\"c\"])\n compare = float(window[0][\"c\"])\n change = ((today - compare) / compare) * 100\n return round(change, 2)\n\n return [_pc(df[i : i + lag + 1]) for i in range(len(df) - lag)]",
"def percentage... | [
"0.70771146",
"0.6300938",
"0.5975893",
"0.5946316",
"0.59099215",
"0.5908374",
"0.59003836",
"0.5848711",
"0.58313084",
"0.57837766",
"0.5745381",
"0.5692947",
"0.5603733",
"0.55009323",
"0.53791946",
"0.5355176",
"0.5333886",
"0.5330266",
"0.5318077",
"0.53168833",
"0.52851... | 0.7111712 | 0 |
Converts a time range (ex. '1m', '5', 'max') to a datetime ojbect | def __time_range_to_date(time_range : str) -> dt.datetime:
if time_range.lower() == 'max':
return dt.datetime(1900,1,1)
multiplier, period = re.search("(\d+)([dwmy])", time_range.lower()).groups()
multiplier = int(multiplier)
if period == 'd': return dt.datetime.now() + relativedelta.relativede... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __time_range_to_date(time_range : str) -> dt.datetime:\n\n if time_range.lower() == 'max':\n return dt.datetime(1900,1,1)\n\n multiplier, period = re.search(\"(\\d+)([dwmy])\", time_range.lower()).groups()\n multiplier = int(multiplier)\n\n if period == 'd': return dt.datetime.now() + relative... | [
"0.793447",
"0.62709147",
"0.6268865",
"0.6067156",
"0.580863",
"0.57697177",
"0.5648744",
"0.5644356",
"0.5632021",
"0.561408",
"0.5585713",
"0.5575347",
"0.5543593",
"0.5519087",
"0.55171835",
"0.55128515",
"0.5511257",
"0.5507609",
"0.5476374",
"0.5427873",
"0.5411636",
... | 0.7921445 | 1 |
This function returns the BlackScholes call value for an options contract | def CallValue(contract : 'Contract') -> float:
return Option.__call_value(contract.underlyingPrice, contract.strikePrice, contract.interestRate / 100, contract.daysToExpiration / 365, contract.volatility / 100) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_option_value(x_s, x_y, tau_y, x_sigma, m_moneyness, tau_implvol,\n k_strk, t_end, t_hor):\n\n x_sigma = x_sigma.reshape(-1)\n\n # Step 1: Compute time to expiry of the call option at thor\n\n tau = np.busday_count(t_hor, t_end)/252\n\n # Step 2: Compute value of the underl... | [
"0.58751965",
"0.5740435",
"0.5617026",
"0.5514296",
"0.54566777",
"0.54271317",
"0.54179317",
"0.5397908",
"0.5357593",
"0.5343789",
"0.53238255",
"0.5323027",
"0.52286446",
"0.5227392",
"0.52151555",
"0.5213908",
"0.5185896",
"0.5179846",
"0.5173719",
"0.5145687",
"0.514263... | 0.63005114 | 0 |
This function will use the TD Ameritrade API to retrieve Option(s) for the symbol available up to the specified to_date | def GetOptions(td_ameritrade_api_key : str, symbol : str, to_date : str) -> List['Option']:
options_url = 'https://api.tdameritrade.com/v1/marketdata/chains'
request = requests.get(url = options_url, params = {
'apikey' : td_ameritrade_api_key,
'symbol' : symbol,
'contractType' : "ALL",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_options_data(self, from_date, to_date, range=\"None\"):\n base_url = 'https://api.tdameritrade.com/v1/marketdata/chains?&symbol={stock_ticker}&fromDate={startdate}&toDate={enddate}&range={range}'\n endpoint = base_url.format(stock_ticker=self.ticker, startdate=from_date, enddate=to_date, rang... | [
"0.7459513",
"0.5947577",
"0.58769",
"0.54279345",
"0.542717",
"0.5425809",
"0.5412879",
"0.53776854",
"0.5369474",
"0.5347454",
"0.5339872",
"0.5335102",
"0.528961",
"0.528202",
"0.52412295",
"0.52411515",
"0.5228036",
"0.5224506",
"0.52194744",
"0.5203802",
"0.5164655",
"... | 0.8007887 | 0 |
Finds the corresponding table name for the security specified | def __get_table_name(security : Union[Equity, Option, SecurityType]) -> str:
if isinstance(security, Equity):
return 'Equities'
elif isinstance(security, Option):
return 'Options'
elif isinstance(security, EquityListing):
return "ListedEquities"
elif isinstance(security, SecurityTy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_table(name):\n tables = Base.metadata.tables\n table = tables.get(name, None)\n if table is not None:\n return table\n else:\n raise NameError('Unable to locate table: %s' % name)",
"def getTableByName(self, tablename):\n pass",
"def table_name() -> str:\n pass... | [
"0.67943525",
"0.6685553",
"0.6365931",
"0.63298464",
"0.62465066",
"0.62413204",
"0.62344176",
"0.6208685",
"0.60447127",
"0.6017178",
"0.6003623",
"0.5984685",
"0.59766996",
"0.59766996",
"0.59766996",
"0.59665054",
"0.5958655",
"0.5957935",
"0.5915635",
"0.58586437",
"0.58... | 0.6999453 | 0 |
Assure that the column name is SQL valid | def _validate_column_name(col_name : str) -> str:
if col_name[0].isdigit():
return f'"{col_name}"'
return col_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _valid_column(column_name):\n return str(column_name)",
"def column_name(name):\n # Only needs exceptions to standard token cleanup\n column_map = {\n \"line#\" : \"ignore\",\n \"date\" : \"timestamp\",\n \"rh\" : \"humidity\",\n \"par\" : \"par_ue\"\n }\n\n i... | [
"0.8112268",
"0.6607129",
"0.64823",
"0.6339913",
"0.63204974",
"0.62815547",
"0.6265024",
"0.6238832",
"0.6224266",
"0.61663926",
"0.61599976",
"0.6109794",
"0.60717046",
"0.6065956",
"0.6063813",
"0.6029353",
"0.60210615",
"0.60210615",
"0.6020517",
"0.60135686",
"0.5959498... | 0.78522587 | 1 |
Takes the conditions in tuple format and converts it to a proper SQL WHERE clause | def __convert_to_sql_where(conditions : List[Tuple[Any, RelationalOperator, Any]]) -> str:
formatted_identifiers = []
for identifier in conditions:
col_name, relation, value = identifier
if relation == RelationalOperator.Between and len(value) != 2:
raise ValueError("Between relational op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_where_clause(**kwds_filter):\n clause = []\n params = []\n items = kwds_filter.items()\n items = sorted(items, key=lambda x: x[0]) # Ordered by key.\n for key, val in items:\n if nonstringiter(val):\n clause.append(key + ' IN (%s)' % (', '.jo... | [
"0.75511324",
"0.751034",
"0.7240489",
"0.72299075",
"0.719078",
"0.7017938",
"0.6985508",
"0.6978745",
"0.6949176",
"0.67960805",
"0.6721013",
"0.66881025",
"0.66401166",
"0.6640089",
"0.6536709",
"0.6489517",
"0.64729446",
"0.64506096",
"0.64329875",
"0.64316744",
"0.639672... | 0.81629884 | 0 |
Adds security to corresponding table in database | def AddNewSecurity(self, security : Union[Equity, Option, EquityListing]) -> None:
table_name = self.__get_table_name(security)
self.Insert(table_name, security.__dict__.keys(), security.__dict__.values()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_security(self, secobj):\n with SecurityDocument(self.cloudant_database) as sec_doc:\n # context manager saves\n for key in sec_doc:\n del sec_doc[key]\n for k, v in secobj.items():\n sec_doc[k] = v\n return self.get_security()",
... | [
"0.5762194",
"0.5684788",
"0.55877537",
"0.5584634",
"0.55019045",
"0.549346",
"0.5435849",
"0.5261851",
"0.5249833",
"0.51618093",
"0.51508313",
"0.5139354",
"0.5113177",
"0.51063985",
"0.510039",
"0.509207",
"0.5085734",
"0.5036416",
"0.501583",
"0.49919537",
"0.4934684",
... | 0.6711932 | 0 |
Changes security entry that fits the condition parameter to the new security parameter. The condition | def ModifySecurities(self, new_security : Union[Equity, Option],
condition : Tuple[Any, RelationalOperator, Any]) -> None:
table_name = self.__get_table_name(new_security)
set_clause = ", ".join([f"{self._validate_column_name(key)} = '{value}'" for key, value in new_security.__di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def condition(self, condition):\n\n self._condition = condition",
"def security(self, security):\n\n self._security = security",
"def add_to_resource_policy(self, permission: aws_cdk.aws_iam.PolicyStatement) -> None:\n ...",
"def pre_security_group_update(self, resource_id, resource_dict... | [
"0.56319267",
"0.52913153",
"0.51880485",
"0.5138197",
"0.5048786",
"0.50446695",
"0.4990701",
"0.49798682",
"0.4965564",
"0.49579334",
"0.49161792",
"0.49092233",
"0.49073067",
"0.4904086",
"0.4850755",
"0.484347",
"0.48212504",
"0.48156554",
"0.47859845",
"0.4783498",
"0.47... | 0.737721 | 0 |
Delete security from the database. | def DeleteSecurity(self, security : Union[Equity, Option]) -> None:
table_name = self.__get_table_name(security)
# Query for the security with all matching key, value pairs
where_clause = self.__convert_to_sql_where([(key, RelationalOperator.EqualTo, value) for key, value in security.__dict__.items()])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete():\n\n from slicr.extensions import db\n\n click.echo('deleting database...')\n\n db.drop_all()",
"def delete(self):\n\n\n try:\n db = getDatabase()\n connection = db.connect()\n\n connection.delete(self)\n except Exception as e:\n rai... | [
"0.6713016",
"0.6608892",
"0.65223384",
"0.64207286",
"0.63405496",
"0.62951076",
"0.62951076",
"0.62616146",
"0.6248997",
"0.62330157",
"0.62202704",
"0.6216676",
"0.6184665",
"0.6184209",
"0.6184209",
"0.6184209",
"0.6184209",
"0.6184209",
"0.6184209",
"0.6184209",
"0.61842... | 0.78513324 | 0 |
Deletes securities from database according to the conditions provided | def DeleteSecuritiesConditional(self, security_type : SecurityType, conditions : List[Tuple[Any, RelationalOperator, Any]] = None) -> None:
table_name = self.__get_table_name(security_type)
where_clause = self.__convert_to_sql_where(conditions)
self.__cursor.execute(f"""DELETE FROM {table_name}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteSecurity(self, security : Union[Equity, Option]) -> None:\n\n table_name = self.__get_table_name(security)\n\n # Query for the security with all matching key, value pairs\n where_clause = self.__convert_to_sql_where([(key, RelationalOperator.EqualTo, value) for key, value in security.__dict__.it... | [
"0.67297053",
"0.6082248",
"0.57342494",
"0.5723573",
"0.5717666",
"0.56431663",
"0.56415236",
"0.56101036",
"0.5543574",
"0.5540737",
"0.55312276",
"0.55250317",
"0.5523151",
"0.55055684",
"0.54958075",
"0.54658735",
"0.5457351",
"0.5430379",
"0.542885",
"0.54031646",
"0.540... | 0.7211943 | 0 |
Finds all securities of type security_type with the specified conditions and ordering by columns | def GetSecurities(self, security_type : SecurityType,
conditions : Optional[List[Tuple[Any, RelationalOperator, Any]]] = None,
order_by_cols : Optional[List[Tuple[str, Ordering]]] = None) -> List[Union[Equity, Option]]:
table_name = self.__get_table_name(security_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteSecuritiesConditional(self, security_type : SecurityType, conditions : List[Tuple[Any, RelationalOperator, Any]] = None) -> None:\n \n table_name = self.__get_table_name(security_type)\n\n where_clause = self.__convert_to_sql_where(conditions)\n\n self.__cursor.execute(f\"\"\"DELETE FROM {tab... | [
"0.5674329",
"0.55904317",
"0.53238875",
"0.5221288",
"0.52047825",
"0.5104207",
"0.5013994",
"0.48731625",
"0.48639226",
"0.48021477",
"0.4785143",
"0.4761365",
"0.47400728",
"0.47247145",
"0.47231096",
"0.472173",
"0.47193614",
"0.46999517",
"0.46993297",
"0.46735325",
"0.4... | 0.76865876 | 0 |
Creates an empty customer database | def create_empty_db():
drop_db()
database.create_tables([Customer])
database.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_up_db():\n DATABASE.drop_tables([Customer])\n DATABASE.close()\n DATABASE.create_tables([Customer])\n DATABASE.close()",
"def create():\n\tcreate_db()",
"def init_database():\n database.init(DATABASE_NAME)\n database.connect()\n database.execute_sql('PRAGMA foreign_keys = ON')\n ... | [
"0.7221793",
"0.7115123",
"0.6954075",
"0.69491565",
"0.69062227",
"0.6875379",
"0.68609905",
"0.6835613",
"0.6829907",
"0.68232507",
"0.68232507",
"0.68232507",
"0.68232507",
"0.68232507",
"0.68232507",
"0.68232507",
"0.68232507",
"0.68232507",
"0.68232507",
"0.68232507",
"0... | 0.8655173 | 0 |
Tests customer search function | def test_search_customer(self):
create_empty_db()
add_customer(**user_1)
test_map = {'name': user_1['name'], 'lastname': user_1['lastname'],
'email': user_1['email_address'],
'phone_number': user_1['phone_number']}
self.assertEqual(test_map, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search_customer(self):\n expected_result = {\"name\": \"Bruce\", \"last_name\": \"Wayne\", \"email\": \"b_wayne@gotham.net\",\n \"phone_number\": \"228-626-7699\"}\n set_up_db()\n add_customer(*self.test_customer)\n self.assertDictEqual(expected_result... | [
"0.8433098",
"0.78554493",
"0.7749698",
"0.7430815",
"0.7430815",
"0.7430815",
"0.7240496",
"0.7186439",
"0.7137276",
"0.691457",
"0.6881121",
"0.677831",
"0.66977096",
"0.6683154",
"0.66805357",
"0.6661897",
"0.6565086",
"0.65262985",
"0.6513514",
"0.6483063",
"0.64814717",
... | 0.8326278 | 1 |
Tests the display of all customers in database | def test_display_customers(self):
create_empty_db()
self.assertEqual([], display_customers())
add_customer(**user_1)
add_customer(**user_2)
add_customer(**user_3)
self.assertEqual(['Post Malone', 'Howard Moon', 'Vince Noir'],
display_custom... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_all_customers():\n return cr.show_all_customers()",
"def test_get_customers(self):\n get_customers_url = reverse(\"customer_list\")\n response = self.client.get(get_customers_url)\n\n self.assertEqual(response.status_code, status.HTTP_200_OK)\n\n # get data from db\n ... | [
"0.78321546",
"0.765574",
"0.7507623",
"0.73981583",
"0.73763317",
"0.7312859",
"0.6968113",
"0.69495803",
"0.6936323",
"0.69045496",
"0.68810356",
"0.68714947",
"0.6854272",
"0.685199",
"0.6839281",
"0.6803956",
"0.67815447",
"0.67526907",
"0.67377967",
"0.6718462",
"0.66206... | 0.86292255 | 0 |
Adding a ColorField to a model should not fail in 2.2LTS. | def test_model_formfield_doesnt_raise(self):
try:
fields_for_model(Color())
except AttributeError:
self.fail("Raised Attribute Error") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_color(self, field):\n if match(r'^[A-Fa-f0-9]{0,6}$', field.data):\n field.data = field.data.lower()\n else:\n raise ValidationError('Field is not a valid hexadecimal color code.')",
"def test_model_formfield_with_samples_and_choices_fails(self):\n with sel... | [
"0.6144657",
"0.60924506",
"0.59366184",
"0.58583724",
"0.5856814",
"0.5793017",
"0.57466894",
"0.5722711",
"0.5693189",
"0.56905097",
"0.56780726",
"0.5676602",
"0.5676602",
"0.5676602",
"0.5676602",
"0.5676602",
"0.5676602",
"0.5676602",
"0.56575894",
"0.565718",
"0.5648426... | 0.6293986 | 0 |
Checks that supplying a ColorField with both samples and choices options fails (mutually exclusive). | def test_model_formfield_with_samples_and_choices_fails(self):
with self.assertRaises(ImproperlyConfigured):
ColorField(choices=COLOR_PALETTE, samples=COLOR_PALETTE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_clean_field_samples(self):\n # 1. Test with predefined choice\n obj = ColorSamples()\n obj.color = ColorSamples.COLOR_SAMPLES[0][0]\n try:\n obj.full_clean()\n except ValidationError as e:\n self.fail(\n \"Failed to assign predefined ... | [
"0.76602834",
"0.72265345",
"0.6560762",
"0.6471547",
"0.63304514",
"0.62948465",
"0.62655103",
"0.6157578",
"0.613556",
"0.6132139",
"0.6094466",
"0.5977011",
"0.5974872",
"0.5904495",
"0.5902005",
"0.5826977",
"0.5778925",
"0.5721709",
"0.5711629",
"0.56557363",
"0.56407785... | 0.81657267 | 0 |
Checks that supplying a ColorField with the samples kwarg works, and that it accepts valid values outside the predefined choices. | def test_clean_field_samples(self):
# 1. Test with predefined choice
obj = ColorSamples()
obj.color = ColorSamples.COLOR_SAMPLES[0][0]
try:
obj.full_clean()
except ValidationError as e:
self.fail(
"Failed to assign predefined palette choice... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model_formfield_with_samples_and_choices_fails(self):\n with self.assertRaises(ImproperlyConfigured):\n ColorField(choices=COLOR_PALETTE, samples=COLOR_PALETTE)",
"def test_clean_field_choices(self):\n # 1. Test with predefined choice\n obj = ColorChoices()\n obj.c... | [
"0.8121453",
"0.6735209",
"0.6562606",
"0.6553346",
"0.6415403",
"0.62921697",
"0.61956096",
"0.6193979",
"0.61735046",
"0.6090125",
"0.6013909",
"0.596989",
"0.5928204",
"0.5928033",
"0.58604497",
"0.5825832",
"0.582054",
"0.5727328",
"0.57246834",
"0.56875235",
"0.5641124",... | 0.8084923 | 1 |
Returns a dictionary of all timeline state items whose start/duration includes time_elapsed. | def GetItemsAtTime(self, time_elapsed):
items = []
if self.data == None:
raise Exception('TimelineData: Trying to GetState when data==None')
# Go through each of our items
for item in self.data:
# Ignore items that cant be retrieved by time_elapsed
if 'start' not in item or 'duration... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self, duration):\n metrics = []\n\n if duration:\n for count_key in self.kv_counts:\n metrics.append(\n MetricObject(\n count_key,\n self.kv_counts[count_key] / duration\n )\n ... | [
"0.6500112",
"0.62495285",
"0.6150903",
"0.60626864",
"0.59825057",
"0.5837152",
"0.5612959",
"0.5557811",
"0.5499858",
"0.5496939",
"0.54890347",
"0.54756135",
"0.54675496",
"0.5451769",
"0.5431832",
"0.5431779",
"0.5426059",
"0.54192394",
"0.54168785",
"0.5412851",
"0.53778... | 0.6650533 | 0 |
For read access, download the file into a local buffer. | async def _download(self) -> None:
# do request
async with aiohttp.ClientSession() as session:
async with session.get(self.url, auth=self._auth, timeout=self._timeout) as response:
# check response
if response.status == 200:
# get data and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get(self, remote_filename, local_path):\n\n with local_path.open('wb') as local_file:\n file_id = self.get_file_id(remote_filename)\n if file_id is None:\n raise BackendException(\n 'File \"%s\" cannot be downloaded: it does not exist' %\n ... | [
"0.71055895",
"0.70474404",
"0.7026733",
"0.68020684",
"0.6751272",
"0.67090553",
"0.66471654",
"0.66380334",
"0.66377354",
"0.66189885",
"0.65713143",
"0.6562706",
"0.6524925",
"0.6523518",
"0.6514468",
"0.64539516",
"0.6448589",
"0.6440528",
"0.6437386",
"0.64334494",
"0.64... | 0.7133285 | 0 |
Import the module "_data/[dataset_name]_dataset.py". In the file, the class called DatasetNameDataset() will be instantiated. It has to be a subclass of BaseDataset, and it is caseinsensitive. | def find_dataset_using_name(dataset_name):
dataset_filename = "datasets." + dataset_name + "_dataset"
datasetlib = importlib.import_module(dataset_filename)
dataset = None
target_dataset_name = dataset_name.replace('_', '') + 'dataset'
for name, cls in datasetlib.__dict__.items():
if 'datase... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def importDataset():\n module_path = os.path.join(path, \"dataset\")\n module_path = os.path.join(module_path, \"dataset.py\")\n dataset_class = importClass(\"Dataset\", \"dataset\", module_path)\n return dataset_class",
"def find_dataset_using_name(dataset_name):\n dataset_filename = \"data.\" + ... | [
"0.73856336",
"0.70676315",
"0.70676315",
"0.70676315",
"0.70357066",
"0.6100566",
"0.60220915",
"0.60212165",
"0.60069704",
"0.5995107",
"0.59597534",
"0.59526634",
"0.5945686",
"0.59253156",
"0.59022325",
"0.5873202",
"0.5868935",
"0.58618367",
"0.58618367",
"0.58513933",
"... | 0.7195769 | 1 |
resize image into (target_width,target_height) target_width/target_height = ow/oh raise ValueError, if target_height<=0 or target_width<=0 | def __scale_width_height(img, target_width=None, target_height=None, method=Image.BICUBIC):
if target_height > 0 and target_width:
raise ValueError(
f"Expected target_width>0 and target_height>0, but got target_width={target_width}, target_height={target_height}")
ow, oh = img.size
if t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_image_scale(source_width, source_height, target_width, target_height):\n if source_width == target_width and source_height == target_height:\n return 1.0\n\n source_ratio = source_width / source_height\n target_ratio = target_width / target_height\n\n if target_ratio < source_ratio... | [
"0.69097227",
"0.6889423",
"0.68845344",
"0.68554175",
"0.65885615",
"0.6567776",
"0.656434",
"0.65358025",
"0.65114975",
"0.6474362",
"0.6377472",
"0.6357848",
"0.6300716",
"0.6294298",
"0.62883276",
"0.6286805",
"0.62836665",
"0.62668663",
"0.62576365",
"0.6256997",
"0.6242... | 0.7334319 | 0 |
crop the image at position [pos,pos+size] | def __crop(img, pos, size):
ow, oh = img.size
x1, y1 = pos
tw = th = size
if (ow > tw or oh > th):
return img.crop((x1, y1, x1 + tw, y1 + th))
return img | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop(img, size, point=(0, 0)):\n y, x = point\n w, h = size\n hf, wf, _ = img.shape\n\n if not isinstance(x, int):\n y = min(int(wf * y), wf)\n x = min(int(hf * x), hf)\n\n if not isinstance(w, int):\n w = int(wf * w)\n h = int(hf * h)\n\n x2 = min(x + h, hf) - 1\n... | [
"0.78207093",
"0.7404092",
"0.7401432",
"0.7394182",
"0.73555976",
"0.73555976",
"0.73451686",
"0.72659546",
"0.72452694",
"0.72452694",
"0.7216573",
"0.7157376",
"0.71298385",
"0.7101451",
"0.7096666",
"0.7092405",
"0.7092133",
"0.70328265",
"0.7003536",
"0.699849",
"0.69729... | 0.8880825 | 0 |
flip the image if flip is True | def __flip(img, flip, flip_type=Image.FLIP_LEFT_RIGHT):
if flip:
return img.transpose(flip_type)
return img | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flip(img, boolean=True):\n return pg.transform.flip(img, boolean, False)",
"def flip_image(image):\n return cv2.flip(image, flipCode=1)",
"def flip_image(image):\n\n return cv2.flip(image, 1)",
"def flip(img, code=0):\n\treturn cv2.flip(img, flipCode=code)",
"def flip(self):",
"def flip_imag... | [
"0.81722796",
"0.7887645",
"0.77990437",
"0.77499473",
"0.76510876",
"0.75822663",
"0.75447565",
"0.7520633",
"0.7474796",
"0.7437431",
"0.73866946",
"0.73595345",
"0.72142386",
"0.7166891",
"0.71488017",
"0.71474534",
"0.7146304",
"0.713885",
"0.7103045",
"0.7093057",
"0.705... | 0.8200502 | 0 |
Print warning information about image size(only print once) | def __print_size_warning(ow, oh, w, h):
if not hasattr(__print_size_warning, 'has_printed'):
logging.warning(
f"The loaded image size was ({ow}, {oh}), so it was adjusted to ({w}, {h}).This adjustment will be done to all label2ImagePaths")
__print_size_warning.has_printed = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _print_img_size(self, img):\n width, height = img.size\n print('{}, {}'.format(width, height))",
"def size(img):\n\treturn img.size",
"def get_image_size(self):",
"def image_info(img):\n\tprint(img.format)\n\tprint(img.size)\n\tprint(img.mode)",
"def __len__(self):\n return len(sel... | [
"0.78217286",
"0.7217401",
"0.7132467",
"0.69822854",
"0.67987454",
"0.67987454",
"0.6509768",
"0.6467157",
"0.64110386",
"0.63456047",
"0.63248324",
"0.63074213",
"0.6241334",
"0.62292063",
"0.62288254",
"0.62165797",
"0.6196333",
"0.6195555",
"0.6195555",
"0.6195555",
"0.61... | 0.79489774 | 0 |
Create a 1D CNN regressor to predict the next value in a `timeseries` using the preceding `window_size` elements as input features and evaluate its performance. | def evaluate_timeseries(timeseries, window_size):
filter_length = 5
nb_filter = 4
timeseries = np.atleast_2d(timeseries)
if timeseries.shape[0] == 1:
timeseries = timeseries.T # Convert 1D vectors to 2D column vectors
nb_samples, nb_series = timeseries.shape
print('\n\nTimeseries ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predictions(loader, model, win_len_per_ser, criterion, device, window_out = 1 ):\n \n model.eval()\n num_win_per_ser = win_len_per_ser #num windows\n #print(num_win_per_ser)\n y_pred = []\n y_true = []\n with torch.no_grad():\n for idx, (x, y) in enumerate(loader): #for i in range... | [
"0.5676206",
"0.5624519",
"0.5538403",
"0.5511066",
"0.5476886",
"0.5473988",
"0.545578",
"0.54553986",
"0.5453578",
"0.5440728",
"0.54223055",
"0.5371483",
"0.5366023",
"0.5340317",
"0.53128916",
"0.5310433",
"0.52681905",
"0.5262947",
"0.5253199",
"0.52467644",
"0.5236356",... | 0.66528946 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.