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 |
|---|---|---|---|---|---|---|
return word embedding from path file | def gen_embedding(path):
word_emb = {}
with open(path, encoding='utf-8') as f:
for line in tqdm(f):
values = line.split()
word_emb[values[0]] = np.asarray(values[1:], dtype='float32')
return word_emb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_embedding_file(self):\n if self.language == 'en':\n embed_file_dir = self.embedding_path\n wv = KeyedVectors.load_word2vec_format(embed_file_dir, binary=True)\n self.pretrained_embedding = {}\n for word in wv.vocab.keys():\n normalized_word... | [
"0.714321",
"0.69293404",
"0.69026184",
"0.683942",
"0.67908764",
"0.6763844",
"0.6745005",
"0.6740114",
"0.6731184",
"0.6720369",
"0.6682428",
"0.66791385",
"0.66790795",
"0.6666699",
"0.66630864",
"0.6646522",
"0.66387117",
"0.66284627",
"0.6619337",
"0.66174227",
"0.658214... | 0.73965585 | 0 |
Returns the right value, b, from cons(a,b) | def cdr(pair):
def right_val(a,b):
return b
return pair(right_val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cons(a, b):\r\n def pair(f):\r\n return f(a, b)\r\n return pair",
"def cons(first, second):\n pair = Pair(first, second)\n if _can_be_list(pair):\n pair = _pair2list(pair)\n return pair",
"def peek(self):\r\n print(self.a, self.b)\r\n if self.a:\r\n ret... | [
"0.6104468",
"0.56823295",
"0.55193377",
"0.55020803",
"0.54645276",
"0.54475915",
"0.54198915",
"0.5387183",
"0.5368972",
"0.5313395",
"0.5312042",
"0.5309721",
"0.53004396",
"0.5286296",
"0.52612746",
"0.52436495",
"0.52195436",
"0.5196283",
"0.5162914",
"0.5103177",
"0.510... | 0.60538065 | 1 |
3d plot of the given x, y, z beside z2 | def plot3d2(x, y, z, z2, save_fig = True, title = None):
fig = plt.figure(figsize = (12, 7))
ax = fig.add_subplot(121, projection = '3d')
try:
ax.title.set_text(title)
except:
pass
surf = ax.plot_surface(x, y, z, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax.set_zlim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot3d(x, y, z, savefig = True):\n\n fig = plt.figure(figsize=(12, 7))\n ax = fig.gca(projection='3d')\n\n # Plot the surface.\n surf = ax.plot_surface(x, y, z, cmap=cm.coolwarm,\n linewidth=0, antialiased=False)\n\n # Customize the z axis.\n ax.zaxis.set_major_locator(LinearLocator(10))\n... | [
"0.73884255",
"0.72141445",
"0.71854126",
"0.71801126",
"0.71716255",
"0.71536535",
"0.7151224",
"0.7124016",
"0.707871",
"0.70730287",
"0.707246",
"0.7070368",
"0.7057608",
"0.70523095",
"0.70174587",
"0.7009494",
"0.70016164",
"0.6999338",
"0.69921994",
"0.685559",
"0.68468... | 0.76071006 | 0 |
Not used but would be a shame to delete it find the MSE for different nxn sized data sets and plots the MSE as a function of n. | def MSE_plots(n_min, n_max, save_fig, k = [5], method = 'OLS', lamb = 1, split = False, train = 0.7, N = 1, method2 = 'OLS'):
n = np.linspace(n_min, n_max, n_max - n_min + 1)
errors = np.zeros((4, len(k), len(n))) # First index MSE for real FrankeFunction, MSE for the data, R2 for the real FrankeFunction, R2 fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MSE(actual, noisy):\n mean_squared_error(actual, noisy)",
"def calc_mse(data, ax=0):\n return ((data[:, 0] - data[:, 1]) ** 2).mean(axis=ax)",
"def compute_MSE(e):\n\n return 1/2*np.mean(e**2)",
"def plot(self) -> None:\n cw_l2_data_list = list(); cw_linf_data_list = list()\n\n for... | [
"0.66081226",
"0.645139",
"0.6398277",
"0.6397658",
"0.63548166",
"0.6339845",
"0.6230781",
"0.6199714",
"0.6194183",
"0.61925435",
"0.6190124",
"0.6163094",
"0.6145237",
"0.61395943",
"0.61211854",
"0.6069992",
"0.60633487",
"0.60624605",
"0.60621196",
"0.6047089",
"0.603337... | 0.73682535 | 0 |
Varies lambda between lambda_min and lambda_max and plots the MSE and R2 for the test data as a function of lambda kfold is not used here, but I should have used the lambda_best_fit from regression.py. This was however added later. | def varying_lamda(x, y, z, lambda_min, lambda_max, n_lambda, k, save_fig = None, method = 'Ridge', split = True, train = 0.7, seed = 42, max_iter = 1001, l_min = False, plot_indexes = [0,1,2]):
lambdas = np.array([0] + np.logspace(lambda_min, lambda_max, n_lambda).tolist())
polynomials = np.array(k)
X, Y =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tune_lambda(Xtrain, ytrain, Xval, yval):\n #####################################################\n # TODO 5: Fill in your code here #\n #####################################################\n bestlambda = None\n err = 1\n\n for v in range(-19,20):\n if v>=0:\n val = float(\"... | [
"0.663487",
"0.6570577",
"0.5965127",
"0.57875526",
"0.5774969",
"0.57696885",
"0.57435316",
"0.5715972",
"0.5654938",
"0.5644364",
"0.56375545",
"0.5616511",
"0.5613352",
"0.5586539",
"0.5506",
"0.5466689",
"0.54639953",
"0.5441683",
"0.54297066",
"0.5401699",
"0.53822684",
... | 0.7175527 | 0 |
recreates figure 2.11 from the book as asked in exercise c using kfold N times with random indexes. The plot is the mean error estimates of N times | def fig_2_11V2(x, y, z, first_poly = 4, complexity = 10, N = 7, method = 'OLS', seed = 42, lam = 0, folds = 5, save_fig = ''):
errors = np.zeros((4, complexity + 1))
bias = np.zeros(complexity + 1)
variance = np.zeros(complexity + 1)
z_real = FrankeFunction(x, y)
complx = np.arange(first_poly, firs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem1():\n n_i = 10\n k = 5\n num_samples = 1000\n total_draws = 50\n\n plt.figure()\n for num_samples in [100, 1000, 10000]:\n experiment_results = []\n for samples in range(num_samples):\n # N = np.random.randint(1, k + 1, n_i * k)\n N = np.array([[i] ... | [
"0.642672",
"0.62238246",
"0.606139",
"0.5966277",
"0.5918029",
"0.58358914",
"0.5790589",
"0.5751784",
"0.5710527",
"0.57082236",
"0.56991595",
"0.56929916",
"0.5687621",
"0.56728876",
"0.5656668",
"0.56505597",
"0.5638749",
"0.56250715",
"0.56044215",
"0.5599866",
"0.558794... | 0.6231291 | 1 |
Finds the best lambda fit for the polynomial orders in p for the training data using kfold and makes multiple plots. Very slow for high n and m. | def best_fit(x, y, z, z_real, p = list(range(3, 15)), folds = 4, train = 0.7, seed = 42, n_lambda = 2001, n = 1, m = 1):
lambdas = np.array([0] + np.logspace(-5.5, -1, n_lambda).tolist())
polynomials = np.array(p)
X, Y = np.meshgrid(lambdas, polynomials)
MSE = np.zeros(np.shape(X))
lambda_min_ridge ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def varying_lamda(x, y, z, lambda_min, lambda_max, n_lambda, k, save_fig = None, method = 'Ridge', split = True, train = 0.7, seed = 42, max_iter = 1001, l_min = False, plot_indexes = [0,1,2]):\n\n lambdas = np.array([0] + np.logspace(lambda_min, lambda_max, n_lambda).tolist())\n polynomials = np.array(k)\n ... | [
"0.61967266",
"0.5894779",
"0.58709",
"0.5770856",
"0.5696888",
"0.56871897",
"0.56855875",
"0.56651926",
"0.5657436",
"0.5621841",
"0.5600335",
"0.5566454",
"0.5563774",
"0.55629843",
"0.5555587",
"0.5543707",
"0.5534561",
"0.5516074",
"0.5515341",
"0.5506598",
"0.5501438",
... | 0.6229848 | 0 |
A plot of the bias and variance tradeoff by recreating the noise N times for polynomial orders between first_poly first_poly + complexity | def bias_var(x, y, z, first_poly = 4, complexity = 10, N = 100, method = 'OLS', seed = 42, lam = 0, train = 0.7, folds = 5):
bias = np.zeros(complexity + 1)
variance = np.zeros(complexity + 1)
z_real = FrankeFunction(x, y)
complx = np.arange(first_poly, first_poly + complexity + 1, 1)
for i in ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def demo(N, y, cov_fun_kwargs, loo, K, ylim, figsize, seed, trace, upper_bound):\n\n T = y * N\n cov_fun, cov_kwargs = cov_fun_kwargs\n Sigma, tau = cov_functions[cov_fun](N, seed=seed, **cov_kwargs)\n\n np.random.seed(seed)\n sim = Simulation(Sigma, T)\n\n fig, (ax0, ax1) = plt.subplots(figsize=... | [
"0.6384267",
"0.61533856",
"0.59631354",
"0.58542526",
"0.57613903",
"0.570605",
"0.57036245",
"0.5686213",
"0.56431866",
"0.56123537",
"0.55745536",
"0.5549876",
"0.5538616",
"0.55181545",
"0.5514749",
"0.55057865",
"0.5466694",
"0.5443141",
"0.5441746",
"0.5433322",
"0.5414... | 0.66276705 | 0 |
Downloads the MD5 digests associated with the files in a resource. These are saved with the downloaded files in the cache and used to check if the files have been updated on the server | def get_digests(cls, resource):
result = resource.xnat_session.get(resource.uri + '/files')
if result.status_code != 200:
raise NiAnalysisError(
"Could not download metadata for resource {}"
.format(resource.id))
return dict((r['Name'], r['digest'])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_blob_digests(self):\n pass",
"def local_blob_digests(self):\n pass",
"def CalculateMd5OfEachFile(self, filedic):\n #for eachfiledic in self.fileTobeUploaded:\n fileobj = open(filedic[\"filepath\"], 'rb')\n buf = fileobj.read()\n hash = hashlib.md5()\n ... | [
"0.6428023",
"0.6428023",
"0.6357223",
"0.63461673",
"0.6337604",
"0.6337604",
"0.6319121",
"0.62722975",
"0.62688446",
"0.6263971",
"0.6251614",
"0.6246528",
"0.6199179",
"0.61964184",
"0.61926603",
"0.6190321",
"0.61285555",
"0.6124874",
"0.6120538",
"0.60825723",
"0.607179... | 0.66637766 | 0 |
This creates a derived session in a way that respects whether the acquired session has been shared into another project or not. If we weren't worried about this we could just use session = xnat_login.classes.MrSessionData(label=proc_session_id, parent=subject) | def _create_session(self, xnat_login, subject_id, visit_id):
uri = ('/data/archive/projects/{}/subjects/{}/experiments/{}'
.format(self.inputs.project_id, subject_id, visit_id))
query = {'xsiType': 'xnat:mrSessionData', 'label': visit_id,
'req_format': 'qa'}
respo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_session(self, **params):\n raise NotImplementedError('Should be implemented by a sub-class.')",
"def create_session(self):\n # TODO refactor bids_import pipeline to use same functions as dcm2bids below. To be done in different PR though\n if self.verbose:\n print(\"Crea... | [
"0.6008737",
"0.59029317",
"0.5520083",
"0.55035335",
"0.5414367",
"0.536214",
"0.53301024",
"0.5318129",
"0.5237338",
"0.5228435",
"0.52107745",
"0.516103",
"0.5145125",
"0.51413447",
"0.5140846",
"0.5119847",
"0.51185715",
"0.5112657",
"0.5101649",
"0.50704604",
"0.50569475... | 0.6869065 | 0 |
Caches a single dataset (if the 'path' attribute is accessed and it has not been previously cached for example | def cache(self, dataset, prev_login=None):
if dataset.archive is not self:
raise NiAnalysisError(
"{} is not from {}".format(dataset, self))
assert dataset.uri is not None
with self.login(prev_login=prev_login) as xnat_login:
sess_id, scan_id = re.match(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_cached(cache_path, in_dir):\n\n print(\"Creating dataset from the files in: \" + in_dir)\n\n # If the object-instance for DataSet(in_dir=data_dir) already\n # exists in the cache-file then reload it, otherwise create\n # an object instance and save it to the cache-file for next time.\n\n ca... | [
"0.7209974",
"0.6803537",
"0.674969",
"0.66327983",
"0.65216607",
"0.6515712",
"0.65049577",
"0.6504847",
"0.649996",
"0.6457507",
"0.6457507",
"0.6327937",
"0.63223124",
"0.6298402",
"0.626675",
"0.62393725",
"0.62176406",
"0.62156224",
"0.62143654",
"0.61547595",
"0.6144451... | 0.73272073 | 0 |
Return the tree of subject and sessions information within a project in the XNAT archive | def get_tree(self, subject_ids=None, visit_ids=None):
# Convert subject ids to strings if they are integers
if subject_ids is not None:
subject_ids = [
('{}_{:03d}'.format(self.project_id, s)
if isinstance(s, int) else s) for s in subject_ids]
# Add d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_subject_info_tree(subject_info_pyxb, authn_subj, include_duplicates=False):\n\n class State:\n pass\n\n state = State()\n\n state.subject_info_pyxb = subject_info_pyxb\n state.include_duplicates = include_duplicates\n state.visited_set = set()\n state.tree = SubjectInfoNode(\"Root\... | [
"0.6218537",
"0.5201899",
"0.51904243",
"0.5146706",
"0.51441693",
"0.51321507",
"0.5081233",
"0.50617266",
"0.5056689",
"0.5044258",
"0.49721885",
"0.4900442",
"0.48878756",
"0.48863026",
"0.48748198",
"0.4855289",
"0.48542503",
"0.48475945",
"0.4798768",
"0.47958493",
"0.47... | 0.6834698 | 0 |
Returns the labels for the XNAT subject and sessions given the frequency and provided IDs. | def get_labels(cls, frequency, project_id, subject_id=None,
visit_id=None):
if frequency == 'per_session':
assert visit_id is not None
assert subject_id is not None
subj_label = '{}_{}'.format(project_id, subject_id)
sess_label = '{}_{}_{}'.form... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nodes(self, ids):\n return [self.node_labels[i] for i in ids]",
"def get_labels():\n\n logging.info(\"Getting metadata about labels\")\n\n labels = []\n\n if len(args.labels) == 0:\n logging.warning(\"No labels specified, assuming all labels. If you have a lot of labels in your inb... | [
"0.60455763",
"0.58538216",
"0.5673425",
"0.56661934",
"0.55925333",
"0.5571956",
"0.553905",
"0.55372113",
"0.5479797",
"0.5430343",
"0.5406244",
"0.53669673",
"0.53579235",
"0.5339231",
"0.5337022",
"0.53341526",
"0.5321965",
"0.5311045",
"0.5294377",
"0.5279869",
"0.527889... | 0.654024 | 0 |
Downloads a single dataset from an XNAT server | def download_dataset(download_path, server, user, password, session_id,
dataset_name, data_format=None):
with xnat.connect(server, user=user, password=password) as xnat_login:
try:
session = xnat_login.experiments[session_id]
except KeyError:
raise NiAnal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_dataset(self):\n raise NotImplementedError",
"def x_download():\n\t#_loadconfig()\n\tconf = _get_config()\n\t#print conf['xplane']\n\tdownload_url = conf['xplane']['download']\n\tlocal(\"wget -P %s %s\" % (navimport.conf.work_dir(\"/xplane_zips\"), download_url))",
"def download(args):\n ... | [
"0.6454303",
"0.645106",
"0.64145815",
"0.622972",
"0.6204956",
"0.6166584",
"0.60750073",
"0.5986293",
"0.5952546",
"0.5930593",
"0.59178406",
"0.58890903",
"0.58786213",
"0.58727086",
"0.5863751",
"0.5862628",
"0.58624923",
"0.5855549",
"0.5848393",
"0.58119965",
"0.5810328... | 0.66168547 | 0 |
Return the total amount of calories for each item in the _calories dictionary. | def adding_total_calories(total_calories: int) -> int:
for item in _calories:
total_calories = total_calories + _calories[item]
return total_calories | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calories(foods, foods_used):\n calories = 0.0\n for i, count in foods_used.items():\n calories += (foods[i]['calories'] * count)\n return calories",
"def get_total_expenses(self):\n return sum(self.expenses.values())",
"def calories(self) -> List[RecipeObjectNutrientsCalories]:\n ... | [
"0.7841667",
"0.6843834",
"0.6591413",
"0.6374997",
"0.6353281",
"0.6308069",
"0.627658",
"0.6155628",
"0.615305",
"0.61347705",
"0.61346525",
"0.61346525",
"0.61346525",
"0.6096279",
"0.6092271",
"0.59906465",
"0.5984482",
"0.5926618",
"0.5919394",
"0.5877268",
"0.5825999",
... | 0.798169 | 0 |
Inserting a new value into the calories dictionary. | def insert_calorie_value(new_item: str) -> None:
new_item_calories = int(input("Enter calories for " + new_item + ": "))
_calories[new_item] = new_item_calories | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _insert_item(self, key: _KT, value: _VT) -> None:\n dict.__setitem__(self, key, value)",
"def __setitem__(self, key, value):\n self.insert(key, value)",
"def insert(self, key, val):\n self.dict.setdefault(key, []).append(val)",
"def add(self, key, value, location):\r\n i = sel... | [
"0.6804416",
"0.65591997",
"0.644645",
"0.64100003",
"0.6371622",
"0.63484925",
"0.62549883",
"0.6218331",
"0.62002844",
"0.618095",
"0.6173622",
"0.6158189",
"0.6128213",
"0.6082548",
"0.60798395",
"0.60317045",
"0.601796",
"0.60129565",
"0.60097075",
"0.5991703",
"0.5987463... | 0.7667434 | 0 |
Print the food items, total calories and average calories. | def printing_food_and_calories(food_item_names: list, total_calories: int) -> None:
avg_calories = total_calories / len(_calories)
print("\nFood Items:", sorted(food_item_names))
print("Total Calories:", total_calories,
"Average Calories: %0.1f\n" % avg_calories) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_food(self):\n for dish in self.food:\n print(dish.get_name())",
"def calories() -> None:\n new_item = input(\"Enter food item to add, or ’q’ to exit: \")\n while new_item != \"q\":\n insert_calorie_value(new_item)\n total_calories = 0\n total_calories = addi... | [
"0.7097891",
"0.6548885",
"0.64881444",
"0.6290056",
"0.62568957",
"0.62152535",
"0.6121451",
"0.6117783",
"0.6099719",
"0.6090612",
"0.6011658",
"0.59537023",
"0.5920604",
"0.5900643",
"0.58737713",
"0.5869495",
"0.586078",
"0.5847227",
"0.58046967",
"0.5803036",
"0.5749345"... | 0.88680345 | 0 |
Ask user for a food item and add it to list, calculate the average the calories and the total calories. Press q to quit. | def calories() -> None:
new_item = input("Enter food item to add, or ’q’ to exit: ")
while new_item != "q":
insert_calorie_value(new_item)
total_calories = 0
total_calories = adding_total_calories(total_calories)
food_item_names = []
appending_food_item_names(food_item_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printing_food_and_calories(food_item_names: list, total_calories: int) -> None:\n avg_calories = total_calories / len(_calories)\n print(\"\\nFood Items:\", sorted(food_item_names))\n print(\"Total Calories:\", total_calories,\n \"Average Calories: %0.1f\\n\" % avg_calories)",
"def buy_anim... | [
"0.6616214",
"0.6435766",
"0.6312016",
"0.6178241",
"0.61382043",
"0.6100695",
"0.6054668",
"0.6004036",
"0.5994595",
"0.5939111",
"0.58855563",
"0.5878791",
"0.5840907",
"0.58006424",
"0.5771299",
"0.57589585",
"0.57553786",
"0.57508004",
"0.57074237",
"0.5698907",
"0.568232... | 0.8009774 | 0 |
Computes the weighted F1_score for each label | def F1_score(y_t, y_p, weights):
P = Precision()
R = Recall() #label per label evaluation
F1_score_per_label = [] #store per label
P_per_label = []
R_per_label = []
F1_tot = 0 #weighted sum
for i in range(8):
P.update_state( y_t[:,i], y_p[:,i] )
R.update_state( y_t[:,i], y_p[:,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f1_score(true, pred, n_classes=2, pos_label=1, average=None, weights=None):\n\n if n_classes == 2:\n if np.sum(true * pred) == 0:\n f1 = 0.0\n else:\n f1 = skl_f1_score(true, pred, average='binary', labels=range(n_classes), pos_label=pos_label, sample_weight=weights)\n ... | [
"0.7590878",
"0.74019974",
"0.7304507",
"0.71994865",
"0.7189998",
"0.71749127",
"0.71248233",
"0.691543",
"0.68868256",
"0.6838204",
"0.68092096",
"0.679124",
"0.6774323",
"0.6744536",
"0.67118233",
"0.6662244",
"0.6661274",
"0.66467386",
"0.6592144",
"0.6565224",
"0.6547959... | 0.7838961 | 0 |
Rescales array of images to specified dimensions. | def resize_array(images, dim=None):
size = images.shape[0]
imgs = np.zeros((size, dim, dim))
for i in range(size):
imgs[i, :, :] = skimage_resize(images[i, :, :], (dim, dim))
return imgs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_images(images, new_shape):\n\n images_list = list()\n\n for image in images:\n new_image = resize(image, new_shape)\n images_list.append(new_image)\n \n return np.asarray(images_list)",
"def rescale_images(original_images):\n mobile_net_possible_dims = [128, 160, 192, 224]\... | [
"0.7039275",
"0.6845864",
"0.67618686",
"0.6744246",
"0.6735477",
"0.6676968",
"0.6545257",
"0.65400434",
"0.64330506",
"0.64327246",
"0.6339051",
"0.6335927",
"0.6315591",
"0.63030136",
"0.62993336",
"0.6288982",
"0.6275241",
"0.6275241",
"0.62733996",
"0.62527394",
"0.62028... | 0.73159486 | 0 |
Resizes raw ouput of frifriidownload. Takes ouput h5py file of frifriidownload.ipynb and returns a h5py file with the exact same format, but with resized images. Arguments | def initial_resizing(fr_raw_data_path, fr_data_path, dim=300):
with h5py.File(fr_raw_data_path, 'r') as data:
images = resize_array(np.asarray(data['images'].value), dim=dim)
labels = data['labels'].value
with h5py.File(fr_data_path, 'w') as f:
f.create_dataset('images', data=images)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(inputfile, output, size):\n if not output:\n output = join(dirname(inputfile), str(size))\n if not isdir(output):\n os.mkdir(output)\n\n logger.info('Resizing images from: %s' % inputfile)\n inputfile = realpath(inputfile)\n #/usr/share/datasets/KSCGR_Original/data1/bo... | [
"0.579831",
"0.5543579",
"0.54814976",
"0.5304206",
"0.52979577",
"0.52545416",
"0.522313",
"0.5215465",
"0.514157",
"0.51299906",
"0.512998",
"0.5110999",
"0.50995994",
"0.50909275",
"0.50872463",
"0.5072801",
"0.50724435",
"0.50657225",
"0.5059999",
"0.50595",
"0.5047526",
... | 0.6192724 | 0 |
Dumps random sources and FR sources into a h5py file. Empty images and images with nans are removed from inputed random radio images. The ouput h5py file has the exact file structure of the inputed fr_data_path file. The remaining random images are concatenated with the fr images. FRI labels are set to 0.0, FRII labels... | def add_random(fr_data_path, random_path, output_path):
with h5py.File(random_path, 'r') as data:
random = np.asarray(data['images'].value)
means = np.mean(np.mean(random, axis=-1), axis=-1)
empty = means == 0.0
error = np.isnan(means)
discard = empty | error
random_i = np.w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_random(everything_path, random_path):\n with h5py.File(random_path, 'r') as data:\n random = np.asarray(data['images'].value)\n \n means = np.mean(np.mean(random, axis=-1), axis=-1)\n empty = means == 0.0\n error = np.isnan(means)\n discard = empty | error\n\n random_i... | [
"0.58822685",
"0.58631015",
"0.58495665",
"0.5796117",
"0.57869375",
"0.57436776",
"0.5726677",
"0.56164074",
"0.5588292",
"0.5530099",
"0.55273885",
"0.5512033",
"0.54644233",
"0.5449375",
"0.5439521",
"0.5407889",
"0.5386092",
"0.537235",
"0.53329575",
"0.53090507",
"0.5292... | 0.7266753 | 0 |
Appends new random sources to data h5py File. Adds new random sources to a h5py file that is or has the same format as the output file of add_random_data. Arguments | def append_random(everything_path, random_path):
with h5py.File(random_path, 'r') as data:
random = np.asarray(data['images'].value)
means = np.mean(np.mean(random, axis=-1), axis=-1)
empty = means == 0.0
error = np.isnan(means)
discard = empty | error
random_i = np.where(~d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_random(fr_data_path, random_path, output_path):\n with h5py.File(random_path, 'r') as data:\n random = np.asarray(data['images'].value)\n \n means = np.mean(np.mean(random, axis=-1), axis=-1)\n empty = means == 0.0\n error = np.isnan(means)\n discard = empty | error\n\n r... | [
"0.67602044",
"0.6064266",
"0.54224694",
"0.5420276",
"0.54171365",
"0.54065704",
"0.5364606",
"0.53565514",
"0.53282213",
"0.5310068",
"0.5291916",
"0.52736014",
"0.52707237",
"0.52698874",
"0.52663946",
"0.5238524",
"0.5230575",
"0.5226644",
"0.5225333",
"0.5223067",
"0.522... | 0.6450735 | 1 |
Gets train and test labels for FRI vs Random classification. Arguments | def generate_labels_fri(train_i, test_i, labels):
train = labels[train_i]
test = labels[test_i]
train_y = train == 1
test_y = test == 1
return train_y, test_y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_labels_frii(train_i, test_i, labels):\n train = labels[train_i]\n test = labels[test_i]\n\n train_y = train == 2\n test_y = test == 2\n\n return train_y, test_y",
"def test_text_classifier_get_labels(self):\n pass",
"def get_test_labels(self):\n raise NotImplementedError",
... | [
"0.7286609",
"0.70569706",
"0.6933562",
"0.6903602",
"0.6713493",
"0.6697266",
"0.6591856",
"0.6465765",
"0.64569855",
"0.6450537",
"0.64132303",
"0.6358648",
"0.6337812",
"0.6301233",
"0.62951237",
"0.625972",
"0.6249722",
"0.6241342",
"0.6239845",
"0.6233966",
"0.62224144",... | 0.73998797 | 0 |
Gets train and test labels for FRII vs Random classification. Arguments | def generate_labels_frii(train_i, test_i, labels):
train = labels[train_i]
test = labels[test_i]
train_y = train == 2
test_y = test == 2
return train_y, test_y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_labels_fri(train_i, test_i, labels):\n train = labels[train_i]\n test = labels[test_i]\n\n train_y = train == 1\n test_y = test == 1\n\n return train_y, test_y",
"def test_text_classifier_get_labels(self):\n pass",
"def get_test_labels(self):\n raise NotImplementedError",
... | [
"0.756389",
"0.7096626",
"0.69290054",
"0.69257945",
"0.6868091",
"0.6732344",
"0.65533715",
"0.65446967",
"0.65136015",
"0.64089143",
"0.6353218",
"0.63307375",
"0.6273301",
"0.6269273",
"0.6239302",
"0.62379026",
"0.6231137",
"0.6231137",
"0.6198764",
"0.61917514",
"0.61780... | 0.7583044 | 0 |
Create ground truth array that allows multiple labels per point | def createGTMulti(classesDict, length, gtList):
""" Create array containing label for sample point: """
n_maxLabels = 5 #maximum number of labels that can be assign to one point
y_GT = np.empty([length,n_maxLabels])
y_GT.fill(-1) #-1 corresponds to no label given
classesNotTrained = []
for i i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_labels(n_samples):\n return np.ones([n_samples, 1]), np.zeros([n_samples, 1])",
"def create_TargetLabel(dataset):\n label_Array = dataset['close_-1_r'].shift(-1)\n label_Array = label_Array.apply(lambda x:1 if x>0.0000 else 0)\n return label_Array",
"def generate_patch_labels(batch_siz... | [
"0.6753623",
"0.6318638",
"0.62710094",
"0.6227057",
"0.61745167",
"0.6169001",
"0.616126",
"0.6144299",
"0.61347485",
"0.6133566",
"0.60322136",
"0.60288686",
"0.60180634",
"0.6002986",
"0.5985894",
"0.5984476",
"0.59774005",
"0.5975838",
"0.59698594",
"0.59608054",
"0.59271... | 0.6395419 | 1 |
The method first checks for every 2s windows, if all amplitude values lie below the silence threshold and returns silences for those interval. After that a majority vote of 2s length will be applied. | def majorityVoteSilence(y_Raw, amps, silenceClassNum):
y_raw = y_Raw.copy()
silenceThreshold = 1000
majVotWindowLength = 2.0 #in seconds
windowLength = 0.032
frameLengthFloat = math.ceil(majVotWindowLength/windowLength)
frameLength = int(frameLengthFloat)
resArray = np.empty(y_raw.shape)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_silence_threshold(self):\n loudest_sound_cohort_size = 0.2 # Top 20% are counted in the loudest sound group.\n silence_threshold_multiplier = 1.6 # Sounds must be at least 1.6x as loud as the loudest silence\n\n rospy.loginfo(\"Getting intensity values from mic.\")\n sel... | [
"0.71466213",
"0.6409475",
"0.6371328",
"0.6293573",
"0.6193076",
"0.5912924",
"0.5897721",
"0.5817821",
"0.5812242",
"0.57155514",
"0.5647271",
"0.56060433",
"0.5580342",
"0.5548751",
"0.5509576",
"0.54549193",
"0.5436235",
"0.5432081",
"0.53647876",
"0.53432316",
"0.5343104... | 0.67833835 | 1 |
Read a line from self.serial, ignoring all of the debug lines. You must have the self.serialLock before calling this function Returns None if we couldn't read a nondebug line in a reasonable amount of time. | def readNonDebugLine(self):
line = "D"
linesRead = 0
try:
while line == None or line == "" or line[0] == 'D':
linesRead += 1
if linesRead == 100:
return None
try:
line = self.serial.readline()
sys.stdout.write(".")
sys.stdout.flush()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readline(self):\n try:\n output = self.ser.readline()\n return output\n except SerialException as se:\n log.debug('Serial connection read error: {}'.format(se))\n return None",
"def get_valid_line(port):\r\n while True:\r\n try:\r\n ... | [
"0.675768",
"0.64719343",
"0.6133813",
"0.6089158",
"0.59813446",
"0.5949382",
"0.5907831",
"0.5847358",
"0.58420366",
"0.58226496",
"0.5808249",
"0.57025224",
"0.57025224",
"0.5692863",
"0.5597065",
"0.55887336",
"0.55807936",
"0.55561167",
"0.55356073",
"0.5519128",
"0.5516... | 0.80467755 | 0 |
redirects to next question, appends the responses | def handle_answer():
extracted_answer = request.form.get('answers')
responses.append(extracted_answer)
length = len(responses)
return redirect(f"/questions/{length}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to_question():\n # responses variable will go on to store all of the user's answers to the questions\n session[ANSWERS_KEY] = []\n return redirect(f\"/questions/{len(session[ANSWERS_KEY])}\")",
"def add_answer():\n\n ans = request.form['answer']\n responses.append(ans)\n\n response... | [
"0.75370693",
"0.7309631",
"0.69628924",
"0.6704508",
"0.6669402",
"0.6529099",
"0.65054333",
"0.6428117",
"0.6416601",
"0.63072085",
"0.62077636",
"0.6194221",
"0.61758107",
"0.6150198",
"0.61199987",
"0.60824966",
"0.6030395",
"0.59834605",
"0.58911955",
"0.58771056",
"0.58... | 0.74533087 | 1 |
after survery is done landing on a thank page | def thank_you():
return redirect('/thankyou') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thank_you(request):\n return render(request, 'core/thank_you.html')",
"def thanks(request):\n if 'contacted' in request.session:\n return render(request, 'thanks.html')\n else:\n return redirect('contact_us')",
"def finish_survey():\n return render_template(\"thanks.html\")",
"d... | [
"0.6788264",
"0.6595573",
"0.6461199",
"0.6460274",
"0.6422279",
"0.63809615",
"0.6344948",
"0.622954",
"0.6163851",
"0.6097609",
"0.60253763",
"0.59629446",
"0.59608006",
"0.5955534",
"0.5943139",
"0.5873326",
"0.57648176",
"0.57403934",
"0.5713635",
"0.5680469",
"0.56595933... | 0.66740227 | 1 |
renders thank you html to page | def add_thankyou():
final_thanks = "Thank you for taking our survey"
return render_template(
"thankyou.html",
thanks=final_thanks
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thank_you(request):\n return render(request, 'core/thank_you.html')",
"def thanks():\n return render_template('submitted.html')",
"def thanks(request):\n assert isinstance(request, HttpRequest)\n\n return render(\n request,\n 'AscensionESports_Baseline/Thanks.html',\n {\n ... | [
"0.8062041",
"0.77734506",
"0.75290006",
"0.74883515",
"0.7457509",
"0.6948474",
"0.6882326",
"0.6873065",
"0.6788622",
"0.6718006",
"0.66567886",
"0.659958",
"0.6525142",
"0.64785516",
"0.6360265",
"0.62707627",
"0.62213707",
"0.6219066",
"0.61733526",
"0.6143223",
"0.612966... | 0.79702383 | 1 |
Computes sacreBLEU score for current submission. | def _compute_score(self):
sgml_path = str(self.sgml_file.name)
text_path = sgml_path.replace('.sgm', '.txt')
ref_path = 'testsets/wmt18.ende.ref.txt'
from sacrebleu import process_to_text, corpus_bleu
from pathlib import Path
if not Path(text_path).exists():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_stability_scores(self):\n self.mutations, self.scores, self.matrix = stability(\n self.seq,\n alphabet='ACGU',\n fold_vectorize=self.fold_vectorize)",
"def calculScore(self):\n for cell in self.notComputeRouter:\n if(cell.isCovered==True):\n ... | [
"0.6732517",
"0.65753704",
"0.6566397",
"0.64567846",
"0.6423692",
"0.6418522",
"0.6341895",
"0.6328618",
"0.6322662",
"0.62882644",
"0.6285559",
"0.62766033",
"0.6234183",
"0.6184874",
"0.61445343",
"0.6140803",
"0.6136644",
"0.6134206",
"0.6118318",
"0.61123616",
"0.6053035... | 0.66659355 | 1 |
Create a sparse representention of ``sequences``. | def sparse_tuple_from(sequences):
indices = []
values = []
for n, seq in enumerate(sequences):
indices.extend(zip([n] * len(seq), range(len(seq))))
values.extend(seq)
indices = np.asarray(indices, dtype=np.int64)
values = np.asarray(values, dtype=np.int32)
shape = np.asarray([l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparse_tuple_from(sequences, dtype=np.int32):\n indices = []\n values = []\n\n for n, seq in enumerate(sequences):\n indices.extend(zip([n]*len(seq), range(len(seq))))\n values.extend(seq)\n\n indices = np.asarray(indices, dtype=np.int64)\n values = np.asarray(values, dtype=dtype)\... | [
"0.64814466",
"0.6476671",
"0.6423379",
"0.63320357",
"0.63310236",
"0.6280472",
"0.6280472",
"0.6027212",
"0.5975199",
"0.59632",
"0.5899897",
"0.5783154",
"0.57495433",
"0.57459867",
"0.57062215",
"0.5704625",
"0.56536067",
"0.5650805",
"0.564712",
"0.56219155",
"0.5614227"... | 0.69004315 | 0 |
Return harm'th harmonic of freq'th frequency | def HarmonicCurrent(self, freq, harm):
f = harm*self.freqs[freq].Wph
return self.Ip(f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def harmonic(num):\n if num < 2:\n return 1\n else:\n return 1 / num + (harmonic(num-1))",
"def getFWHM(antenna, freq):\n diameter = getDiameter(antenna)\n lam = 299792458.0 / (freq * 1e9)\n fwhmo = lam / math.pi * 180.0 * 60.0\n fwhm = 1.22 * fwhmo / diameter\n return fwhm",
"def ... | [
"0.7025545",
"0.69666004",
"0.67388034",
"0.66742104",
"0.66665643",
"0.65769804",
"0.65501016",
"0.64974946",
"0.64428353",
"0.6394897",
"0.63119864",
"0.6299196",
"0.62838924",
"0.6217714",
"0.6166127",
"0.61557734",
"0.61395794",
"0.61143035",
"0.60838854",
"0.6046865",
"0... | 0.7094828 | 0 |
Deabbreviates the given label_str as a Drake tools/workspace label. If the label_str is None, returns None. If the label_str is relative, interprets it relative to the "//tools/workspace/{name}/" package and returns an absolute label. Otherwise, returns the label_str unchanged. | def _resolve_drake_abbreviation(name, label_str):
if label_str == None:
return None
if label_str.startswith(":"):
return "@drake//tools/workspace/" + name + label_str
return label_str | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_cmdline(label_string):\n if not label_string.startswith('//'):\n label_string = '//' + label_string\n return Label.parse(label_string, None)",
"def parse_buildfile(label_string):\n if not isinstance(label_string, str):\n raise iga.fargparse.ParseError()\n ... | [
"0.5493452",
"0.53157383",
"0.5308865",
"0.52162045",
"0.5032356",
"0.49955347",
"0.49076423",
"0.48855197",
"0.48234028",
"0.47723868",
"0.47723868",
"0.4730411",
"0.47035912",
"0.46912217",
"0.4640282",
"0.46265084",
"0.4619898",
"0.4597021",
"0.45949158",
"0.45918074",
"0.... | 0.75893784 | 0 |
Download an archive of the provided GitHub repository and commit to the output path and extract it. | def github_download_and_extract(
repository_ctx,
repository,
commit,
mirrors,
output = "",
sha256 = "0" * 64,
extra_strip_prefix = "",
commit_pin = None):
urls = _urls(
repository = repository,
commit = commit,
mirrors = mirrors... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _download(url, outpath=None, dirname=None, branch='master', release=None):\n six.print_('downloading...')\n outfolder = outpath or os.getcwd()\n file, archive_url = get_archive_url(url, branch, release)\n six.print_(archive_url)\n if dirname:\n outfolder = \"{}/{}.zip\".format(outfolder, ... | [
"0.7299827",
"0.6996785",
"0.6851019",
"0.66118145",
"0.6502438",
"0.6454363",
"0.6326854",
"0.63167197",
"0.63033384",
"0.62513226",
"0.62509066",
"0.6237316",
"0.6226956",
"0.6197997",
"0.6196102",
"0.6155643",
"0.61142826",
"0.61126155",
"0.60822076",
"0.60154104",
"0.5985... | 0.77642673 | 0 |
Compute the strip prefix for a downloaded archive of the provided GitHub repository and commit. | def _strip_prefix(repository, commit, extra_strip_prefix):
repository_split = repository.split("/")
if len(repository_split) != 2:
fail("repository must be formatted as organization/project")
_, project = repository_split
# GitHub archives omit the "v" in version tags, for some reason.
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trim_repo_url(url):\n return url.replace(\".git\", \"\")",
"def removeprefix(self, x) -> String:\n pass",
"def github_archive(\n name,\n repository = None,\n commit = None,\n commit_pin = None,\n sha256 = \"0\" * 64,\n build_file = None,\n patches = No... | [
"0.5652172",
"0.5554605",
"0.54442376",
"0.5387567",
"0.5379905",
"0.5352716",
"0.53320515",
"0.53320336",
"0.53294367",
"0.5319218",
"0.52457154",
"0.5232823",
"0.52119076",
"0.51832646",
"0.5151672",
"0.5133377",
"0.5076513",
"0.5054134",
"0.50435024",
"0.50215286",
"0.5020... | 0.7977387 | 0 |
Returns true iff the commit is a hexadecimal string of length 40. | def _is_commit_sha(commit):
return len(commit) == 40 and all([
ch.isdigit() or (ch >= "a" and ch <= "f")
for ch in commit.elems()
]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_git_sha(text):\n # Handle both the full sha as well as the 7-character abbreviation\n if len(text) in (40, 7):\n try:\n int(text, 16)\n return True\n except ValueError:\n pass\n return False",
"def __isHexString(self, text):\n return all(map(l... | [
"0.75310045",
"0.6916779",
"0.6751016",
"0.66939974",
"0.6577284",
"0.64339066",
"0.64078575",
"0.6291537",
"0.62212795",
"0.6217626",
"0.6196688",
"0.6097613",
"0.60645914",
"0.6018439",
"0.59760046",
"0.59714776",
"0.5865132",
"0.5767874",
"0.57330835",
"0.57021797",
"0.565... | 0.79437214 | 0 |
Given a URL pattern for github.com or a Drakespecific mirror, substitutes in the given repository and commit (tag or git sha). | def _format_url(*, pattern, repository, commit):
is_commit_sha = _is_commit_sha(commit)
is_tag = not is_commit_sha
substitutions = {
"repository": repository,
"commit": commit,
"tag_name": commit if is_tag else None,
"commit_sha": commit if is_commit_sha else None,
}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_repository(post):\n pattern = re.compile(constants.REPOSITORY_REGEX)\n if \"links\" in post.json_metadata.keys():\n for link in post.json_metadata[\"links\"]:\n if link.startswith(\"/exit?url=\"):\n link = link[len(\"/exit?url=\"):]\n\n try:\n ... | [
"0.59759855",
"0.58624494",
"0.5857148",
"0.5793736",
"0.57574517",
"0.5607502",
"0.55679005",
"0.55396855",
"0.54959273",
"0.5490272",
"0.54473674",
"0.54330915",
"0.5402495",
"0.53789747",
"0.5333615",
"0.52597594",
"0.52568436",
"0.5239093",
"0.52205473",
"0.5201553",
"0.5... | 0.66242903 | 0 |
Compute the urls from which an archive of the provided GitHub repository and commit may be downloaded. | def _urls(*, repository, commit, mirrors):
result_with_nulls = [
_format_url(
pattern = x,
repository = repository,
commit = commit,
)
for x in mirrors.get("github")
]
return [
url
for url in result_with_nulls
if url != None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUrls(self):\n # in case you need to move from a read only Url to a writeable one, here it gets replaced\n repopath = self.repositoryUrl().replace(\"[git]\", \"\")\n repoString = utils.replaceVCSUrl(repopath)\n [repoUrl, repoBranch, repoTag] = utils.splitVCSUrl(repoString)\n ... | [
"0.6456689",
"0.6333289",
"0.6226612",
"0.6225718",
"0.6178328",
"0.617227",
"0.60984576",
"0.6067744",
"0.598783",
"0.5919076",
"0.58724535",
"0.5857349",
"0.5800136",
"0.5778897",
"0.5738447",
"0.5725445",
"0.5716222",
"0.5699203",
"0.56966025",
"0.56940144",
"0.56504464",
... | 0.68042713 | 0 |
Handle requests to /appointments route Retrieve & render all appointments in the db | def read_appointments():
if current_user.is_admin is False:
appointments = Appointment.query.filter_by(user_id=current_user.id).all()
else:
appointments = Appointment.query.all()
return render_template('appointments/index.html.j2', appointments=appointments, title='appointments') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def appointment_list(self, request, **dict):\n\t\tdata = self.get_serializer(self.get_queryset(), many=True).data\n\t\treturn Response(data, status.HTTP_200_OK)",
"def appointments(request):\n now = timezone.localtime(timezone.now())\n data = {}\n tables = {}\n rows = []\n seen = Appointment.objec... | [
"0.74196094",
"0.73475456",
"0.71870583",
"0.6975466",
"0.6908662",
"0.6689468",
"0.643109",
"0.62312776",
"0.6093619",
"0.60288614",
"0.59134096",
"0.5899959",
"0.5825844",
"0.5782626",
"0.57654375",
"0.5696964",
"0.5693876",
"0.5687839",
"0.56864846",
"0.5657706",
"0.565505... | 0.7767089 | 0 |
Handle requests to /appointments route Create & save a new appointment | def create_appointment():
form = AppointmentForm()
if form.validate_on_submit():
appointment = Appointment(
title = form.title.data,
description = form.description.data,
location = form.location.data,
start = form.start.data,
client = form.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_patient_appointment():\n if request.method == 'POST':\n patient_email = request.form['patient_email']\n doctor_email = request.form['doctor_email']\n date = request.form['date']\n time = request.form['time']\n\n response = requests.post(server_url + 'patient/create_... | [
"0.72616637",
"0.684108",
"0.6836346",
"0.66382486",
"0.65843296",
"0.63732463",
"0.62283784",
"0.6220162",
"0.6175483",
"0.60073113",
"0.60027397",
"0.58442044",
"0.5837622",
"0.5805806",
"0.57763404",
"0.5776016",
"0.574254",
"0.56820095",
"0.5660373",
"0.56394625",
"0.5607... | 0.73936397 | 0 |
Maximum likelihood labels for some distribution over y's | def label(self, p_y_given_x):
return np.argmax(p_y_given_x, axis=2).T | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def NLL(self,y):\n return -T.mean(T.log(self.p_y_given_x)[T.arange(y.shape[0]), y])",
"def negative_log_likelihood(self, y):\r\n # y.shape[0] is (symbolically) the number of rows in y, i.e., number of examples (call it n) in the minibatch\r\n # T.arange(y.shape[0]) is a symbolic vector which... | [
"0.6788078",
"0.65894145",
"0.6543456",
"0.6543456",
"0.6543217",
"0.6507876",
"0.64932126",
"0.6468587",
"0.6444979",
"0.6444979",
"0.6328523",
"0.6295609",
"0.6202991",
"0.61464185",
"0.61247444",
"0.611593",
"0.6109292",
"0.60936534",
"0.60499567",
"0.60223633",
"0.5948092... | 0.710404 | 0 |
Estimate marginals, log p(xi|yj) for each possible type. | def marginal_p(self, xi, thetai):
if self.marginal_description == 'gaussian':
mu, sig = thetai # mu, sig have size m by k
xi = xi.reshape((-1, 1, 1))
return (-(xi - mu)**2 / (2. * sig) - 0.5 * np.log(2 * np.pi * sig)).transpose((1, 0, 2)) # log p(xi|yj)
elif self.m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_marginal_likelihood(self):\n data = np.repeat([1, 0], [50, 50])\n marginals = []\n a_prior_0, b_prior_0 = 1.0, 1.0\n a_prior_1, b_prior_1 = 20.0, 20.0\n\n for alpha, beta in ((a_prior_0, b_prior_0), (a_prior_1, b_prior_1)):\n with pm.Model() as model:\n ... | [
"0.6380683",
"0.63611037",
"0.627736",
"0.61449707",
"0.5994979",
"0.59877026",
"0.59743273",
"0.59641844",
"0.59251755",
"0.5905187",
"0.5860727",
"0.5847705",
"0.58418274",
"0.5805165",
"0.57915455",
"0.5769771",
"0.5734626",
"0.57292646",
"0.57107455",
"0.5693731",
"0.5669... | 0.6595073 | 0 |
Takes a resource and a search term and return a list of countries or a country. | def _get_country_list(cls, resource, term="", filters=None):
# create the filter string
filters_uri_string = ""
if filters:
filter_string = cls.QUERY_SEPARATOR.join(filters)
filters_uri_string = "fields={}".format(filter_string)
# build uri
if term and no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_places(self, search, country=\"True\", city=\"True\"):\n params = {}\n params[\"query\"] = search\n params[\"includeCities\"] = city\n params[\"includeCountries\"] = country\n placeRequestPath = \"/apiservices/autosuggest/v1.0/\"\n browsePlacesURL = self.rootURL... | [
"0.60441583",
"0.59755903",
"0.5808493",
"0.57474273",
"0.5598684",
"0.55965686",
"0.5556006",
"0.553263",
"0.553263",
"0.54796916",
"0.53904295",
"0.5386155",
"0.5330523",
"0.5315031",
"0.5309764",
"0.530596",
"0.53020495",
"0.5272663",
"0.52635056",
"0.52504873",
"0.5243132... | 0.724008 | 0 |
Returns a `Country` object by alpha code. | def get_country_by_country_code(cls, alpha, filters=None):
resource = "/alpha"
return cls._get_country_list(resource, alpha, filters=filters) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def country(alpha_2_code: str) -> None:",
"def get_countries_by_country_codes(cls, codes, filters=None):\n resource = \"/alpha?codes=\"\n codes = cls.QUERY_SEPARATOR.join(codes)\n return cls._get_country_list(resource, codes, filters=filters)",
"def get_country_from_code(country_code):\n ... | [
"0.7089632",
"0.7018981",
"0.68360543",
"0.68055433",
"0.6680105",
"0.62955844",
"0.6288947",
"0.62801284",
"0.6251623",
"0.62398905",
"0.60558957",
"0.6047952",
"0.5955333",
"0.5927633",
"0.59150565",
"0.59130657",
"0.5884987",
"0.5858456",
"0.58371097",
"0.5823054",
"0.5794... | 0.81850433 | 0 |
Check if the log file exists and can be openend | def log_file_exists(path):
try:
f = open(path)
f.close()
except IOError:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_log_file_path(log_file_path):\n try:\n if not os.path.exists(log_file_path):\n print(\"Log file path not exists\")\n return False\n else:\n return True\n except:\n print(\"Log file path generic error: \" + log_file_path)\n return False",
... | [
"0.7649238",
"0.7530432",
"0.7347039",
"0.715572",
"0.71378726",
"0.6962555",
"0.68749493",
"0.6834695",
"0.66220766",
"0.66092384",
"0.65755713",
"0.6534093",
"0.6484807",
"0.6470693",
"0.641887",
"0.64120764",
"0.64054453",
"0.64047426",
"0.6366032",
"0.6365602",
"0.6356147... | 0.796735 | 0 |
Log the location requests and write them to a log file | def log_request(forecast):
from time import gmtime, strftime
current_day = strftime("%d/%m/%Y", gmtime())
current_time = strftime("%H:%M", gmtime())
with open('locations.log', 'a') as log:
# print(request.remote_addr, file=log) # IP address
# print(request.user_agent, file=log) # User a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _log_request(self):\n log = self.server.log\n if log:\n if hasattr(log, \"info\"):\n log.info(self.format_request() + '\\n')\n else:\n log.write(self.format_request() + '\\n')",
"def log(self):\n\n\t\theader_dict = dict(request.headers)\n\n\t\ttry:\n\t\t\ttracker_id = header_dict[\"tracker_... | [
"0.64807194",
"0.6284928",
"0.6123197",
"0.61184096",
"0.6048109",
"0.6014808",
"0.5960959",
"0.5927083",
"0.58963996",
"0.58346736",
"0.57979995",
"0.57882774",
"0.57657814",
"0.5727881",
"0.5725551",
"0.5710415",
"0.5706792",
"0.56919837",
"0.56617963",
"0.56570566",
"0.564... | 0.7201425 | 0 |
Set trait values by using the keyword arguments. Use cls.create() to create a new instance of this model. | def __init__(self, **kwargs):
super(Model, self).__init__(**kwargs)
for (key, value) in kwargs.iteritems():
# use setattr so that validation is triggered
setattr(self, key, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **attributes):\n self.set(**attributes)",
"def set(self, **kwargs):\n raise NotImplementedError",
"def set(self, **kwargs):\n field_names = self.get_field_names()\n for name, value in kwargs.iteritems():\n if name in field_names:\n setatt... | [
"0.67126644",
"0.65768415",
"0.6475461",
"0.6397765",
"0.6382912",
"0.6368563",
"0.6310652",
"0.6293842",
"0.622368",
"0.622368",
"0.622368",
"0.6221523",
"0.6202023",
"0.61928356",
"0.60710394",
"0.6064031",
"0.6038382",
"0.602038",
"0.6000997",
"0.59984493",
"0.599653",
"... | 0.7016906 | 0 |
Create a new instance of this model. The trait values on this new instance will be the same values as on the original instance, with the exception of immutable types like integers. | def __copy__(self):
trait_data = self.__getstate__()
inst = self.__class__.create(trait_data)
return inst | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n new = object.__new__(type(self))\n new.required = self.required\n new.title = self.title\n new.type = self.type\n values = self.values\n if (values is not None):\n values = (*values,)\n new.values = values\n return new",
"def __... | [
"0.6676559",
"0.6509449",
"0.6344153",
"0.6336235",
"0.631485",
"0.6277068",
"0.5996439",
"0.5996178",
"0.59518605",
"0.5939236",
"0.5934095",
"0.5916765",
"0.5915471",
"0.5902185",
"0.5884394",
"0.5878762",
"0.58628356",
"0.58510655",
"0.58510655",
"0.5834655",
"0.5824118",
... | 0.7120307 | 0 |
Build a dictionary of traits and their current values. | def __getstate__(self):
# grab all the traits
traits = self.traits()
# filter out transient traits
traits = [trait for trait in traits if traits[trait].get_metadata("transient") in [None, False]]
# build a dictionary
# TODO: use self.__dict__ instead of self._trait_valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traits(self):\n members = [member for member in getmembers(self.__class__) if isinstance(member[1], TraitType)]\n traits = dict(members)\n return traits",
"def traits ( self, **metadata ):\n traits = self.__base_traits__.copy()\n for name in self.__dict__.keys():\n ... | [
"0.7039768",
"0.63538194",
"0.6289249",
"0.6105193",
"0.5906057",
"0.56297034",
"0.560206",
"0.5465477",
"0.54623127",
"0.5447713",
"0.5443782",
"0.538566",
"0.5379683",
"0.537879",
"0.53405625",
"0.53195786",
"0.5283414",
"0.5221009",
"0.5196004",
"0.51920414",
"0.5186289",
... | 0.7150706 | 0 |
Loads a pickled data file if the file is there, returns False otherwise | def pickle_load(path):
if os.path.isfile(path):
file = pickle.load(open(path, "rb"))
return file
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_data(self, filename):\n if not os.path.isfile(filename):\n return False\n\n with open(filename) as f:\n data = pickle.load(f)\n if data:\n self.profiles = data['profiles']\n self.user_data = data['user_data']\n se... | [
"0.7287219",
"0.7144231",
"0.7137119",
"0.70844233",
"0.70248264",
"0.6880995",
"0.6860018",
"0.6859217",
"0.6858166",
"0.6843264",
"0.6794191",
"0.6782974",
"0.67791075",
"0.66986644",
"0.6648589",
"0.6612741",
"0.6609128",
"0.6606487",
"0.66049695",
"0.6603827",
"0.6598058"... | 0.7589998 | 0 |
Counts trigrams, bigrams and unigrams for words. This funcion appends them straigt to the data stuctures they will be used in. This populates features and raw conunts for each industry. | def countize(word, ind, count_words, features):
word = clean(word)
word = word.split()
if len(word)>1:
for i in range(1,len(word)):
bigram = (word[i-1],word[i])
count_words[ind].append(bigram)
features.append(bigram)
if len(word)>2:
for i in range(2,le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, corpus): \n for sentence in corpus.corpus:\n prev_word = None\n for datum in sentence.data:\n word = datum.word\n self.unigram_count[word] += 1\n if prev_word != None:\n self.bigram_count[prev_word][word] += 1\n prev_word = word\n \n self.v... | [
"0.67787427",
"0.6616555",
"0.6556645",
"0.63850594",
"0.63547343",
"0.6336458",
"0.63022137",
"0.6277686",
"0.62525123",
"0.6210935",
"0.61823857",
"0.6177107",
"0.61616325",
"0.6132681",
"0.6123291",
"0.6087143",
"0.60707706",
"0.60529006",
"0.6035648",
"0.6004986",
"0.5998... | 0.67658335 | 1 |
Gathers and pickles vectors from a given csv file. | def gather_and_save_vectors(path, words_vec = collections.defaultdict(list), features = []):
with open(path, 'rt', encoding='mac_roman') as csvfile:
csvreader = csv.reader(csvfile, delimiter=' ', quotechar='"')
for row in csvreader:
words_vec, features = countize(row[3], row[2], words_ve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadCSV(input_file):",
"def csvToVec(filename):\n X = csvToArray(filename)\n assert X.shape[0] == 1, 'file %s must have 1 row' % filename\n y = X[0,:]\n return y",
"def load_file(csv_file):\n vehicles = []\n # Opens the file and reads it row for row\n with open(csv_file, 'rb') as csv_o... | [
"0.6888591",
"0.6667055",
"0.6447633",
"0.6441823",
"0.6416773",
"0.638443",
"0.63685536",
"0.62376577",
"0.6235755",
"0.62333155",
"0.6210472",
"0.6201278",
"0.6198714",
"0.6145814",
"0.6137962",
"0.6124991",
"0.61010146",
"0.6021219",
"0.60208184",
"0.60184103",
"0.6010493"... | 0.67931163 | 1 |
Returns ngrams of a given role. Role can be a string or a tuple of strings. (In this latter case they already are assumed to be stripped of unnecessary punctuation, certain nonalphanumeric charatcters and capitalisation). | def n_grammize(role):
ngrams = []
if isinstance(role,str):
role = role.lower()
role = role.split()
if len(role)>2:
for i in range(2, len(role)):
ngrams.append((role[i-2], role[i-1], role[i]))
if len(role)>1:
for i in range(1, len(role)):
ng... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ngrams(self, string_):\n def find_ngrams(input_list, n):\n return zip(*[input_list[i:] for i in range(n)])\n\n ngrams = []\n tokens = string_.split()\n\n for size in range(1, self._ngram_range + 1):\n tuples = find_ngrams(tokens, size)\n concatenate... | [
"0.61402243",
"0.6019998",
"0.60045886",
"0.59341073",
"0.59319186",
"0.58735085",
"0.58025056",
"0.5800501",
"0.57737285",
"0.57707524",
"0.5729101",
"0.5727403",
"0.5667416",
"0.5612965",
"0.55376065",
"0.5521605",
"0.5495334",
"0.5429406",
"0.54199857",
"0.54048324",
"0.53... | 0.8349167 | 0 |
Uses featurize function on a vector. | def feature_vector(features, vector):
clean_features = set(features)
new_features_vector = featurize(vector,clean_features)
return new_features_vector | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, X):\n featurizers = [self.featurizer1, self.featurizer2, self.featurizer3, self.featurizer4, self.featurizer5,\n self.featurizer6, self.featurizer7, self.featurizer8, self.featurizer9, self.featurizer10]\n fvs = []\n for datum in X:\n [fv] = ... | [
"0.6279238",
"0.62478745",
"0.6121798",
"0.6079553",
"0.60581803",
"0.60362357",
"0.59740824",
"0.5891672",
"0.5890009",
"0.58688086",
"0.5858637",
"0.5843295",
"0.58297974",
"0.57748574",
"0.5719389",
"0.5689847",
"0.5676522",
"0.5671145",
"0.56549513",
"0.5650641",
"0.55704... | 0.75786316 | 0 |
Removes stopwords and some nonalpahnumeric characters that are deemed irrelevant for our purposes. | def clean(word):
word = word.lower()
stopwords = ['of', 'and','to', 'at', 'in', '@']
word = re.sub(r'[\&/\-\(\)\|\@,\]\[]+', ' ', word)
for stopword in stopwords:
pattern = r'\b' + stopword + r'\b'
pattern = re.compile(pattern)
word = re.sub(pattern, '', word)
word = re.sub(r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_stopwords(self, text: str) -> str:\n pattern = r\"\"\"\n (?x) # Set flag to allow verbose regexps\n \\w+(?:-\\w+)* # Words with optional internal hyphens \n | \\s* # Any spa... | [
"0.7668897",
"0.75107396",
"0.75107396",
"0.75107396",
"0.75107396",
"0.75107396",
"0.75107396",
"0.75103426",
"0.745749",
"0.7410949",
"0.7322454",
"0.72971654",
"0.7257038",
"0.7251849",
"0.7238443",
"0.7230823",
"0.7226988",
"0.71822757",
"0.71772724",
"0.7159221",
"0.7149... | 0.7719584 | 0 |
Sets weight of each term depending on ocurrance. 0.2 is decided completely heuristically. Features are deemed irrelevant if they appear many times in each industry and aren't associated with one in particular. | def set_weight(term, irrelevant):
if term in irrelevant:
return (0.2 * max([x/sum(indtf_features[term]) for x in indtf_features[term]]))
elif isinstance(term, tuple):
return len(term)
else:
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_weights_rocchio(isRelevant, result):\n\tglobal global_weights\n\tmax_contributing_weight = max(result.sim_measures, key=result.sim_measures.get)\n\tif isRelevant:\n\t\tglobal_weights[max_contributing_weight] += alpha\n\t\tfor measure in result.sim_measures:\n\t\t\tglobal_weights[measure] -= beta \n\n\te... | [
"0.6369961",
"0.6271947",
"0.60454494",
"0.585983",
"0.58412117",
"0.5800738",
"0.57777506",
"0.57360715",
"0.5691468",
"0.56898457",
"0.5493943",
"0.54804784",
"0.54799795",
"0.5478447",
"0.54776084",
"0.54596615",
"0.54485625",
"0.54483396",
"0.5446516",
"0.54402906",
"0.54... | 0.67181236 | 0 |
Transforms a short 'document' according to a trained model and weights to infer the topic. Each topic is and index. Query can be a string, tuple of string or a list of tuple of strings. Verbose = False will return only the numeric index. Otherwise the topics can be interpreted bu a legend in form of a dictionary. | def guess_topic(lda, query, features_vec, irrelevant, verbose=True):
query_doc = []
doc_topic = []
topic_most_pr = None
if isinstance(query,str):
query = clean(query)
query = n_grammize(query)
for term in query:
weight = set_weight(term, irrelevant)
if ter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def semanticSearch(model, topics, index, idx_to_docid, k=1000):\r\n run = {}\r\n topic_nums = [topic for topic in topics]\r\n queries = [topics[topic]['title'] for topic in topics]\r\n encoded_queries = model.encode(queries)\r\n labels, distances = index.knn_query(encoded_queries, k=k)\r\n for i,... | [
"0.57476157",
"0.56244314",
"0.55522525",
"0.55447453",
"0.5503854",
"0.54328257",
"0.540742",
"0.53439325",
"0.52937776",
"0.52260923",
"0.5206664",
"0.5205154",
"0.51819384",
"0.5175856",
"0.51390594",
"0.5078848",
"0.50570416",
"0.5042481",
"0.50256",
"0.50121063",
"0.5008... | 0.5973902 | 0 |
Get the n most common rolename from csvfile (I used it) for testing purposes mostly. | def get_mostcommon(path, n, i=3):
allroles = []
with open(path, 'rt', encoding='mac_roman') as csvfile:
csvreader = csv.reader(csvfile, delimiter=' ', quotechar='"')
for row in csvreader:
try:
role = clean(row[i])
allroles.append(''.join(role))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_team(file):\n with open(file, \"r\") as csv_file:\n reader = csv.reader(csv_file)\n next(reader)\n most_wins = 0\n best_team = \"\"\n for row in reader:\n if int(row[3]) > most_wins:\n most_wins = int(row[3])\n best_team = row[... | [
"0.5811817",
"0.5779755",
"0.57320595",
"0.54729784",
"0.54105455",
"0.5389896",
"0.5379834",
"0.52935493",
"0.51974595",
"0.51733625",
"0.5172672",
"0.5158862",
"0.5145489",
"0.5135635",
"0.51277316",
"0.51220286",
"0.51147276",
"0.50854826",
"0.5080411",
"0.5066969",
"0.506... | 0.7325346 | 0 |
generator function to get randomly ordered samples of financial data | def get_examples():
symbols = get_symbols()
symbol_start_indices, total_examples = _index_symbols(symbols)
selection_order = np.arange(total_examples)
np.random.shuffle(selection_order)
for sample_index in selection_order:
# use a binary search to determine which symbol to use given the samp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_feeder_2():\n return random.sample(range(100), 10)",
"def data_source():\n dataset = [0.1, 0.2, 0.3, 0.4, 0.5]\n while True:\n time.sleep(2)\n yield random.choice(dataset)",
"def generate_samples(self, n_samples):",
"def generate_samples(self, n_samples):",
"def test_random_... | [
"0.7042209",
"0.6748927",
"0.65114784",
"0.65114784",
"0.6460016",
"0.64581263",
"0.63565946",
"0.62900376",
"0.6261254",
"0.6239399",
"0.62391174",
"0.62097275",
"0.6187463",
"0.6132192",
"0.6110315",
"0.6107518",
"0.6062251",
"0.6058275",
"0.6057489",
"0.6057019",
"0.605283... | 0.67601985 | 1 |
analyse the symbols to determine where examples can be extracted | def _index_symbols(symbols):
symbol_start_indices = []
next_start_index = 0
for symbol in symbols:
entry_count = count_entries(symbol)
if entry_count > EXAMPLE_SIZE:
symbol_start_indices.append(next_start_index)
next_start_index += entry_count - EXAMPLE_SIZE
total... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbols_details(self):\n pass",
"def symbols(self):\n pass",
"def explain(symbol):\n if isinstance(symbol, Symbolic):\n print(symbol.source)\n else: \n print(symbol)",
"def test_ex_2_1(self):\n\n wam = WAM()\n wam.execute(self.fig_2_3_instrs)\n #s = ... | [
"0.61620724",
"0.5961964",
"0.58629996",
"0.5696681",
"0.55566597",
"0.55555195",
"0.5509136",
"0.5487217",
"0.54459673",
"0.5443426",
"0.53950363",
"0.5371426",
"0.53046227",
"0.52617",
"0.5248638",
"0.5231612",
"0.5227878",
"0.5224617",
"0.5190185",
"0.5189669",
"0.5187694"... | 0.61644316 | 0 |
iterates over padded tiles of an ND image while keeping track of the slice positions | def tile_iterator(im,
blocksize = (64, 64),
padsize = (64,64),
mode = "constant",
verbose = False):
if not(im.ndim == len(blocksize) ==len(padsize)):
raise ValueError("im.ndim (%s) != len(blocksize) (%s) != len(padsize) (%s)"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll(self, image):\n\n\t\toutput = np.zeros(image.shape)\n\n\t\theight, width = image.shape\n\n\t\tfor y in range(height):\n\n\t\t\t# Getting available neighbour indexes in y direction.\n\t\t\tdelta_y_0 = abs(min(y - self.padding, 0))\n\t\t\tdelta_y_1 = min( height - 1 - y, self.padding) + self.padding + 1\n\n... | [
"0.6320081",
"0.6216814",
"0.6195147",
"0.60652786",
"0.5944742",
"0.5944742",
"0.59005415",
"0.58932716",
"0.5860595",
"0.5857728",
"0.58525264",
"0.58328336",
"0.5808904",
"0.58026594",
"0.5777165",
"0.57505",
"0.5707814",
"0.5691599",
"0.5649974",
"0.5610359",
"0.5599954",... | 0.6521748 | 0 |
Compute energy of a protein. | def compute_energy(self, protein):
return utils.score_pose(protein.pose, self.scorefxn) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy_tot(P,F,H,molecule):\n return energy_el(P,F,H) + energy_n(molecule)",
"def energy(self):\n energy = -0.5*np.sum(self.phi)+0.5*np.sum(self.mass*np.sqrt(self.particles.momentum[:,0]**2+self.particles.momentum[:,1]**2)**2)\n return energy",
"def energy(p,m):\n return math.sqrt(p*p +... | [
"0.72012615",
"0.715897",
"0.71059984",
"0.70766",
"0.70726967",
"0.70589584",
"0.7055935",
"0.70316356",
"0.69816923",
"0.6975418",
"0.6911739",
"0.67674965",
"0.67373985",
"0.67346823",
"0.6701098",
"0.6694987",
"0.66668403",
"0.66624516",
"0.6649281",
"0.664188",
"0.664176... | 0.82101876 | 0 |
Sample from possible fragments for a position, and replace torsion angles of that fragment in the protein. | def perturb_fragment(self, protein, position): # you may want to add more arguments
#check which fragments have already been sampled from the current position during the current step
chosen_indices = self.sampled_fragments[position]
fragments_to_sample_from = set(range(self.nfrags)) - c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sample_angle(self):\n active_names = (\"N\", \"CA\", \"C\", \"O\", \"CB\", \"H\", \"HA\")\n selection = self.covalent_residue.select(\"name\", active_names)\n self.covalent_residue._active = False\n self.covalent_residue._active[selection] = True\n self.covalent_residue.upda... | [
"0.5305515",
"0.5180681",
"0.51104534",
"0.5014608",
"0.48726195",
"0.48163992",
"0.4806955",
"0.47817487",
"0.4777187",
"0.47461727",
"0.47372264",
"0.47323832",
"0.46817002",
"0.46801928",
"0.46705428",
"0.46659943",
"0.4642765",
"0.46316916",
"0.4625718",
"0.46244594",
"0.... | 0.6773049 | 0 |
Anneal temperature using exponential annealing schedule. Consider kT to be a single variable (i.e. ignore Boltzmann constant) | def anneal_temp(self, T):
new_T = self.anneal_rate * T
return(new_T) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _k(self, T):\n RT = Rgas * T\n return (self.parameters.A1 / np.exp(self.parameters.E1 / RT),\n self.parameters.A2 / np.exp(self.parameters.E2 / RT))",
"def exponential(t, eta_init, last_eta, d = 0.01):\n return eta_init*np.exp(-d*t)",
"def exp(t,tau):\n return np.exp(-t/t... | [
"0.70223296",
"0.6454653",
"0.6285607",
"0.6272474",
"0.62450045",
"0.6214381",
"0.6204918",
"0.6186438",
"0.6113547",
"0.60832334",
"0.6067471",
"0.60490257",
"0.6045893",
"0.6033196",
"0.599369",
"0.5920794",
"0.5913871",
"0.5907448",
"0.58919245",
"0.5879924",
"0.5873256",... | 0.6998116 | 1 |
Run ONE full MCMC simulation from start_temp to end_temp. Be sure to save the best (lowestenergy) structure, so you can access it after. It is also a good idea to track certain variables during the simulation (temp, energy, and more). | def simulate(self):
#loop to perform additional steps until the current temperature is no longer greater than the ending_temperature
while self.current_T >= self.end_temp:
self.step(self.current_T)
#log various parameters that changed in the MCMCSampler object after... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n print(\"\\nBeginning simulation: current date and time {}\\n\".format(datetime.datetime.now()))\n\n # Initialise the particles, potential and energy array\n particles = np.random.rand(n_particles, 3) * L\n lj_pot = np.zeros((n_particles, n_particles))\n energy = np.zeros(n_steps + 1)... | [
"0.6719989",
"0.6187217",
"0.61104983",
"0.6038098",
"0.5963481",
"0.5931287",
"0.590561",
"0.58786446",
"0.5835071",
"0.5818203",
"0.5817355",
"0.5707744",
"0.56497705",
"0.5628978",
"0.56262344",
"0.5613195",
"0.559241",
"0.5558531",
"0.5554702",
"0.5552925",
"0.5549502",
... | 0.6652485 | 1 |
Calls the patient update endpoint, and returns a summary. If the update struct is None, then the method returns the list of errors that happened while trying to update this Patient data. | def post_to_endpoint_with_patient_struct(
data_set_id: int,
json_data: json,
update_path: str,
summary_schema: marshmallow.Schema = None,
commit: bool = False,
return_patient_struct: Union[PatientStruct, PcorPatientStruct] = None
) -> Tuple[Optional[object], List[str], Union[PatientStruct, PcorP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_to_endpoint(data_set_id: int,\n json_data: json,\n update_path: str,\n summary_schema: marshmallow.Schema = None,\n commit: bool = False) -> Tuple[Optional[object], List[str]]:\n result, errors, _ = post_to_endpoint_with_pati... | [
"0.5894665",
"0.5239594",
"0.49709976",
"0.49367508",
"0.492882",
"0.4927456",
"0.49062845",
"0.4904821",
"0.48947275",
"0.48865876",
"0.48839745",
"0.4856527",
"0.4836941",
"0.48353428",
"0.4834773",
"0.48274225",
"0.4799497",
"0.4790184",
"0.47784716",
"0.47743553",
"0.4772... | 0.619505 | 0 |
Posts the roster member numbers, and the medical group restriction for a specific plan to the SFE. The post will include the value of the commit which will decide whether this is a validation only operation or one that would lead to data updates. | def _post_roster_to_endpoint(
plan_id: int,
roster_member_numbers: Set[str],
restrict_to_medical_group_id: Optional[int],
commit: bool
) -> Tuple[Optional[List[str]], int, List[str]]:
#from django.conf import settings
"""if restrict_to_medical_group_id:
url = settings.SFE_URL + reverse('api_plan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateAndSendToPiggy(self):\n completion = False\n allowAction = False\n mode = self.getMode()\n selected_date = self.getActiveDate()\n dates_user_is_allowed_to_manipulate = [datetime.date.today(), self.last_working_date]\n\n if getpass.getuser() not in MOSES.getAdmi... | [
"0.5406901",
"0.53190297",
"0.52782184",
"0.51523155",
"0.5132878",
"0.49806508",
"0.49678287",
"0.4966064",
"0.4957115",
"0.49533275",
"0.49210647",
"0.491864",
"0.49109998",
"0.48907435",
"0.4886257",
"0.48517922",
"0.4844767",
"0.4843075",
"0.48355353",
"0.48208615",
"0.48... | 0.6674818 | 0 |
Check Monte Calor statistics in CheckMate output. | def checkStats(checkmateOutput):
if not os.path.isfile(checkmateOutput):
print("Files %s not found" %checkmateOutput)
return False
# Get CMS-SUS-16-032 data:
data = np.genfromtxt(checkmateOutput,names=True,
dtype=None,encoding=None)
data = np.delete(data,np.where(data['sr'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RunCheckMate(parserDict):\n t0 = time.time()\n parser = ConfigParserExt()\n parser.read_dict(parserDict)\n\n pars = parser.toDict(raw=False)[\"options\"]\n\n outputFolder = os.path.abspath(parser.get(\"CheckMateParameters\",\"OutputDirectory\"))\n resultFolder = os.path.join(outputFolder,pars... | [
"0.56708354",
"0.5640992",
"0.56023943",
"0.55943125",
"0.5556258",
"0.5549421",
"0.5529195",
"0.5498868",
"0.54936326",
"0.5493021",
"0.5483865",
"0.5482603",
"0.5474185",
"0.5457",
"0.5450003",
"0.5450003",
"0.54043716",
"0.53940886",
"0.5369571",
"0.53473234",
"0.5343286",... | 0.6516957 | 0 |
Adding existing user to project. Already has role. Should 'complete' anyway but do nothing. | def test_add_user_existing_with_role(self):
project = fake_clients.FakeProject(name="test_project")
user = fake_clients.FakeUser(
name="test@example.com", password="123", email="test@example.com"
)
assignment = fake_clients.FakeRoleAssignment(
scope={"project":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_user(username, password, email, role_type, curr_username, user_role, request_ip):\n if user_connector.check_username_availability(username):\n user_connector.add_user(username, password, email, role_type)\n log_connector.add_log('ADD USER', \"Added new user: {}\".format(username), curr_use... | [
"0.71821344",
"0.7031617",
"0.7004944",
"0.6919425",
"0.68790615",
"0.6856563",
"0.6812726",
"0.6791513",
"0.67497045",
"0.6730467",
"0.6708298",
"0.6707417",
"0.66984934",
"0.66916555",
"0.6689092",
"0.667523",
"0.6650772",
"0.6639229",
"0.6618744",
"0.6616759",
"0.6614431",... | 0.71185714 | 1 |
Ensures that when a project becomes invalid at the submit stage that the a 400 is recieved and no final emails are sent. | def test_new_project_invalid_on_submit(self):
setup_identity_cache()
url = "/v1/actions/CreateProjectAndUser"
data = {"project_name": "test_project", "email": "test@example.com"}
response = self.client.post(url, data, format="json")
self.assertEqual(response.status_code, status... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invalid_project_tye_msg(proj_type):\n return {\"error\": f\"Project type {proj_type} is not valid, please use one of the following: \"\n f\"{', '.join(project_types)}\"}, 400",
"def test_pypi_not_200(self):\n form = self._get_form()\n self.assertFalse(self._validate_form(... | [
"0.6262488",
"0.622149",
"0.6171945",
"0.6151178",
"0.6124826",
"0.60645145",
"0.60137534",
"0.59481496",
"0.5908061",
"0.5797568",
"0.5786521",
"0.573891",
"0.57307863",
"0.57101095",
"0.5647287",
"0.5620445",
"0.5609429",
"0.559986",
"0.559503",
"0.5592268",
"0.5590574",
... | 0.6476846 | 0 |
Project created if not present, existing user attached. No token should be needed. | def test_new_project_existing_user(self):
user = fake_clients.FakeUser(
name="test@example.com", password="123", email="test@example.com"
)
setup_identity_cache(users=[user])
# unauthenticated sign up as existing user
url = "/v1/actions/CreateProjectAndUser"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_new_project_existing(self):\n\n project = fake_clients.FakeProject(name=\"test_project\")\n\n setup_identity_cache(projects=[project])\n\n url = \"/v1/actions/CreateProjectAndUser\"\n data = {\"project_name\": \"test_project\", \"email\": \"test@example.com\"}\n response... | [
"0.7299471",
"0.7234782",
"0.7076508",
"0.7017567",
"0.6992709",
"0.69262415",
"0.68911916",
"0.6865844",
"0.6858165",
"0.68420464",
"0.6831582",
"0.6794033",
"0.6789412",
"0.6783985",
"0.67498165",
"0.6747258",
"0.6734577",
"0.6734577",
"0.6734577",
"0.6723486",
"0.6712834",... | 0.75843513 | 0 |
CreateProjectAndUser should create a notification. We should be able to grab it. | def test_notification_CreateProjectAndUser(self):
setup_identity_cache()
url = "/v1/actions/CreateProjectAndUser"
data = {"project_name": "test_project", "email": "test@example.com"}
response = self.client.post(url, data, format="json")
self.assertEqual(response.status_code, sta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_successfully_create_notifications(self):\n pre_function_notifications = Notification.objects.all()\n self.assertEqual(len(pre_function_notifications), 0)\n\n create_notification(\n user=self.user_with_targets,\n title=\"Hi.\",\n body=\"Hello there, fri... | [
"0.6984443",
"0.6352937",
"0.62960654",
"0.62762576",
"0.6200471",
"0.6186733",
"0.6161037",
"0.6132949",
"0.613171",
"0.6121216",
"0.61175996",
"0.6106454",
"0.6106454",
"0.6106454",
"0.6099714",
"0.6092147",
"0.60814804",
"0.6060918",
"0.60601914",
"0.6047661",
"0.6045657",... | 0.8151886 | 0 |
Ensure the update email workflow goes as expected. Create task, create token, submit token. | def test_update_email_task(self):
user = fake_clients.FakeUser(
name="test@example.com", password="123", email="test@example.com"
)
setup_identity_cache(users=[user])
url = "/v1/actions/UpdateEmail"
headers = {
"project_name": "test_project",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_email_task_send_email_current_name_not_email(self):\n\n user = fake_clients.FakeUser(\n name=\"nkdfslnkls\", password=\"123\", email=\"test@example.com\"\n )\n\n setup_identity_cache(users=[user])\n\n url = \"/v1/actions/UpdateEmail\"\n headers = {\n ... | [
"0.6641487",
"0.65933645",
"0.63793033",
"0.5988052",
"0.58915395",
"0.5823073",
"0.5801181",
"0.56437814",
"0.5622126",
"0.556626",
"0.5563945",
"0.5509865",
"0.55096465",
"0.5467318",
"0.54488516",
"0.54419976",
"0.54326904",
"0.5379935",
"0.53690886",
"0.5351489",
"0.53484... | 0.72772837 | 0 |
Tests the sending of additional emails to a set of roles in a project | def test_additional_emails_roles(self):
# NOTE(amelia): sending this email here is probably not the intended
# case. It would be more useful in utils such as a quota update or a
# child project being created that all the project admins should be
# notified of
project = fake_cli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_additional_emails_role_no_email(self):\n\n project = fake_clients.FakeProject(name=\"test_project\")\n\n user = fake_clients.FakeUser(\n name=\"test@example.com\", password=\"123\", email=\"test@example.com\"\n )\n\n assignment = fake_clients.FakeRoleAssignment(\n ... | [
"0.77477735",
"0.7315475",
"0.6827417",
"0.66901034",
"0.66202974",
"0.6550147",
"0.6497265",
"0.64453137",
"0.6418991",
"0.6414361",
"0.64034605",
"0.6370533",
"0.62843436",
"0.6227989",
"0.62265706",
"0.6219871",
"0.6216618",
"0.61955845",
"0.61282665",
"0.6121579",
"0.6121... | 0.8471276 | 0 |
The additional email actions should not send an email if the action is invalid. | def test_email_additional_action_invalid(self):
setup_identity_cache()
url = "/v1/actions/InviteUser"
headers = {
"project_name": "test_project",
"project_id": "test_project_id",
"roles": "project_admin,member,project_mod",
"username": "test@exam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_email_disabled(self):\r\n test_email = {\r\n 'action': 'Send email',\r\n 'send_to': 'myself',\r\n 'subject': 'test subject for myself',\r\n 'message': 'test message for myself'\r\n }\r\n response = self.client.post(self.send_mail_url, test_e... | [
"0.65730184",
"0.6376346",
"0.62104857",
"0.6187945",
"0.60576475",
"0.59244066",
"0.59205645",
"0.5912073",
"0.58782667",
"0.58319366",
"0.58272535",
"0.5803269",
"0.5791973",
"0.57378376",
"0.57144916",
"0.571216",
"0.57079375",
"0.5701372",
"0.56703043",
"0.5663843",
"0.56... | 0.7289466 | 0 |
When can_edit_users is false, and a new user is invited, the task should be marked as invalid if the user doesn't already exist. | def test_user_invite_cant_edit_users(self):
project = fake_clients.FakeProject(name="test_project")
setup_identity_cache(projects=[project])
url = "/v1/actions/InviteUser"
headers = {
"project_name": "test_project",
"project_id": project.id,
"roles":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_invite_cant_edit_users_existing_user(self):\n project = fake_clients.FakeProject(name=\"test_project\")\n\n user = fake_clients.FakeUser(name=\"test@example.com\")\n\n setup_identity_cache(projects=[project], users=[user])\n\n url = \"/v1/actions/InviteUser\"\n head... | [
"0.70514643",
"0.64830637",
"0.6148935",
"0.6148552",
"0.61462927",
"0.6118526",
"0.60407144",
"0.59387314",
"0.5936648",
"0.5901571",
"0.589283",
"0.58872414",
"0.57998174",
"0.57644355",
"0.5719481",
"0.5709963",
"0.5695988",
"0.5656522",
"0.5620688",
"0.5614186",
"0.560636... | 0.661029 | 1 |
When can_edit_users is false, and a new user is invited, the task should be marked as valid if the user exists. | def test_user_invite_cant_edit_users_existing_user(self):
project = fake_clients.FakeProject(name="test_project")
user = fake_clients.FakeUser(name="test@example.com")
setup_identity_cache(projects=[project], users=[user])
url = "/v1/actions/InviteUser"
headers = {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_anonymous_user_update_user_taskrun(self):\r\n with self.flask_app.test_request_context('/'):\r\n user_taskrun = TaskRunFactory.create()\r\n\r\n assert_raises(Unauthorized,\r\n getattr(require, 'taskrun').update,\r\n user_taskru... | [
"0.66174513",
"0.6601052",
"0.6384289",
"0.6334532",
"0.621152",
"0.61806226",
"0.61534464",
"0.6063311",
"0.6060537",
"0.6060164",
"0.6044851",
"0.60244834",
"0.59576625",
"0.594278",
"0.59351856",
"0.5911798",
"0.5905776",
"0.5897276",
"0.5896448",
"0.5874475",
"0.5834748",... | 0.70513034 | 0 |
When can_edit_users is false, and a new signup comes in, the task should be marked as invalid if it needs to create a new user. Will return OK (as task doesn't auto_approve), but task will actually be invalid. | def test_project_create_cant_edit_users(self):
setup_identity_cache()
url = "/v1/actions/CreateProjectAndUser"
data = {"project_name": "test_project", "email": "test@example.com"}
response = self.client.post(url, data, format="json")
self.assertEqual(response.status_code, status... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_project_create_cant_edit_users_existing_user(self):\n user = fake_clients.FakeUser(name=\"test@example.com\")\n\n setup_identity_cache(users=[user])\n\n url = \"/v1/actions/CreateProjectAndUser\"\n data = {\"project_name\": \"test_project\", \"email\": \"test@example.com\"}\n ... | [
"0.66085404",
"0.64380985",
"0.640038",
"0.62846017",
"0.6143267",
"0.61050075",
"0.6069316",
"0.60530555",
"0.5980463",
"0.5970805",
"0.59477574",
"0.59021604",
"0.5873239",
"0.58261275",
"0.5819795",
"0.57675356",
"0.5758916",
"0.5753213",
"0.5694632",
"0.5676942",
"0.56321... | 0.65307754 | 1 |
When can_edit_users is false, and a new signup comes in, the task should be marked as valid if the user already exists. Will return OK (as task doesn't auto_approve), but task will actually be valid. | def test_project_create_cant_edit_users_existing_user(self):
user = fake_clients.FakeUser(name="test@example.com")
setup_identity_cache(users=[user])
url = "/v1/actions/CreateProjectAndUser"
data = {"project_name": "test_project", "email": "test@example.com"}
response = self.cl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_admin_approval(self):\n\n new_user = self.registration_profile.objects.create_inactive_user(\n site=Site.objects.get_current(), **self.user_info)\n profile = self.registration_profile.objects.get(user=new_user)\n user, activated = self.registration_profile.objects.act... | [
"0.6319128",
"0.62552834",
"0.61908275",
"0.615733",
"0.61488724",
"0.60932577",
"0.60647994",
"0.6049347",
"0.59604836",
"0.5944117",
"0.59132886",
"0.59021646",
"0.5847654",
"0.5742341",
"0.5733471",
"0.5727593",
"0.56754845",
"0.5663465",
"0.56541914",
"0.5634608",
"0.5605... | 0.6379207 | 0 |
Set up form data. | def setUpFormData(self):
self.formData = {'labGroup': '5', 'abbrev': 'etoh', 'name': 'ethanol', 'CAS_ID': '64-17-5', 'CSID': '682',
'chemicalClasses': [ChemicalClass.objects.get(label='Solv').pk]} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n self.user = User.objects.get(username='Aslan')\n self.user.save()\n self.setUpFormData()\n self.form = CompoundForm(self.user, self.formData)",
"def initial_form_data(self, request, step, form):\n return None",
"def set_form(self, form):\n self.param... | [
"0.68016547",
"0.6669204",
"0.6392889",
"0.62460214",
"0.62324643",
"0.6223161",
"0.61881846",
"0.61854374",
"0.61827356",
"0.6179994",
"0.61214954",
"0.60462725",
"0.60309213",
"0.60309213",
"0.6017674",
"0.6009395",
"0.5995892",
"0.59803677",
"0.5944125",
"0.59229565",
"0.5... | 0.6727658 | 1 |
Set up lab group for tests. | def setUp(self):
self.labGroup = LabGroup.objects.makeLabGroup(
title="LegacyPassTest1", address='1, war drobe, Narnia', email='aslan@example.com', access_code='old_magic')
self.labGroup.save()
super(NoLabForUser, self).setUp() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n self.labGroup = LabGroup.objects.makeLabGroup(\n 'test', 'War Drobe', 'aslan@example.com', 'ancient_magic')\n self.labGroup.save()\n self.labGroup.users.add(User.objects.get(username='Aslan'))\n self.labGroup.save()\n self.response = self.s.get(self.... | [
"0.6833717",
"0.6591932",
"0.6449999",
"0.63306993",
"0.630889",
"0.62895",
"0.62602586",
"0.6256517",
"0.62400544",
"0.6221543",
"0.6106464",
"0.6106464",
"0.61008394",
"0.60976285",
"0.6095497",
"0.60188913",
"0.60178053",
"0.60139465",
"0.6004077",
"0.59957445",
"0.5973466... | 0.68219155 | 1 |
Make sure that saving a valid form works. | def test_saving(self):
if self.form.is_valid():
self.compound = self.form.save()
self.assertIsNotNone(self.compound.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_valid(self, form):\n form.save()\n return super().form_valid(form)",
"def form_valid(self, form, factura_form, remito_form, ot_linea_form):\n form.save()\n factura_form.save()\n remito_form.save()\n ot_linea_form.save()\n return HttpResponseRedirect(self.... | [
"0.68990594",
"0.68580776",
"0.6716657",
"0.6689772",
"0.66768503",
"0.65493596",
"0.6530574",
"0.64837015",
"0.64713764",
"0.64713764",
"0.6424546",
"0.64115185",
"0.6370163",
"0.63618284",
"0.6353641",
"0.63391066",
"0.6338812",
"0.6329545",
"0.6305311",
"0.62634265",
"0.62... | 0.7100611 | 0 |
Get data for the form and remove the CAS number. | def setUpFormData(self):
super(NoCAS, self).setUpFormData()
self.formData['CAS_ID'] = '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_field(self, url, data):\r\n while data != []:\r\n for field in data:\r\n if 'id' in field:\r\n requests.delete(url + str(field['id']), headers=self.headers)\r\n data.clear()\r\n data = requests.get(url, headers=self.headers).json(... | [
"0.56692374",
"0.56033903",
"0.55418986",
"0.5272646",
"0.5236702",
"0.52326304",
"0.5222763",
"0.5213981",
"0.5182077",
"0.5145639",
"0.5117664",
"0.5114514",
"0.51122105",
"0.5094855",
"0.5049387",
"0.50321674",
"0.5010105",
"0.49786502",
"0.49755615",
"0.49728656",
"0.4969... | 0.6313918 | 0 |
Create inconsistency between CAS number and name. | def setUpFormData(self):
super(InconsistentCASName, self).setUpFormData()
self.formData['CAS_ID'] = '290-37-9'
self.formData['CSID'] = '8904' # consistent values for pyrazine. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self, cr, user, vals, context=None):\n if ('name' not in vals) or (vals.get('name')=='/'): \n vals['name'] = self.pool.get('ir.sequence').get(cr, user, 'services.contracts.archive')\n return super(env_and_safety_allowances_archive, self).create(cr, user, vals, context)",
"def... | [
"0.55365926",
"0.5442971",
"0.5290361",
"0.52699053",
"0.52344525",
"0.5213541",
"0.51775724",
"0.5171424",
"0.5146217",
"0.5143811",
"0.5137238",
"0.5084902",
"0.505352",
"0.5047763",
"0.5042051",
"0.49853882",
"0.49819195",
"0.49509123",
"0.49481195",
"0.4940359",
"0.494035... | 0.5477288 | 1 |
feat =feature input_zone_polygon = shpF input_value_raster = trainF band = 1 coords=[commonBox[0], commonBox[2], commonBox[3], commonBox[1]] | def get_zone_pixels(feat, input_zone_polygon, input_value_raster, band, coords=[]): #, raster_band
# Open data
raster = gdal.Open(input_value_raster)
shp = ogr.Open(input_zone_polygon)
lyr = shp.GetLayer()
# Get raster georeference info
transform = raster.GetGeoTransform()
xOrigin = transform[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spatial(self):",
"def mainFunction(f):\n\n #############################################################################\n \n \n # biomass hexagon\n predF = '/vol/v3/lt_stem_v3.1/models/biomassfiaald_20180708_0859/2000/biomassfiaald_20180708_0859_2000_mean.tif'\n trainF = '/vol/v2/datasets/biomass/nbcd... | [
"0.61735",
"0.6161118",
"0.60565156",
"0.5746852",
"0.57418066",
"0.5684454",
"0.55834466",
"0.55502355",
"0.54894286",
"0.54626876",
"0.5461146",
"0.54364747",
"0.5411424",
"0.540842",
"0.53969634",
"0.5377036",
"0.5342902",
"0.5341299",
"0.5308774",
"0.5307411",
"0.52977175... | 0.6667705 | 0 |
biomass predF = '/vol/v3/lt_stem_v3.1/models/biomassfiaald_20180708_0859/2000/biomassfiaald_20180708_0859_2000_mean.tif' trainF = '/vol/v2/datasets/biomass/nbcd/fia_ald/nbcd_fia_ald_biomass_clipped_to_conus.tif' shpF = '/vol/v2/datasets/Eco_Level_III_US/us_eco_l3_no_states_multipart.shp' trainND = 32768 predND = 9999 t... | def mainFunction(f):
#############################################################################
# biomass hexagon
predF = '/vol/v3/lt_stem_v3.1/models/biomassfiaald_20180708_0859/2000/biomassfiaald_20180708_0859_2000_mean.tif'
trainF = '/vol/v2/datasets/biomass/nbcd/fia_ald/nbcd_fia_ald_biomass_clippe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config1() :\n data_name = \"titanic\" ### in data/input/\n model_class = 'AutoML' ### ACTUAL Class name for model_sklearn.py\n n_sample = 1000\n\n def post_process_fun(y): ### After prediction is done\n return int(y)\n\n def pre_process_fun(y): ### Before the predic... | [
"0.5751322",
"0.5728104",
"0.57214856",
"0.57079554",
"0.56615245",
"0.56354",
"0.5628345",
"0.5622833",
"0.5618916",
"0.55971026",
"0.5592311",
"0.5569166",
"0.5569091",
"0.55580115",
"0.5518776",
"0.5511118",
"0.55083716",
"0.55061144",
"0.5489924",
"0.5489006",
"0.54695773... | 0.6835519 | 0 |
Determines if previous minimum skew and/or kurtosis should be replaced. | def checkMin(oldskew,oldkurt,newskew,newkurt,oldtransform,newtransform):
if (newskew < oldskew and newkurt < oldkurt) or (newkurt < oldkurt and (newskew-oldskew) < 2.0*(oldkurt-newkurt) ):
return (newskew,newkurt,newtransform)
elif newskew < oldskew:
return (oldskew,oldkurt,oldtransform)
eli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def support_skewed(self):\n\t\tif all([item in self.__class__.__dict__ for item in ['init_agg','last_agg','finalize']]):\n\t\t\treturn True\n\t\telse:\n\t\t\treturn False",
"def accept_move(misfit_current, likelihood_current, misfit_proposednext):\n if misfit_proposednext <= misfit_current:\n return Tr... | [
"0.56515265",
"0.55337745",
"0.5429516",
"0.5419026",
"0.53508544",
"0.53044164",
"0.52709705",
"0.52291274",
"0.51787686",
"0.5175725",
"0.5167837",
"0.5161958",
"0.5158973",
"0.51454186",
"0.51088625",
"0.5101634",
"0.5093021",
"0.50878626",
"0.50746673",
"0.5050008",
"0.50... | 0.60877913 | 0 |
List storage accounts within a subscription or resource group. | def list_storage_accounts(resource_group_name=None):
scf = storage_client_factory()
if resource_group_name:
accounts = scf.storage_accounts.list_by_resource_group(resource_group_name)
else:
accounts = scf.storage_accounts.list()
return list(accounts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_storage_account_list(credentials: Credentials, subscription_id: str) -> List[Dict]:\n try:\n client = get_client(credentials, subscription_id)\n storage_account_list = list(map(lambda x: x.as_dict(), client.storage_accounts.list()))\n\n # ClientAuthenticationError and ResourceNotFoundEr... | [
"0.7320318",
"0.6651165",
"0.62439924",
"0.6184162",
"0.6145911",
"0.59039",
"0.58671045",
"0.5840274",
"0.57441765",
"0.5728142",
"0.5645398",
"0.5636501",
"0.5627045",
"0.56266147",
"0.56164116",
"0.5569306",
"0.5560969",
"0.5537345",
"0.55020845",
"0.54901856",
"0.5486767"... | 0.82980007 | 0 |
Show the current count and limit of the storage accounts under the subscription. | def show_storage_account_usage():
scf = storage_client_factory()
return next((x for x in scf.usage.list() if x.name.value == 'StorageAccounts'), None) # pylint: disable=no-member | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_space(access_token):\n client = dropbox.client.DropboxClient(access_token)\n account_info = client.account_info()\n quota_info = account_info['quota_info']\n total = quota_info['quota']\n used = quota_info['normal'] + quota_info['shared']\n return total - used",
"def getAccountSize(... | [
"0.626172",
"0.5928219",
"0.5769423",
"0.56741863",
"0.5654431",
"0.5513493",
"0.53687006",
"0.536599",
"0.53284514",
"0.53220856",
"0.5245537",
"0.52425355",
"0.5240312",
"0.52386",
"0.5236853",
"0.5233157",
"0.5226607",
"0.52219427",
"0.52179664",
"0.5215547",
"0.5200623",
... | 0.71497154 | 0 |
Create a stored access policy on the containing object | def create_acl_policy(client, container_name, policy_name, start=None, expiry=None,
permission=None, **kwargs):
acl = _get_acl(client, container_name, **kwargs)
acl[policy_name] = AccessPolicy(permission, expiry, start)
if hasattr(acl, 'public_access'):
kwargs['public_access'] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_restricted_policy(environ, bag):\n username = environ['tiddlyweb.usersign']['name']\n if username == 'GUEST':\n return\n bag.policy.owner = username\n # accept does not matter here\n for constraint in ['read', 'write', 'create', 'delete', 'manage']:\n setattr(bag.policy, const... | [
"0.6120522",
"0.5991837",
"0.5977101",
"0.58240104",
"0.5799434",
"0.5770939",
"0.5763552",
"0.5759775",
"0.5733948",
"0.56609756",
"0.5627171",
"0.56185126",
"0.56121063",
"0.56093913",
"0.55592847",
"0.5555371",
"0.55546874",
"0.55378443",
"0.5524767",
"0.5518799",
"0.55019... | 0.6184479 | 0 |
Adding the semicircles so that i can use the tangent thing | def addSemicircles(self):
#axes setup
self.setup_axes(animate=False)
self.axes.move_to(ORIGIN)
self.axes.shift(LEFT*5)
#equations of circle
global equation_upper, equation_lower
equation_upper = lambda x : math.sqrt((self.x_max)**2 - x**2)
equatio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawTangents(self):\n #bigger tangent\n global big_tangent\n big_tangent = always_redraw(\n lambda : self.get_secant_slope_group(self.x_max * np.cos(theta.get_value()*DEGREES), graph_upper,\n dx=0.001, secant_line_color=RED, secant_... | [
"0.6511479",
"0.63582504",
"0.62292373",
"0.62292373",
"0.60392404",
"0.6029207",
"0.59928757",
"0.5986355",
"0.5939926",
"0.5861232",
"0.5858033",
"0.58485687",
"0.5816202",
"0.58137244",
"0.57763934",
"0.57530665",
"0.5727165",
"0.57132226",
"0.57070947",
"0.56994355",
"0.5... | 0.778817 | 0 |
Drawing the tangent to the circle at the point defined by theta from above | def drawTangents(self):
#bigger tangent
global big_tangent
big_tangent = always_redraw(
lambda : self.get_secant_slope_group(self.x_max * np.cos(theta.get_value()*DEGREES), graph_upper,
dx=0.001, secant_line_color=RED, secant_line_lengt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tangent_circle(dist, radius):\n if dist < 3 * radius:\n if dist >= radius:\n return math.asin(radius/float(dist))\n return math.radians(100)\n return None",
"def tangent(self, p):\n p = array(p, float)\n v = (p - self.o)\n v /= norm(v)\n b = self.o +... | [
"0.68210936",
"0.68082553",
"0.6468239",
"0.6416218",
"0.63939244",
"0.6283899",
"0.6283792",
"0.62334484",
"0.6202951",
"0.6202951",
"0.61995333",
"0.6194441",
"0.61483556",
"0.6142514",
"0.6130193",
"0.6118884",
"0.60151887",
"0.6007657",
"0.5992",
"0.5975721",
"0.59291214"... | 0.6885991 | 0 |
text for Consider the following areas | def considerAreasText(self):
global consider_area_text
consider_area_text = MathTex("\\text{Consider the following areas:}").scale(0.8).shift(RIGHT*3.55)
self.play(Write(consider_area_text))
self.play(consider_area_text.animate.to_edge(UP)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_formatted_text(self, n_cols):",
"def text(self, str: str, x: int, y: int, colour: int, /) -> None:",
"def plot_area_text(data_obj, test_num, yi, xpos, ha, va, fs, dfs):\n\n plt.text(xpos[0], yi, 'Test ' + str(test_num) + ': Image area', ha=ha, va=va, fontsize=fs)\n str1 = str(data_obj.image_area[... | [
"0.64041543",
"0.6377654",
"0.632749",
"0.62660927",
"0.6217415",
"0.6127728",
"0.6065138",
"0.6050231",
"0.60372806",
"0.60256594",
"0.60008544",
"0.5952757",
"0.58686084",
"0.58307946",
"0.5816903",
"0.5807217",
"0.579291",
"0.57903117",
"0.5766726",
"0.57592934",
"0.572776... | 0.73524785 | 0 |
outline and move shaded shapes | def areasShaded(self):
global area_ABE
area_ABE = always_redraw(
lambda : Polygon(dot_center.get_center(), radius_ang_end_dot.get_center(), dropped_dot.get_center(),
color=PINK, fill_color=PINK, fill_opacity=0.5)
)
global area_ABE_copy
area_ABE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shapes():\r\n turtle.up()\r\n turtle.forward(500)\r\n turtle.down()\r\n draw_hexagon()\r\n draw_square()\r\n draw_triangle()",
"def draw(self):\n arcade.draw_rectangle_outline(self.position_x, self.position_y, self.radius, self.color)",
"def draw_housing():\n tess.pensize(3)\n ... | [
"0.62152916",
"0.605251",
"0.5987781",
"0.59800446",
"0.59738743",
"0.59658647",
"0.5955795",
"0.5951562",
"0.5947045",
"0.59127516",
"0.5882004",
"0.57984614",
"0.57946116",
"0.57875484",
"0.5787153",
"0.5785315",
"0.5783228",
"0.57493037",
"0.5746614",
"0.57459676",
"0.5742... | 0.61928725 | 1 |
Pass through to provider supports_catalog_lookup | def supports_catalog_lookup(self):
# Implemented from kitosid template for -
# osid.resource.ResourceProfile.supports_resource_lookup
return self._provider_manager.supports_catalog_lookup() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_catalog_lookup(self):\n return False",
"def can_lookup_catalogs(self):\n # Implemented from kitosid template for -\n # osid.resource.BinLookupSession.can_lookup_bins_template\n return self._get_provider_session('catalog_lookup_session').can_lookup_catalogs()",
"def supp... | [
"0.8455877",
"0.74303055",
"0.73249394",
"0.7083447",
"0.7081553",
"0.66690326",
"0.6332474",
"0.6311813",
"0.62990963",
"0.6292647",
"0.6251142",
"0.6241391",
"0.6225812",
"0.62206495",
"0.61305606",
"0.61151016",
"0.60950756",
"0.6028557",
"0.6013458",
"0.5988211",
"0.59430... | 0.81521475 | 1 |
Pass through to provider supports_catalog_query | def supports_catalog_query(self):
# Implemented from kitosid template for -
# osid.resource.ResourceProfile.supports_resource_lookup
return self._provider_manager.supports_catalog_query() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_catalog_query(self):\n return False",
"def supports_catalog_search(self):\n return False",
"def supports_catalog_lookup(self):\n return False",
"def can_search_catalogs(self):\n # Implemented from kitosid template for -\n # osid.resource.BinQuerySession.can_sea... | [
"0.8465524",
"0.7281689",
"0.676633",
"0.65632665",
"0.65460175",
"0.64406174",
"0.6404225",
"0.6212126",
"0.60509926",
"0.6010541",
"0.5995206",
"0.59924567",
"0.5951385",
"0.5943247",
"0.59163135",
"0.58023816",
"0.5785838",
"0.57586443",
"0.5726331",
"0.5713541",
"0.570034... | 0.8171043 | 1 |
Pass through to provider supports_catalog_admin | def supports_catalog_admin(self):
# Implemented from kitosid template for -
# osid.resource.ResourceProfile.supports_resource_lookup
return self._provider_manager.supports_catalog_admin() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_catalog_admin(self):\n return False",
"def supports_catalog(self):\n return False",
"def can_manage_catalog_aliases(self):\n # Implemented from kitosid template for -\n # osid.resource.ResourceAdminSession.can_manage_resource_aliases_template\n return self._get_p... | [
"0.8499521",
"0.69093174",
"0.64641404",
"0.6397634",
"0.637139",
"0.63698316",
"0.6339752",
"0.6287508",
"0.6243115",
"0.61334854",
"0.613139",
"0.61088973",
"0.5999095",
"0.58882666",
"0.5790415",
"0.5744554",
"0.5735928",
"0.5668989",
"0.5656294",
"0.5648281",
"0.5647352",... | 0.8258288 | 1 |
Pass through to provider supports_catalog_hierarchy | def supports_catalog_hierarchy(self):
# Implemented from kitosid template for -
# osid.resource.ResourceProfile.supports_resource_lookup
return self._provider_manager.supports_catalog_hierarchy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_catalog_hierarchy(self):\n return False",
"def supports_catalog_hierarchy_design(self):\n # Implemented from kitosid template for -\n # osid.resource.ResourceProfile.supports_resource_lookup\n return self._provider_manager.supports_catalog_hierarchy_design()",
"def supp... | [
"0.8542173",
"0.7900961",
"0.78329295",
"0.77603096",
"0.69218767",
"0.6636653",
"0.660969",
"0.65671676",
"0.64564717",
"0.6446212",
"0.64374375",
"0.64101064",
"0.63792163",
"0.6251547",
"0.61963934",
"0.619614",
"0.60602677",
"0.60574764",
"0.60287905",
"0.5977223",
"0.597... | 0.8349393 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.