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 |
|---|---|---|---|---|---|---|
get notes, you can either copy to a sync folder or download to local | def getnotes(): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNotes(self, request, global_params=None):\n config = self.GetMethodConfig('GetNotes')\n return self._RunMethod(\n config, request, global_params=global_params)",
"async def _view_all_notes(self, ctx: Context):\n\n author = ctx.author\n\n note_infos = []\n\n embed_li... | [
"0.6348131",
"0.62294436",
"0.6095098",
"0.6090929",
"0.5969424",
"0.5913103",
"0.58877283",
"0.5875533",
"0.587039",
"0.5755032",
"0.57102007",
"0.5685677",
"0.5674463",
"0.5654117",
"0.5636658",
"0.5633647",
"0.56146985",
"0.5590802",
"0.5529989",
"0.55236137",
"0.5484942",... | 0.7081106 | 0 |
Find next node of a given node in a BST. | def next_node(node):
# is root
if not node.parent:
return _min_node(node.right)
# is subtree and is left
if node.parent.left == node:
if not node.right:
return node.parent
return _min_node(node.right)
# is subtree and is right
return node.parent.parent | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_node(node):\n\n if node.right_child is not None:\n # First case: ``node`` has right child, the next node is in the subtree\n # rooted at the right child, and it is leftmost node in this subtree.\n current_node = node.right_child\n while current_node.left_child is not Non... | [
"0.74567485",
"0.7090742",
"0.6928549",
"0.68795377",
"0.67899877",
"0.6764543",
"0.669973",
"0.65375566",
"0.6487014",
"0.6486642",
"0.64003444",
"0.6399026",
"0.639506",
"0.63792956",
"0.6377282",
"0.63366306",
"0.63348866",
"0.63336825",
"0.6327812",
"0.62818664",
"0.62653... | 0.76324075 | 0 |
Return the min node of a BST subtree. | def _min_node(node):
if not node:
return None
i = node
while i.left:
i = i.left
return i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_min(self) -> TreeNode:\n node = self.root\n while True:\n if not node.left:\n return node\n node = node.left",
"def _find_smallest(node):\n if node.left:\n return BinarySearchTree._find_smallest(node.left)\n else:\n r... | [
"0.8181223",
"0.7754536",
"0.7699864",
"0.7666253",
"0.7632981",
"0.76130587",
"0.7516755",
"0.75156",
"0.7462528",
"0.7420651",
"0.73975736",
"0.73489773",
"0.7188644",
"0.7147024",
"0.71064144",
"0.7091051",
"0.70677614",
"0.706635",
"0.70491433",
"0.7002115",
"0.69909126",... | 0.79107755 | 1 |
uses a set for duplicates, the dict is for frequencies only instead of an array of dicts separates each window length into an algorithm chunk (sliding window) 3x faster than clumpFinder() but still slow (many redundant operations!) | def chunkedClumpFinder(sequence, k, L, t):
frequentPatterns = set([])
for i in range(len(sequence)):
window = sequence[i:i + L]
frequencies = {}
for j in range(len(window)):
pattern = window[j:j + k]
if pattern not in frequencies:
frequencies[pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_of_sets(l):\r\n distinct_sweets = set(l) #let's find all distinct sweets from input list\r\n dict_of = {} #empty dict to store key:value (sweet:number of occurrences)\r\n\r\n for i in distinct_sweets:\r\n dict_of[i] = l.count(i)\r\n \r\n key_min = min(dict_of.keys(), key=(lambda k... | [
"0.63687587",
"0.6196125",
"0.6118355",
"0.6066688",
"0.60510707",
"0.603749",
"0.6013759",
"0.5971861",
"0.59603256",
"0.5899018",
"0.5868384",
"0.58586293",
"0.58455414",
"0.5835125",
"0.5807947",
"0.5777659",
"0.5767623",
"0.57562715",
"0.57500553",
"0.5744204",
"0.5737346... | 0.63872755 | 0 |
Optimize log(params) to fit model to data using the BFGS method. This optimization method works well when we start reasonably close to the optimum. It is best at burrowing down a single minimum. Because this works in log(params), it cannot explore values of params < 0. It should also perform better when parameters rang... | def optimize_log(p0, data, model_func, pts, lower_bound=None, upper_bound=None,
verbose=0, flush_delay=0.5, epsilon=1e-3,
gtol=1e-5, multinom=True, maxiter=None, full_output=False,
func_args=[], func_kwargs={}, fixed_params=None, ll_scale=1,
output_fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maximize_loglik(model_params: Union[CupidParams, CupidParamsCSHeteroxy, CupidParamsFcmnl],\n x_init: np.ndarray,\n lower: Optional[np.ndarray] = None,\n upper: Optional[np.ndarray] = None,\n checkgrad: Optional[bool] = False,\n ... | [
"0.65304214",
"0.64780915",
"0.6177655",
"0.6161781",
"0.61599773",
"0.60868424",
"0.60741144",
"0.6044265",
"0.60271394",
"0.60215414",
"0.60146534",
"0.59783334",
"0.5933783",
"0.59062",
"0.5886293",
"0.5869606",
"0.58289564",
"0.5819565",
"0.5812694",
"0.5792707",
"0.57897... | 0.6719574 | 0 |
Drops records from the dataframe df is var1 is greater than var2 For example, if var1 is spending on clothing and var2 is total income it is not logical that var1 is greater than var2 | def drop_illogical(df,var1,var2):
#Mask the illogical entries
mask = df[var1]>df[var2]
#Record the number of entries
NumRecords = df.shape[0]
#drop the illogical entries
df = df[df.keys()][~mask]
#Notify the user how many records were dropped
print('{} records dropped because {} ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_outliers(df, var):\n import numpy as np\n \n df = df.copy()\n \n # remove outliers\n Q1 = np.nanquantile(df[var] ,0.25)\n Q3 = np.nanquantile(df[var], 0.75)\n IQR = Q3 - Q1\n \n lower_end = Q1 - 1.5 * IQR \n high_end = Q3 + 1.5 * IQR \n \n df_filtered = df.drop(df[(... | [
"0.61005276",
"0.6079517",
"0.589066",
"0.5799702",
"0.5617992",
"0.55075836",
"0.5503977",
"0.55010396",
"0.55010396",
"0.54976255",
"0.5436637",
"0.54360694",
"0.5389384",
"0.53594834",
"0.535714",
"0.535346",
"0.5332813",
"0.53143257",
"0.5292683",
"0.5286526",
"0.52819777... | 0.7170435 | 0 |
This function (initiated by clicking the "Upload Tariff File" button) brings up a file browser window and lets the user select a tariff csv file to import into the tool. After successfully selecting a file to upload, the function reads the file into a pandas data frame, calls the validate_tariff() function to ensure th... | def uploaddata(self):
self.filename = filedialog.askopenfilename(filetypes=[('CSV', '*.csv')],
initialdir='./Tariffs')
if self.filename: # don't try to import anything if filename is empty
self.data = pd.read_csv(self.filename)
self.validate_tariff() # TODO: build out contingency when validati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_file(self):\n self.master.switch_frame(UploadFileView)",
"def start_upload(self):\n filename = filedialog.askopenfilename(filetypes=[('Data Frame files', '.csv .xls .xlsx .data .json .xsl .txt')],\n title='Select data frame file')\n if ... | [
"0.57963634",
"0.5779103",
"0.57500017",
"0.57128847",
"0.56889844",
"0.56412196",
"0.55905133",
"0.5528796",
"0.55150217",
"0.539664",
"0.53774077",
"0.5343562",
"0.5332065",
"0.5328703",
"0.53249145",
"0.5309067",
"0.52954215",
"0.5286032",
"0.5284576",
"0.5274875",
"0.5272... | 0.71449256 | 0 |
This function contains the tests required to validate that a tariff data frame is valid | def validate_tariff(self):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upload_to_df(upload_dataframe: pd.DataFrame) -> None:\n validated = UploadCollection.from_dataframe(upload_dataframe)\n assert upload_dataframe.equals(validated.to_dataframe()[upload_dataframe.columns])",
"def verify_pandas(self):\n self.check_dataset_duplicate_ids(self.vertices)\n #... | [
"0.6895882",
"0.62581795",
"0.62322396",
"0.62277174",
"0.61887205",
"0.6177782",
"0.6155625",
"0.6149133",
"0.6099006",
"0.6096892",
"0.6054584",
"0.6043061",
"0.6030683",
"0.6006912",
"0.60010093",
"0.5993058",
"0.59914565",
"0.5975324",
"0.5944749",
"0.591502",
"0.5887435"... | 0.775189 | 0 |
1.1 Generate Fingerprint VCFs Here we use Dalmatian to run the fingerprint_bam_with_liftover workflow on Terra. This workflow calls Picard ExtractFingerprint to generate a fingerprint VCF and then calls Picard LiftoverVcf to covert this vcf to hg38. To fingerprint hg38 bam files just run fingerprint_bam instead. | async def addToFingerPrint(samples, sampleset=, allsampleset="all", workspace=WORKSPACE, sid=, vcf_list=None,
vcf_list_dir=, working_dir, crosscheck_batch_size, recreate_batch, bamcolname,
taiga_dataset, taiga_filename):
bams = samples[bamcolname]
bams[sid] = bams.index
print('adding '+str(len(bams))+' new sampl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fingerprint(self, algorithm):",
"def main():\n parser = argparse.ArgumentParser(description='MergeGVCFs and genotype them using the GATK')\n parser.add_argument('-g', '--gatk', dest='gatk', help=\"Location of the GATK\", required=True)\n parser.add_argument('-x', '--xmx', dest='xmx', help=\"Memory t... | [
"0.5775645",
"0.57632786",
"0.5658153",
"0.561844",
"0.54591256",
"0.5334822",
"0.5325309",
"0.5305328",
"0.52687347",
"0.5263997",
"0.5230877",
"0.521849",
"0.5206169",
"0.51302344",
"0.5123245",
"0.5070162",
"0.50444156",
"0.5006062",
"0.5003408",
"0.49965554",
"0.4986839",... | 0.6725894 | 0 |
Makes sure the disks are present in the system and not reserved by anything else (boot, pool, iscsi, etc). | async def check_disks_availability(self, disks, allow_duplicate_serials):
verrors = ValidationErrors()
disks_cache = dict(map(lambda x: (x['devname'], x), await self.middleware.call('disk.query')))
disks_set = set(disks)
disks_not_in_cache = disks_set - set(disks_cache.keys())
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _PreCheckDisks(self, ispec):\n self.diskparams = self.cfg.GetInstanceDiskParams(self.instance)\n\n inst_nodes = self.cfg.GetInstanceNodes(self.instance.uuid)\n excl_stor = compat.any(\n list(rpc.GetExclusiveStorageForNodes(self.cfg, inst_nodes).values())\n )\n\n # Get the group access typ... | [
"0.71250546",
"0.63917005",
"0.61703014",
"0.61318177",
"0.61042476",
"0.60634845",
"0.6014175",
"0.60058516",
"0.5998691",
"0.5984649",
"0.59578073",
"0.59428805",
"0.5934872",
"0.59283465",
"0.5911958",
"0.5880785",
"0.5870844",
"0.582219",
"0.58177876",
"0.5780115",
"0.576... | 0.66384786 | 1 |
Creates a regulariser with a default lag of 1. Clearly, other lags can be specified by changing ``lag``. | def create_regulariser (self, nx, lag=1):
I = np.diag (np.ones(nx))
D = (I - np.roll ( I, -lag)).T
D2 = D.T.dot(D)
Z = np.zeros_like (I)
DD0 = np.array([D2, Z, Z]).reshape ( nx*3, nx).T
DD1 = np.array([Z, D2, Z]).reshape ( nx*3, nx).T # HACK! 10*
DD2 = np.array([Z... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_lag(self,inputLabels,lagNum,suffix=None,fillMissing=np.nan,verbose=0,n_jobs=1):\n self._transform_wrapper(\n inputLabels,\n None,\n make_lag,\n suffix,\n lagNum,\n False,\n n_jobs,\n verbose,\n lagNum... | [
"0.57087487",
"0.53776217",
"0.50716937",
"0.5034615",
"0.49503228",
"0.49326134",
"0.4897093",
"0.4829849",
"0.48250768",
"0.48185134",
"0.4808591",
"0.48084906",
"0.47779104",
"0.4774139",
"0.4773688",
"0.47535902",
"0.47450256",
"0.4730975",
"0.47273833",
"0.47186923",
"0.... | 0.5751384 | 0 |
Pad x and y so that the results have the same length (second dimension). | def _pad_tensors_to_same_length(x, y):
with tf.compat.v1.name_scope("pad_to_same_length"):
x_length = tf.shape(input=x)[1]
y_length = tf.shape(input=y)[1]
max_length = tf.maximum(x_length, y_length)
x = tf.pad(tensor=x, paddings=[[0, 0], [0, max_length - x_length], [0, 0]])
y = tf.pad(tensor=y, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_vals(x, y):\n\n xshapes = []\n for x_arr in x:\n\n x_arr = np.array(x_arr)\n xshapes.append(x_arr.shape[0])\n\n x_max_shape = np.max(xshapes)\n for i, x_arr in enumerate(x):\n\n pad_len = x_max_shape - x_arr.shape[0]\n x[i] = np.pad(x_arr, (0, pad_len), mode='constan... | [
"0.72084653",
"0.64343303",
"0.6101265",
"0.6084313",
"0.60171574",
"0.5993216",
"0.5956909",
"0.59541947",
"0.59405696",
"0.59165305",
"0.5867438",
"0.58579695",
"0.5835595",
"0.58168256",
"0.5816696",
"0.5811862",
"0.57709336",
"0.5734227",
"0.5715207",
"0.5693807",
"0.5685... | 0.7147605 | 1 |
Wrap a metric fn that returns scores and weights as an eval metric fn. The input metric_fn returns values for the current batch. The wrapper aggregates the return values collected over all of the batches evaluated. | def _convert_to_eval_metric(metric_fn):
def problem_metric_fn(*args):
"""Returns an aggregation of the metric_fn's returned values."""
(scores, weights) = metric_fn(*args)
# The tf.metrics.mean function assures correct aggregation.
return tf.compat.v1.metrics.mean(scores, weights)
return problem_me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_fn(\n # The pytype below must be Any, because the code below uses internal methods\n # only present on tff.learning.from_keras_model-derived TFF models.\n model: Any,\n dataset: tf.data.Dataset,\n batch_size: int = 1,\n) -> collections.OrderedDict[str, tf.Tensor]:\n # Resets the model'... | [
"0.6395356",
"0.6359279",
"0.629271",
"0.6235188",
"0.62173855",
"0.6195198",
"0.61704963",
"0.6149006",
"0.6123954",
"0.6117296",
"0.6049343",
"0.601445",
"0.5938186",
"0.5898094",
"0.58803093",
"0.58801115",
"0.58606005",
"0.58545065",
"0.5843001",
"0.58256847",
"0.5775458"... | 0.7159342 | 0 |
Computes ROUGEL (sentence level) of two collections of sentences. | def rouge_l_sentence_level(eval_sentences, ref_sentences):
f1_scores = []
for eval_sentence, ref_sentence in zip(eval_sentences, ref_sentences):
m = float(len(ref_sentence))
n = float(len(eval_sentence))
lcs = _len_lcs(eval_sentence, ref_sentence)
f1_scores.append(_f_lcs(lcs, m, n))
return np.mea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rouge_l_sentence_level(evaluated_sentences, reference_sentences):\n if len(evaluated_sentences) <= 0 or len(reference_sentences) <= 0:\n raise ValueError(\"Collections must contain at least 1 sentence.\")\n reference_words = _split_into_words(reference_sentences)\n evaluated_words = _split_into_words(eva... | [
"0.6562477",
"0.6535288",
"0.6080566",
"0.6073384",
"0.5944744",
"0.5769236",
"0.57410604",
"0.56901485",
"0.5615614",
"0.556189",
"0.55066365",
"0.55035615",
"0.5495382",
"0.54569256",
"0.54294115",
"0.54145795",
"0.5409134",
"0.5398293",
"0.5385837",
"0.5370661",
"0.5333738... | 0.66352373 | 0 |
Lists all files in a folder that match the clipping.json format. | def _listdir(folder):
filePattern = r"^\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])\-clipping\-[\d]*\.json$"
filenames = [f for f in os.listdir(folder) if re.match(filePattern, f)]
return filenames | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_files_from_folder(folder: str) -> list:\n\n files = []\n for file_name in os.listdir(folder):\n splitted_filename = file_name.split(\".\")\n if splitted_filename[-1] == \"json\":\n files.append(file_name)\n return files",
"def list_files(path):\n return list(sorted([... | [
"0.66877824",
"0.60839224",
"0.5914875",
"0.5865345",
"0.5820445",
"0.58006823",
"0.5798163",
"0.5783536",
"0.5780574",
"0.57754827",
"0.5738916",
"0.5717606",
"0.5713355",
"0.56997764",
"0.5660107",
"0.56417465",
"0.5632708",
"0.56137383",
"0.5609525",
"0.55692714",
"0.55671... | 0.7092136 | 0 |
Onetime use function. Method for rebasing .json files. Previous file versions did not include the base64 prefix. | def rebase_add_encoding_prefix():
filenames, clippings = load_clippings(inFolder)
for file, clip in zip(filenames, clippings):
img = clip["imgEncoding"]
str = "data:image/png;base64,"
if str not in img:
clip["imgEncoding"] = str + img
with open(file, "w") as outfile:
json.dump(clip, outfile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_gen(self):\r\n current_path = os.path.join(self.settings.save_path, 'current.json')\r\n current_folder_path = os.path.join(self.settings.save_path, 'current')\r\n history_path = os.path.join(self.settings.save_path, 'history')\r\n archive_folder_path = os.path.join(history_p... | [
"0.6086128",
"0.6033686",
"0.59726596",
"0.59672356",
"0.5949546",
"0.5894795",
"0.58688366",
"0.5825079",
"0.5788089",
"0.5704787",
"0.5688017",
"0.56608254",
"0.559506",
"0.55057395",
"0.54784393",
"0.5455468",
"0.54384154",
"0.5428078",
"0.5389018",
"0.53759176",
"0.536490... | 0.6098598 | 0 |
Onetime use function. Method for rebasing .json files. Add a "clipDate" key to clippings. | def rebase_add_date():
filenames, clippings = load_clippings(inFolder)
for file, clip in zip(filenames, clippings):
date = "-".join(file.split("-")[:3])
date = date.split("/")[-1]
clip["clipDate"] = date
with open(file, "w") as outfile:
json.dump(clip, outfile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_files_json():\n # chdir into beep root\n pwd = os.getcwd()\n os.chdir(os.environ.get(\"BEEP_ROOT\", \"/\"))\n\n meta_list = list(filter(lambda x: '_Metadata.csv' in x, os.listdir(SRC_DIR)))\n file_list = list(filter(lambda x: '.csv' in x if x not in meta_list else None, os.listdir(SRC_DI... | [
"0.57587606",
"0.55869764",
"0.53467065",
"0.52671915",
"0.5242644",
"0.5208656",
"0.51642597",
"0.5124621",
"0.50885236",
"0.5050152",
"0.5046206",
"0.5035444",
"0.5032294",
"0.5019946",
"0.50142884",
"0.5002037",
"0.49930683",
"0.49280834",
"0.49243683",
"0.49133766",
"0.49... | 0.7519383 | 0 |
Plots the piezo trace from piezo 0 and PMT pulse sizes near the acoustic signal on one figure. The green line indicates the time of acoustic t0. The red line indicates the time and size of the PMT t0 chosen by Matt's analysis. The yellow lines indicate the times and sizes of other PMT pulses. Also plots in separate win... | def PMTandPiezoPlot(datadir,run,event,gain):
en = event
mu = gain
e = sbc.DataHandling.GetSBCEvent.GetEvent(datadir+'/'+run,en)
print(e["fastDAQ"].keys())
cgate = e["fastDAQ"]["CAMgate"]
dcam = np.diff(cgate)
p0=e["fastDAQ"]["Piezo1"]
p1 = e["fastDAQ"]["Piezo2"]
fdt = e["fast... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plots(self, events=None, title=None):\n data = self.data\n P = PH.regular_grid(3 , 1, order='columnsfirst', figsize=(8., 6), showgrid=False,\n verticalspacing=0.08, horizontalspacing=0.08,\n margins={'leftmargin': 0.07, 'rightmargin': 0.20, 'topmarg... | [
"0.6307774",
"0.6264446",
"0.6067582",
"0.5951146",
"0.594318",
"0.59195983",
"0.59024936",
"0.5900452",
"0.5894213",
"0.5889887",
"0.58874977",
"0.5886258",
"0.58600056",
"0.58458775",
"0.58402437",
"0.5836458",
"0.5819858",
"0.57920396",
"0.5785791",
"0.5773497",
"0.577211"... | 0.72579896 | 0 |
Return content without the comments. If filter_multiline_comment is set to False, only the one line comment will be filtered out. If keep_content_size is set to True, the size of the content is preserved. | def filter_comments(
content, filter_multiline_comment=True, keep_content_size=False
):
def _replace_comment(element):
"""Replace matched *element* in content."""
replacement = ""
matched = element.group()
# Ensure that only the comment part is being replaced
if not matc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _strip_comments(file_contents):\n lines_without_comments = []\n for line in file_contents:\n comment_position = line.find(COMMENT_INDICATOR)\n if comment_position != -1:\n lines_without_comments.append(line[:comment_position])\n else:\n lines_without_comments.ap... | [
"0.5167605",
"0.51409805",
"0.4917135",
"0.4830618",
"0.46820927",
"0.46535304",
"0.46266067",
"0.46166417",
"0.4502041",
"0.44980857",
"0.44534415",
"0.4443194",
"0.44398215",
"0.44346082",
"0.43637702",
"0.43127203",
"0.4308069",
"0.42852294",
"0.42846525",
"0.42836487",
"0... | 0.7138743 | 0 |
Return tuple of content with the top level elements only and dictionary containing the collapsed content associated with the line number. If filter_comment is set to True, all comment are removed from the content before collapsing the elements. The collapsed content dictionary preserve the comments. | def collapse_all(content, filter_comment=False):
_initial_content = content
collapsed_content = {}
if filter_comment:
# Filter comment before collapsing elements to prevent comment analysis
content = filter_comments(content, keep_content_size=True)
def _replace_element(element):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_comments(\n content, filter_multiline_comment=True, keep_content_size=False\n):\n def _replace_comment(element):\n \"\"\"Replace matched *element* in content.\"\"\"\n replacement = \"\"\n matched = element.group()\n\n # Ensure that only the comment part is being replace... | [
"0.53617066",
"0.49494117",
"0.48269865",
"0.47749653",
"0.47021854",
"0.46672785",
"0.46630976",
"0.46363974",
"0.45885256",
"0.45649537",
"0.45570302",
"0.45216203",
"0.44642898",
"0.44569367",
"0.44267008",
"0.43709692",
"0.43698663",
"0.42966306",
"0.4290518",
"0.42780748",... | 0.71825683 | 0 |
Replace matched element in content. | def _replace_element(element):
# Guess line number
count = element.group().count("\n")
# Ensure that the replacement string keep the same length that
# the original content to be able to use the match positions
_buffer = len(element.group()) - count - 2
if len(element.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_content(self, content, siteurl):\n if not content:\n return content\n\n hrefs = self._get_intrasite_link_regex()\n return hrefs.sub(lambda m: self._link_replacer(siteurl, m), content)",
"def string_replace_xml_text(element, pattern, value):\n if element.text:\n ... | [
"0.6515308",
"0.6332452",
"0.62553614",
"0.61960304",
"0.6170884",
"0.6162246",
"0.6047259",
"0.60279584",
"0.60038835",
"0.5947182",
"0.58738005",
"0.5823154",
"0.5736322",
"0.5640052",
"0.5575298",
"0.55390126",
"0.5501876",
"0.5462999",
"0.5449665",
"0.54481953",
"0.542928... | 0.6922728 | 0 |
Return docstrings for an element at a specific line_number. Loop into the file lines in reverse, starting from the element's line_number in order to parse the docstring if available. | def get_docstring(line_number, lines):
docstring = None
for index in reversed(range(line_number-1)):
line = lines[index].strip()
if len(line) == 0 or line.startswith("//"):
# Do not look for docstring when more than two blank lines precede
# the element.
if i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_doxygen_docstring(lines, name):\n\n lines = lines[:]\n newlines = []\n indent = 0\n reading_desc = False\n\n while lines:\n line = lines.pop(0)\n if line.startswith(\"////\"):\n continue\n\n line = line.rstrip()\n if line.startswith('///<'):\n ... | [
"0.59708744",
"0.5864023",
"0.57362026",
"0.5729538",
"0.5353018",
"0.5304556",
"0.52516913",
"0.5187537",
"0.51576215",
"0.5119893",
"0.4906234",
"0.4906234",
"0.4906234",
"0.48642772",
"0.4851124",
"0.48384303",
"0.47899288",
"0.47810355",
"0.4746727",
"0.4719589",
"0.47194... | 0.67731166 | 0 |
Return a list of schedd ads representing all the schedds in the pool. | def get_schedds(args=None):
schedd_query = classad.ExprTree('!isUndefined(CMSGWMS_Type)')
collectors = ["cmssrv221.fnal.gov:9620",
"cmsgwms-collector-tier0.cern.ch:9620",
"cmssrv276.fnal.gov"]
schedd_ads = {}
for host in collectors:
coll = htcondor.Collector(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ads():\n return coll_ad.distinct(KEY_AD_ID)",
"def get_scnlist_all(self):\n logger.debug(\"Creating Database Engine and Session.\")\n db_engine = sqlalchemy.create_engine(self.db_info_obj.dbConn)\n session_sqlalc = sqlalchemy.orm.sessionmaker(bind=db_engine)\n ses = session... | [
"0.6366169",
"0.58527523",
"0.55230117",
"0.5514247",
"0.5457407",
"0.5414462",
"0.537656",
"0.5369209",
"0.53689307",
"0.53553814",
"0.53361785",
"0.5334375",
"0.53261983",
"0.53052175",
"0.5293422",
"0.5286213",
"0.5268966",
"0.5263969",
"0.525932",
"0.5256553",
"0.5237803"... | 0.59305084 | 1 |
Uses the Win32 registry to return a iterator of serial (COM) ports existing on this computer. | def _enumerate_serial_ports():
path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'
try:
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path)
except WindowsError:
raise IterationError
for i in itertools.count():
try:
val = winreg.EnumVal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enumerate_serial_ports():\n path = 'HARDWARE\\\\DEVICEMAP\\\\SERIALCOMM'\n try:\n key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path)\n except WindowsError:\n raise IterationError\n\n for i in itertools.count():\n try:\n val = winreg.EnumValue(key, i)\n# ... | [
"0.86018956",
"0.8531883",
"0.7983318",
"0.7983318",
"0.7980792",
"0.7802933",
"0.77502596",
"0.7742627",
"0.7668107",
"0.764201",
"0.7632164",
"0.7632164",
"0.7631555",
"0.75972277",
"0.75972277",
"0.75972277",
"0.75972277",
"0.7596552",
"0.75547063",
"0.7551492",
"0.7501493... | 0.860505 | 0 |
Function that plots a Calendar Map | def plot_calmap(df_serie, title='Calendar 2018'):
plt.style.use('seaborn')
fig = plt.figure(figsize=(15,6))
ax = fig.add_subplot(111)
cax = calmap.yearplot(df_serie, ax=ax )#, cmap='YlGn')
cb=fig.colorbar(cax.get_children()[1], ax=cax, orientation='horizontal')
plt.title(title)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_calmap(df, yr, s3_resource_bucket):\n calmap_data = pd.Series(df['Miles'].values, index=df['Date'])\n plt.figure(figsize=(15, 5))\n plt.title(f'CALENDAR HEATMAP')\n calmap.yearplot(calmap_data,\n year=int(yr),\n fillcolor='lightgrey')\n plt.savefig(f'... | [
"0.69210756",
"0.6444934",
"0.6395161",
"0.6322168",
"0.6316235",
"0.6248",
"0.62450975",
"0.62378526",
"0.62311244",
"0.62179315",
"0.6160899",
"0.6084357",
"0.60731095",
"0.60508186",
"0.60447294",
"0.6003607",
"0.5985491",
"0.5948202",
"0.593896",
"0.59218866",
"0.5912166"... | 0.7201914 | 0 |
counts reviewer comments, checks for protm tag, counts rxns | def calc_comments(self):
for comment in self.pull_request.get_comments():
self._users.add(comment.user.login)
lowercase_body = comment.body.lower()
if "protm" in lowercase_body:
self.num_protm += 1
self.num_comments += 1
if comment.body... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_conv_comments(self):\n for conv_comment in self.pull_request.get_issue_comments():\n self._users.add(conv_comment.user.login)\n lowercase_body = conv_comment.body.lower()\n if \"protm\" in lowercase_body:\n self.num_protm += 1\n self.num_co... | [
"0.6474507",
"0.6455249",
"0.6259978",
"0.62172806",
"0.61330706",
"0.60819334",
"0.6049567",
"0.6044032",
"0.5932042",
"0.59275013",
"0.5864903",
"0.5854539",
"0.5774755",
"0.57618237",
"0.57519615",
"0.5748041",
"0.5737438",
"0.57298326",
"0.5722486",
"0.57208025",
"0.57045... | 0.668312 | 0 |
counts conversational comments, checks for protm tag, counts rxns | def calc_conv_comments(self):
for conv_comment in self.pull_request.get_issue_comments():
self._users.add(conv_comment.user.login)
lowercase_body = conv_comment.body.lower()
if "protm" in lowercase_body:
self.num_protm += 1
self.num_conv_comments +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_comments(self):\n return self.run_query(f\"count({self.r}/comment)\")",
"def calc_comments(self):\n for comment in self.pull_request.get_comments():\n self._users.add(comment.user.login)\n lowercase_body = comment.body.lower()\n if \"protm\" in lowercase_b... | [
"0.66587913",
"0.6579101",
"0.6395755",
"0.6311714",
"0.6095312",
"0.6047312",
"0.5910355",
"0.5901797",
"0.5876962",
"0.5855314",
"0.58521634",
"0.5803708",
"0.57817703",
"0.5762721",
"0.57504636",
"0.5726828",
"0.5711957",
"0.57052165",
"0.57052165",
"0.57011557",
"0.569478... | 0.68003654 | 0 |
finds issues in PR | def issues(self):
if self.pull_request.body is not None:
regex = r"(?<=closes: #|elated: #)\d{5}"
issue_strs = re.findall(regex, self.pull_request.body)
self.issue_nums = [eval(s) for s in issue_strs] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_issue_list_issues(self):\n pass",
"def get_issues(): # pragma: no cover\n global issue_data\n team = {\n 'stevex196x': 0,\n 'TheSchaft': 0,\n 'melxtru': 0,\n 'aylish19': 0,\n 'connormlewis': 0,\n 'tsukkisuki': 0\n }\n all_issues = 0\n whil... | [
"0.70138097",
"0.6760061",
"0.66123015",
"0.66048265",
"0.65544665",
"0.6547893",
"0.64266086",
"0.63871706",
"0.63705385",
"0.6270671",
"0.62466",
"0.6183235",
"0.61762655",
"0.61605066",
"0.61473805",
"0.6101282",
"0.60798544",
"0.6076719",
"0.6035414",
"0.602907",
"0.60161... | 0.7080025 | 0 |
The homepage is loaded using a combination of .write and .markdown. Contains description how app works | def load_homepage() -> None:
st.image("iwakka.png",
use_column_width=True)
st.header("Hello! This dashboard will help you to analize data from iWakka device")
st.write("Here are some step to process data: ")
st.header(" II. Download data")
st.write("Here you can download data")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home() :\n st.markdown(\"This application provides 3 mains modules :\")\n st.markdown(\"* **The prediction module :** enables you to assess client's liability based on its file\")\n st.markdown(\"* **The explorer module :** enables you to dig deeper into your client informations,\"\n \"... | [
"0.80281425",
"0.71578765",
"0.6982044",
"0.68896574",
"0.6870078",
"0.68403995",
"0.6818947",
"0.6801335",
"0.6782138",
"0.6779921",
"0.6769249",
"0.6699216",
"0.6699216",
"0.6691474",
"0.6685022",
"0.6680601",
"0.66717446",
"0.66556436",
"0.6655127",
"0.6645696",
"0.6633345... | 0.7181079 | 1 |
Create a UNet model using 3D operations. This model is based on the 3D UNet model described by Cicek et al [UNET3D]_ for solving membrane segmentation in electron microscopic images. | def unet3d(input_shape, data_format='channels_first'):
i = Input(shape=input_shape)
down1, c1 = downconv_block(i, 16, 3)
down2, c2 = downconv_block(down1, 32, 3)
down3, c3 = downconv_block(down2, 64, 3)
up1 = upconv_block(down3, 128, 3)
crop1 = crop(c3, up1)
merge_block = [up1, crop1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unet_3d(self):\n for model_class in [UNet3D, UNetPlus3D]:\n b, d, h, w = 4, 8, 64, 64\n in_channel, out_channel = 1, 3\n x = torch.rand(b, in_channel, d, h, w)\n model = model_class(block_type='residual', in_channel=in_channel,\n ... | [
"0.74566793",
"0.69313484",
"0.6902316",
"0.687786",
"0.6713262",
"0.65693206",
"0.65354615",
"0.6512889",
"0.64145637",
"0.6372629",
"0.63473874",
"0.6343035",
"0.6316669",
"0.6280747",
"0.62306607",
"0.62199247",
"0.6216385",
"0.62071687",
"0.61754984",
"0.6156091",
"0.6141... | 0.72291464 | 1 |
Adds a comment to a checkin | def add_comment(self, checkin_id: str, comment: str) -> Dict:
method = "checkin/addcomment/" + checkin_id
auth = self._get_access_token()
if len(comment) > 140:
raise ValueError(
f"Check-in comment is {len(comment)} characters whereas Untappd only supports comments up... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli(ctx, comment, metadata=\"\"):\n return ctx.gi.cannedcomments.add_comment(comment, metadata=metadata)",
"def add_comment(self, issue, comment):\n return self.get_jira().add_comment(issue, comment)",
"def comment():",
"def __add_comment(self, issue_id, comment):\n import httplib2\n ... | [
"0.7102078",
"0.66819334",
"0.61690533",
"0.61546576",
"0.61425036",
"0.6140449",
"0.61339134",
"0.6081882",
"0.60638744",
"0.6055927",
"0.60003436",
"0.5983363",
"0.5982767",
"0.59778225",
"0.5976688",
"0.59765553",
"0.59236735",
"0.5921192",
"0.59078676",
"0.59078676",
"0.5... | 0.8196651 | 0 |
Removes a comment on a checkin | def remove_comment(self, comment_id: str) -> Dict:
method = "checkin/deletecomment/" + comment_id
auth = self._get_access_token()
return self._do_post(method, auth, {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_comment(self, uid: str):\n pass",
"def issues_comments_undelete(self, mar, request):\n return self.aux_delete_comment(mar, request, False)",
"def remove(self, channel, nick, comment=\"\"):\n time.sleep(1)\n self.s.send(\"REMOVE %s %s%s\\n\" % (channel, nick, (comment and (\" ... | [
"0.6411806",
"0.61087275",
"0.5990724",
"0.5918164",
"0.5896276",
"0.58793694",
"0.58626604",
"0.5818508",
"0.57703024",
"0.57703024",
"0.57332915",
"0.5706563",
"0.5685093",
"0.5648533",
"0.562702",
"0.5555107",
"0.55467623",
"0.54898906",
"0.5439831",
"0.54275584",
"0.54192... | 0.657487 | 0 |
Adds a beer to a users wishlist | def add_to_wishlist(self, beer_id: str) -> Dict:
method = "user/wishlist/add"
auth = self._get_access_token()
params = {"bid": beer_id}
return self._do_get(method, auth, params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_wish_list(self, user_id, caption):\n with self.connection:\n return self.cursor.execute(\"INSERT INTO 'wish_list' (`user_id`, `wish_list`) VALUES(?,?)\", (user_id,caption))",
"def test_add_remove_from_wishlist(self):\n url = reverse('add-to-wishlist')\n data = {\n ... | [
"0.67660224",
"0.62912786",
"0.6265778",
"0.62621766",
"0.62581646",
"0.6205359",
"0.6201952",
"0.6182023",
"0.61050695",
"0.6082546",
"0.6066206",
"0.60658205",
"0.6046209",
"0.6035353",
"0.60304606",
"0.5989473",
"0.59838045",
"0.5909522",
"0.5875938",
"0.5861446",
"0.58604... | 0.7936551 | 0 |
Removes a beer from a users wishlist | def remove_from_wishlist(self, beer_id: str):
method = "user/wishlist/delete"
auth = self._get_access_token()
params = {"bid": beer_id}
return self._do_get(method, auth, params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_wish_list(self, user_id, caption):\n with self.connection:\n data = self.cursor.execute(\"SELECT wish_list FROM Wish_list WHERE user_id=?\", (user_id,)).fetchall()\n for row in data:\n new_row = ''.join(row)\n if new_row == caption:\n ... | [
"0.7259753",
"0.6906275",
"0.6864111",
"0.67099994",
"0.66733855",
"0.66321814",
"0.65928495",
"0.65331244",
"0.64332575",
"0.63253903",
"0.6217423",
"0.6194978",
"0.61807096",
"0.61729836",
"0.6157014",
"0.61554927",
"0.6153164",
"0.61204636",
"0.6090897",
"0.6069139",
"0.60... | 0.82368296 | 0 |
Set data and set ContentLength header. | def set_data(self, data):
self.data = data
self.headers['Content-Length'] = len(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_body(self, data):\n self._body = data\n self.add_header('Content-Length', len(self._body))",
"def content_len(self, value):\n self.set_header('CONTENT-LENGTH', value)",
"def set_est_rsp_header(self, data_len):\n self.send_response(200)\n self.send_header('Content-type... | [
"0.7739068",
"0.69663864",
"0.69061565",
"0.6790839",
"0.6772394",
"0.6772394",
"0.6516417",
"0.6474555",
"0.63574344",
"0.6337354",
"0.6207637",
"0.6076806",
"0.6076806",
"0.6067116",
"0.60512626",
"0.60157615",
"0.5981222",
"0.5978075",
"0.5978043",
"0.5919072",
"0.5870608"... | 0.8999144 | 0 |
Get octets of Response. | def get_octets(self):
if self.method == 'GET':
return '{}{}{}{}'.format(self._get_status_line(),
self._get_headers(),
2 * CRLF,
self.data)
else:
return '{}{}{}'.format(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_response_byte(self):\n raise NotImplementedError",
"def sitetotalresponsebytes(self) :\n\t\ttry :\n\t\t\treturn self._sitetotalresponsebytes\n\t\texcept Exception as e:\n\t\t\traise e",
"def receive_primitive_execution_response(self):\n resp = self.read_response_buffer(ATI_RESPONSE_BUFFER... | [
"0.67584234",
"0.624266",
"0.58819395",
"0.5852249",
"0.5794166",
"0.576959",
"0.5674074",
"0.55672896",
"0.5560961",
"0.55547404",
"0.552938",
"0.5471753",
"0.5431196",
"0.5413688",
"0.5413688",
"0.53808963",
"0.5376896",
"0.5372647",
"0.53635085",
"0.53618985",
"0.53502715"... | 0.76032627 | 0 |
This function evaluates the classification model using the accuracy score given a model_object, X, and y | def evaluate(model_object, X, y):
# calcuated accuracy
accuracy = model_object.score(X, y)
return accuracy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_model(model, X_test, Y_test, category_names):\n Y_pred=model.predict(X_test)\n acc=[]\n for i,c in enumerate(Y_test.columns):\n print(c)\n print(classification_report(Y_test[c], Y_pred[:,i]))\n acc.append(accuracy_score(Y_test[c], Y_pred[:,i]))\n print('Accuracy :',np.... | [
"0.7515988",
"0.7515214",
"0.7514516",
"0.74553627",
"0.73694795",
"0.7287006",
"0.72798187",
"0.7275241",
"0.726499",
"0.72494537",
"0.7248431",
"0.72239125",
"0.721681",
"0.72078854",
"0.72075343",
"0.7166369",
"0.71446836",
"0.71296114",
"0.7124664",
"0.711983",
"0.7105154... | 0.8825581 | 0 |
The hostname specified by the remote peer for this connection. | def remote_hostname(self):
return pn_connection_remote_hostname(self._impl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hostname(self):\n return self._hostname",
"def get_hostname(self):\n return self.name",
"def get_host(self) -> str:\n return self.socket.getsockname()[0]",
"def peername(self):\n return self.socket_.getpeername()",
"def hostname(self) -> str:\n _args: list[Arg] = []\n... | [
"0.7981605",
"0.7919443",
"0.781819",
"0.77913344",
"0.7728555",
"0.77235633",
"0.763241",
"0.7623107",
"0.7621482",
"0.7620361",
"0.76036936",
"0.7573506",
"0.75652593",
"0.7543359",
"0.7532723",
"0.7520042",
"0.7489005",
"0.74886316",
"0.7482386",
"0.7454292",
"0.7451588",
... | 0.8748257 | 0 |
The capabilities desired by the remote peer for this connection. | def remote_desired_capabilities(self):
return dat2obj(pn_connection_remote_desired_capabilities(self._impl)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capabilities(self) -> dto.Capabilities:\n raise NotImplementedError",
"def capabilities(self):\n pass",
"def remote_offered_capabilities(self):\n return dat2obj(pn_connection_remote_offered_capabilities(self._impl))",
"def capability(self):\n code, data, capabilities = (\n ... | [
"0.7864362",
"0.77226967",
"0.7706095",
"0.75981325",
"0.75973034",
"0.7499757",
"0.7499757",
"0.74835926",
"0.74506027",
"0.74074715",
"0.7262458",
"0.7234038",
"0.7208045",
"0.71269935",
"0.7114823",
"0.70935553",
"0.69573575",
"0.69261956",
"0.69241446",
"0.68688613",
"0.6... | 0.83942115 | 0 |
The properties specified by the remote peer for this connection. | def remote_properties(self):
return dat2obj(pn_connection_remote_properties(self._impl)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_connection_properties(self):\n try:\n localdict = {\"MQTT\" : {\\\n \"address\" : self.config_handle['MQTT']['MQTTBrokerAddress'],\\\n \"port\" : int(self.config_handle['MQTT']['MQTTBrokerPort']),\\\n ... | [
"0.68456537",
"0.653772",
"0.62828326",
"0.6195585",
"0.6195585",
"0.6192706",
"0.6192706",
"0.6146062",
"0.6144435",
"0.61440533",
"0.61283886",
"0.6063591",
"0.60155845",
"0.59984654",
"0.5973957",
"0.5965847",
"0.59370947",
"0.59279245",
"0.5921653",
"0.5910656",
"0.590705... | 0.78266364 | 0 |
Opens the connection. In more detail, this moves the local state of the connection to the ACTIVE state and triggers an open frame to be sent to the peer. A connection is fully active once both peers have opened it. | def open(self):
obj2dat(self.offered_capabilities,
pn_connection_offered_capabilities(self._impl))
obj2dat(self.desired_capabilities,
pn_connection_desired_capabilities(self._impl))
obj2dat(self.properties, pn_connection_properties(self._impl))
pn_connecti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opened(self):\n self.logger.info(\"Socket connection open\")\n # Send a connection request\n self.sender.send_packet(52)",
"def _connect(self):\n hostport = self.getHost()\n channelOpenData = forwarding.packOpen_direct_tcpip((self.host, self.port), (hostport.host, hostport.... | [
"0.699216",
"0.6720545",
"0.66052824",
"0.65688837",
"0.6461779",
"0.6403845",
"0.6403845",
"0.630622",
"0.6226646",
"0.6225425",
"0.6225425",
"0.61711425",
"0.6162814",
"0.6161016",
"0.61437017",
"0.6132527",
"0.6126176",
"0.61228085",
"0.60389924",
"0.6021844",
"0.60051084"... | 0.7019765 | 0 |
The state of the connection as a bit field. The state has a local and a remote component. Each of these can be in one of three | def state(self):
return pn_connection_state(self._impl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_connection_state(self):\n return self.connection_state",
"def state(self):\n return {\n 'port' : self.self.__port.port, #port name/number as set by the user\n 'baudrate' : self.self.__port.baudrate, #current baudrate setting\n 'bytesize' : self.sel... | [
"0.6482273",
"0.6433013",
"0.6314307",
"0.6302431",
"0.6208477",
"0.61879957",
"0.60750175",
"0.60722756",
"0.6067025",
"0.6039174",
"0.6039174",
"0.6036067",
"0.60196996",
"0.60196996",
"0.6016638",
"0.60139465",
"0.5980345",
"0.5980345",
"0.5980345",
"0.5972967",
"0.5972287... | 0.69306684 | 0 |
Opens the link. In more detail, this moves the local state of the link to the ACTIVE state and triggers an attach frame to be sent to the peer. A link is fully active once both peers have attached it. | def open(self):
pn_link_open(self._impl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_link(self) -> None:\n\n webbrowser.open_new(self.link)",
"def open_link(self):\n try:\n webbrowser.open(self.url)\n except:\n self.ids.link.text=self.link_message",
"def open(self):\n self._isOpen = True",
"def opened(self):\n self.send({\n ... | [
"0.66080314",
"0.61079884",
"0.5837042",
"0.583461",
"0.5769809",
"0.5760496",
"0.57441324",
"0.5630137",
"0.56034017",
"0.5572188",
"0.5553864",
"0.54710066",
"0.54184073",
"0.5356799",
"0.5356799",
"0.5354793",
"0.53493524",
"0.53319454",
"0.52859795",
"0.52533734",
"0.5253... | 0.64356446 | 1 |
Closes the link. In more detail, this moves the local state of the link to the CLOSED state and triggers an detach frame (with the closed flag set) to be sent to the peer. A link is fully closed once both peers have detached it. | def close(self):
self._update_cond()
pn_link_close(self._impl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closeLink(self):\n if self.isOpen:\n self.SerClient.close()\n print(\"Closed serial port {0}\".format(self.port))",
"def close(self):\n if self._closed:\n return\n\n self.listening = False\n\n self.ssl_enabled = False\n\n if self._slave:\n self._... | [
"0.66938305",
"0.6307246",
"0.6277232",
"0.608229",
"0.60567176",
"0.60388726",
"0.6008762",
"0.5995509",
"0.59896326",
"0.5943243",
"0.5884415",
"0.5849329",
"0.5798474",
"0.5789303",
"0.578923",
"0.5788571",
"0.5781019",
"0.5773587",
"0.5770286",
"0.5757257",
"0.57390946",
... | 0.687574 | 0 |
The state of the link as a bit field. The state has a local and a remote component. Each of these can be in one of three | def state(self):
return pn_link_state(self._impl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getState():\n # TODO: this isn't nearly as meaningful as it used to be",
"def network_state(self):\n states = {\n 0: \"NETWORK_EMPTY\",\n 1: \"NETWORK_IDLE\",\n 2: \"NETWORK_LOADING\",\n 3: \"NETWORK_NO_SOURCE\",\n }\n return states[self... | [
"0.5690449",
"0.5668708",
"0.5668708",
"0.5588153",
"0.5585658",
"0.55679953",
"0.5543208",
"0.552515",
"0.55232596",
"0.55221283",
"0.55136484",
"0.55097944",
"0.5471529",
"0.54571605",
"0.545629",
"0.54281",
"0.5419869",
"0.5415876",
"0.5415876",
"0.5400457",
"0.5400457",
... | 0.6756402 | 0 |
Returns the name of the link | def name(self):
return utf82unicode(pn_link_name(self._impl)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name(tab):\n return tab.find(\"a\").get_text(strip=True).title().replace(' ', '')",
"def __str__(self):\n\t\treturn '{0} ({1})'.format (self.name, self.link)",
"def get_name_link_html(self):\n url_text = \"{{% url 'trait_browser:source:studies:pk:detail' pk={} %}} \".format(self.pk)\n ... | [
"0.71299154",
"0.7034757",
"0.6980485",
"0.6919076",
"0.6919076",
"0.6902483",
"0.68388283",
"0.68203676",
"0.6820108",
"0.6798065",
"0.67772627",
"0.67275065",
"0.67275065",
"0.67275065",
"0.6723569",
"0.6722679",
"0.6702163",
"0.6701957",
"0.66948295",
"0.66948295",
"0.6690... | 0.84673464 | 0 |
Returns true if this link is a sender. | def is_sender(self):
return pn_link_is_sender(self._impl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_sender(self):\n return self.balance > 0",
"def sender(self):\n l = self.link\n if l and l.is_sender:\n return l\n else:\n return None",
"def is_sender_public_id(self) -> bool:\n return PublicId.is_valid_str(self.sender)",
"def is_receiver(self)... | [
"0.7136295",
"0.70802164",
"0.6921599",
"0.64989007",
"0.6169625",
"0.6168362",
"0.60093373",
"0.5877719",
"0.58769935",
"0.57950914",
"0.57574874",
"0.5721971",
"0.5685329",
"0.56846696",
"0.56842625",
"0.5654095",
"0.5632591",
"0.56324697",
"0.56242245",
"0.56125104",
"0.55... | 0.8751801 | 0 |
Returns true if this link is a receiver. | def is_receiver(self):
return pn_link_is_receiver(self._impl) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_sender(self):\n return pn_link_is_sender(self._impl)",
"def receiver(self):\n l = self.link\n if l and l.is_receiver:\n return l\n else:\n return None",
"def has_receiver(self):\n return self.balance < 0",
"def is_connected_to(self, receiver: Sk... | [
"0.69650966",
"0.6852672",
"0.6732397",
"0.6217352",
"0.60657305",
"0.6023268",
"0.5935235",
"0.58936906",
"0.5808235",
"0.5745558",
"0.5674144",
"0.56644243",
"0.56486523",
"0.562267",
"0.5561293",
"0.5532493",
"0.5508603",
"0.5465453",
"0.54512715",
"0.54389626",
"0.5393733... | 0.85351586 | 0 |
Send specified object over this sender; the object is expected to have a send() method on it that takes the sender and an optional tag as arguments. Where the object is a Message, this will send the message over this link, creating a new delivery for the purpose. | def send(self, obj, tag=None):
if hasattr(obj, 'send'):
return obj.send(self, tag=tag)
else:
# treat object as bytes
return self.stream(obj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(self, obj):\n\t\tif not isinstance(obj, NotificationMessage):\n\t\t\traise ValueError, u\"You can only send NotificationMessage objects.\"\n\t\tself._send_queue.put(obj)",
"def _send_object(object: Any, src: int, dst: int, group: ProcessGroup) -> None:\n # then broadcast safely\n _broadcast_object... | [
"0.67527705",
"0.62086815",
"0.61746854",
"0.60819185",
"0.5953311",
"0.5948292",
"0.5933821",
"0.58370566",
"0.5820838",
"0.58184326",
"0.5754726",
"0.5753957",
"0.5739397",
"0.57023257",
"0.56995153",
"0.5694203",
"0.56670904",
"0.5650131",
"0.5615801",
"0.561462",
"0.56141... | 0.7246263 | 0 |
Initialize the name, price, and publisher attributes | def __init__(self, name, price, publisher):
# passes self which means itself. only defines name, price, and publisher
self.name = name
self.price = price
self.publisher = publisher
# any of these variables are available with the instances below.
# called attributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name, price, publisher):\n\n\t\tself.name = name\n\t\tself.price = price\n\t\tself.publisher = publisher",
"def __init__(self, name, price, description):\n self.name = name\n self.price = price\n self.description = description",
"def __init__(self, _name, _price):\n ... | [
"0.8742281",
"0.77766323",
"0.77635586",
"0.7575418",
"0.715278",
"0.71475065",
"0.71269536",
"0.710719",
"0.7004891",
"0.69697315",
"0.69262815",
"0.68820333",
"0.686704",
"0.6838979",
"0.6791007",
"0.6776866",
"0.67628205",
"0.67525285",
"0.6721511",
"0.66995883",
"0.660679... | 0.85595906 | 1 |
Simulate a hardback book. | def hardback(self):
print(self.name.title() + " is a hardback book.")
# only one parameter | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hardback(self):\n\t\tprint(self.name.title() + \" is a hardback book.\")",
"def softback(self):\n\t\tprint(self.name.title() + \" is a softback book.\")",
"def softback(self):\n\t\tprint(self.name.title() + \" is a softback book.\")",
"def back(self):\n self.book.back()\n self.book.save()\n... | [
"0.7480994",
"0.706025",
"0.706025",
"0.64167446",
"0.6053993",
"0.6037747",
"0.5956165",
"0.5890169",
"0.5888886",
"0.58675635",
"0.5793995",
"0.57767373",
"0.5775367",
"0.5751254",
"0.56818205",
"0.56769484",
"0.56444496",
"0.56236523",
"0.5599918",
"0.54684776",
"0.5436778... | 0.7633511 | 0 |
Simulate a book being a softback book. | def softback(self):
print(self.name.title() + " is a softback book.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hardback(self):\n\t\tprint(self.name.title() + \" is a hardback book.\")",
"def hardback(self):\n\t\tprint(self.name.title() + \" is a hardback book.\")\n\t\t# only one parameter ",
"def give_book(self):\n pass",
"def back(self):\n self.book.back()\n self.book.save()\n self.sa... | [
"0.7039198",
"0.70243394",
"0.6402143",
"0.6281067",
"0.5441984",
"0.52874064",
"0.51413476",
"0.51136416",
"0.5065948",
"0.504675",
"0.50445867",
"0.5042364",
"0.5027885",
"0.5027778",
"0.4997183",
"0.49717447",
"0.49711064",
"0.4962445",
"0.49496996",
"0.4947928",
"0.491111... | 0.7562381 | 1 |
Check if obj is function(lambda function or user defined method) or not | def is_function(obj):
return isinstance(obj, (types.FunctionType, types.MethodType,
types.LambdaType)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_function(obj):\n if type(obj) is types.FunctionType:\n return True\n if not is_object(obj):\n return False\n if not hasattr(obj, '__class__'):\n return False\n module = obj.__class__.__module__\n name = obj.__class__.__name__\n return (module == '__builtin__' and\n ... | [
"0.8406804",
"0.81598043",
"0.8006852",
"0.77947617",
"0.7518819",
"0.74505544",
"0.7450269",
"0.7407909",
"0.7402401",
"0.73496395",
"0.733957",
"0.7261521",
"0.71794486",
"0.7146296",
"0.71161747",
"0.7082738",
"0.7004352",
"0.68949264",
"0.6871542",
"0.68401486",
"0.670495... | 0.8658715 | 0 |
Check if obj is Chainer dataset instance or not | def is_dataset(obj):
return isinstance(obj, (DictDataset, ImageDataset, LabeledImageDataset,
TupleDataset, DatasetMixin)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_pyvista_dataset(obj):\n return isinstance(obj, (pyvista.DataSet, pyvista.MultiBlock))",
"def is_dataset(self):\n return self._dataset is not None",
"def is_dataclass_instance(obj: Any) -> bool:\n return dataclasses.is_dataclass(obj) and not isinstance(obj, type)",
"def _is_dataclass_instance(... | [
"0.770893",
"0.739313",
"0.729949",
"0.7168334",
"0.6819271",
"0.6281159",
"0.61960447",
"0.6142162",
"0.6134108",
"0.6121551",
"0.59871554",
"0.59129447",
"0.5847221",
"0.5837641",
"0.5763372",
"0.5737771",
"0.57180643",
"0.570669",
"0.57029617",
"0.5697987",
"0.5680553",
... | 0.76800853 | 1 |
Extract only necessary number of arguments from `args_tuple` for `fn` For example if fn is defined as `fn(x)`, and `args = (x, y)`, you want to pass only `x` to `fn`. However `fn(args)` will fail. Instead, you can use `fn(filter_args(fn, args))` to pass only first argument `x` to `fn`. | def filter_args(fn, args_tuple):
sig = inspect.signature(fn)
flag_var_positional = any([
inspect.Parameter.VAR_POSITIONAL == value.kind for
value in sig.parameters.values()])
if flag_var_positional:
return args_tuple
else:
num_args = len(sig.parameters.items())
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _handle_func_args(func, *args, **kwargs):\n if not isinstance(func, (types.FunctionType, types.MethodType)):\n raise RuntimeError('fn {} is not function or method'.format(func))\n if kwargs:\n bound_arguments = inspect.signature(func).bind(*args, **kwargs)\n bound_arguments.apply_def... | [
"0.5690902",
"0.55679125",
"0.5562832",
"0.55326533",
"0.54733473",
"0.5434962",
"0.5408235",
"0.5394954",
"0.536647",
"0.5345054",
"0.5256749",
"0.52392966",
"0.5222291",
"0.51986945",
"0.5194496",
"0.51747423",
"0.5167758",
"0.5150224",
"0.5120675",
"0.50989544",
"0.5081835... | 0.79530096 | 0 |
build predictor This function is used when `predictor` is not set at `__init__`. | def build(self):
if self.predictor_constructor is None:
print('[ERROR] build_predictor_fn not set, skip.')
else:
if hasattr(self, 'predictor'):
print(
"[WARNING] predictor is already set, predictor is overridden")
del self.predi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_predictor(self):\n try: \n predict_fn = tf.contrib.predictor.from_saved_model(self.saved_path)\n except OSError as err: \n print(f\"OSError: {err}\")\n self._predict_fn = predict_fn",
"def build_predictor(self):\n if self.library == \"yolov5\":\n ... | [
"0.7997393",
"0.74647427",
"0.7036349",
"0.69404703",
"0.68318325",
"0.66644275",
"0.6648286",
"0.6613312",
"0.6613312",
"0.6613312",
"0.65086025",
"0.65041876",
"0.6477833",
"0.64506423",
"0.63864267",
"0.6300349",
"0.62879354",
"0.6251706",
"0.6243861",
"0.622155",
"0.61992... | 0.79013455 | 1 |
Take a list of tags in arbitrary order and convert to a vector where each position corresponds to a particular category of tag, e.g., tagvec[0] is part of speech, tagvec[1] is grammatical person, etc. Many tags are liable to be ignored. | def encode_tags(taglist, lang_name):
tagvec = [None]*len(UNIMORPH_CATEGORIES)
for tag in taglist:
if tag in UNIMORPH_TAGTYPES:
tagtype = UNIMORPH_TAGTYPES[tag]
set_tagtype(tagvec, tagtype, tag, lang_name)
if tag in UNIMORPH_POS_MAP:
pos = UNIMORPH_POS_MAP[tag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_taglist(tags):\n taglist = []\n for tag in tags:\n taglist.append(tag['value'].lower())\n return taglist",
"def process_tags(tags=list):\n new_tag_list = list()\n for tag in tags:\n new_tag = tag.replace(\"<\", \" \")\n new_tag = new_tag.replace(\">\", \" \")\n ... | [
"0.65852666",
"0.65625983",
"0.6401724",
"0.5976778",
"0.5954396",
"0.59000534",
"0.5882231",
"0.58056265",
"0.5777922",
"0.5743458",
"0.57354516",
"0.57318646",
"0.5717215",
"0.5706954",
"0.5682867",
"0.566913",
"0.5664755",
"0.5604232",
"0.56017196",
"0.5593573",
"0.5589931... | 0.70481676 | 0 |
Produce a dictionary of dictionaries, which indexes all inflected forms primarily by part of speech, and secondarily by lemma. Each entry records a tag vector and the inflected form. e.g., { | def get_encoded_forms(lang_name):
triplets = get_language_training_data(lang_name)
by_lemma = {}
for triplet in triplets:
lemma = triplet["lemma"]
form = triplet["inflected_form"]
try:
tagvec = encode_tags(triplet["unimorph_tags"].split(";"), lang_name)
except ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keyword_extraction(file_content):\n\n # [question, question....]\n for key, value in file_content.items():\n seg, hidden = ltp.seg([key])\n # ner: [[('Nh', 2, 2)]]\n ner = ltp.ner(hidden)\n # keywords: [('PERSON', \"吴轩\")], tuple_item: ('Nh', 2, 2)\n keywords = [(tag_t... | [
"0.6260083",
"0.6084667",
"0.60658395",
"0.6039075",
"0.59498996",
"0.5932371",
"0.58884287",
"0.58660764",
"0.58531505",
"0.5827168",
"0.582249",
"0.57876813",
"0.5762694",
"0.575759",
"0.5756045",
"0.5737842",
"0.57028764",
"0.5680881",
"0.5674194",
"0.5671517",
"0.56706685... | 0.6908251 | 0 |
Returns a method that can be used in argument parsing to check that the argument is greater or equal to `threshold`. | def int_greater_or_equal(threshold: int) -> Callable:
def check_greater_equal(value_to_check):
value_to_check = int(value_to_check)
if value_to_check < threshold:
raise argparse.ArgumentTypeError("must be greater or equal to %d." % threshold)
return value_to_check
return ch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_threshold(threshold, value):\r\n return threshold[0](value, threshold[1])",
"def para_lower_than(threshold):\n\n return lambda step, curr_obj, curr_optimized_obj, extra_para: extra_para<threshold",
"def check_threshold(threshold, data, percentile_func, name=\"threshold\"):\n if isinstance(t... | [
"0.7370649",
"0.6820717",
"0.6663611",
"0.6351839",
"0.6257886",
"0.6181709",
"0.6176472",
"0.61548364",
"0.6131899",
"0.5963718",
"0.59134835",
"0.583714",
"0.57841104",
"0.57519346",
"0.5749945",
"0.571507",
"0.57088745",
"0.57036436",
"0.56767607",
"0.5676653",
"0.56705195... | 0.7772039 | 0 |
Get the start position of the gene locus | def locus_start(self):
return int(open(self.locus_file).read().split('\t')[3]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_start_loc(self) -> Tuple[int, int]:\n assert self.pos_marker\n return self.pos_marker.working_loc",
"def start_loc(self) -> str:\n return self._start_loc",
"def starting_position(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"starting_position\")",
"def... | [
"0.77073485",
"0.74084705",
"0.71206504",
"0.7031793",
"0.7027435",
"0.70186096",
"0.69944763",
"0.68277234",
"0.6802845",
"0.6798797",
"0.6798797",
"0.6798797",
"0.67664516",
"0.67396003",
"0.67304647",
"0.6725751",
"0.670482",
"0.6681209",
"0.6661813",
"0.66093403",
"0.6602... | 0.7950396 | 0 |
Get the stop position of the gene locus | def locus_stop(self):
return int(open(self.locus_file).read().split('\t')[4]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_end_loc(self) -> Tuple[int, int]:\n assert self.pos_marker\n return self.pos_marker.working_loc_after(\n self.raw,\n )",
"def get_feature_start_end(feature_record):\n return (feature_record.location.start.position+1, feature_record.location.end.position)",
"def get_re... | [
"0.67176384",
"0.6519938",
"0.63851106",
"0.62137026",
"0.61599874",
"0.60957605",
"0.6017166",
"0.5999214",
"0.5970096",
"0.59533167",
"0.58981377",
"0.58107245",
"0.56889755",
"0.56417394",
"0.5638737",
"0.5631604",
"0.5626625",
"0.5593594",
"0.55803275",
"0.55604434",
"0.5... | 0.7825671 | 0 |
Get the DNAsequence of this locus directory | def dnasequence(self):
return parseSingleFasta(open(self.dna_file).readlines())[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_seq(self):\n dna_seq = ''\n\n for exon in self.exons: \n dna_seq += self.rna.gene.polymer.get_subseq(\n start=exon.start, end=exon.end)\n\n if self.rna.gene.strand==core.PolymerStrand.negative:\n dna_seq = dna_seq.reverse_compleme... | [
"0.6546175",
"0.6482111",
"0.62228996",
"0.60724056",
"0.60136324",
"0.5968651",
"0.5957638",
"0.589398",
"0.58743834",
"0.5781113",
"0.57661885",
"0.57573223",
"0.5678389",
"0.5626131",
"0.5626131",
"0.5626131",
"0.5626131",
"0.5626131",
"0.5626131",
"0.5626131",
"0.5626131"... | 0.68442 | 0 |
Run getorf and parse the output into Orf objects | def rungetorf(self,input={}):
# handle potentially applied input argument
self._handle_input_subdict(input)
# check if orfs already predicted (in self.input data structure)
if not self.input['orfs']:
# predict ORFs on the dna sequence
_retstruct = rungetorf( { sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_orfs(gtf, args, config, is_annotated=False, is_de_novo=False):\n\n call = not args.do_not_call\n chr_name_file = os.path.join(config[\"star_index\"], \"chrName.txt\")\n chr_name_str = \"--chr-name-file {}\".format(chr_name_file)\n\n logging_str = logging_utils.get_logging_options_string(args)\n... | [
"0.6290331",
"0.62656677",
"0.60413593",
"0.5640268",
"0.55594075",
"0.5259529",
"0.51389754",
"0.5081033",
"0.5069715",
"0.50307995",
"0.49715823",
"0.4971297",
"0.4934135",
"0.49177998",
"0.49091518",
"0.48981243",
"0.4882644",
"0.48787394",
"0.48621264",
"0.48614228",
"0.4... | 0.6281931 | 1 |
Get Orf object from input['orfs'] by nt coords | def _get_orf_object_by_coords(self,start,end):
for orfobj in self.input['orfs'].orfs:
if orfobj.start == start and orfobj.end == end:
return orfobj
elif start == None and orfobj.end == end:
# used in case of SignalP output -> no Orf start coord given!
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rungetorf(self,input={}):\n # handle potentially applied input argument\n self._handle_input_subdict(input)\n # check if orfs already predicted (in self.input data structure)\n if not self.input['orfs']:\n # predict ORFs on the dna sequence\n _retstruct = runge... | [
"0.619472",
"0.5608206",
"0.558664",
"0.542973",
"0.52548337",
"0.5221989",
"0.51791555",
"0.5147351",
"0.51416075",
"0.5098306",
"0.5067999",
"0.5055612",
"0.50485295",
"0.5022125",
"0.4952155",
"0.49333888",
"0.49302658",
"0.48542315",
"0.48506433",
"0.4842785",
"0.4842272"... | 0.8008028 | 0 |
Helper function which makes a (nearempty) AbgpGeneLocusDirectory from a provided hdr and sequence | def make_abgpgenelocusdirectory_from_fasta(hdr,sequence,outdir):
safe_header = hdr.translate(NONLETTERS_TRANS).replace("_","")
unique_string = get_random_string_tag(10)
if not safe_header:
safe_header = unique_string
locus_dirname = os.path.join(outdir,"%s_%s" % (safe_header,unique_string))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_fasta_seqrecord(header, sequence_string):\n seq = Seq(sequence_string, alphabet=IUPAC.unambiguous_dna)\n seqrecord = SeqRecord(seq, description=header)\n return seqrecord",
"def make_beddir():\n bname = op.basename(ref).split(\".fa\")[0]\n beddir = makedir(op.join(op.dirname(ref), 'bedf... | [
"0.5109767",
"0.5049386",
"0.48798478",
"0.48655432",
"0.4839329",
"0.48375845",
"0.4768329",
"0.46519515",
"0.4636762",
"0.4630872",
"0.4607291",
"0.4541173",
"0.4538897",
"0.45248216",
"0.4523164",
"0.4519078",
"0.45128307",
"0.44850436",
"0.44771925",
"0.4461075",
"0.44587... | 0.7870412 | 0 |
Webscrapes and returns current market price for oil | def showCurrentPrice():
page = requests.get(
"https://markets.businessinsider.com/commodities/oil-price?type=wti"
)
soup = BeautifulSoup(page.text, "html.parser")
currentPrices = soup.find(class_="push-data")
price = str(currentPrices.next)
return price | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getprice():\n\n print(\"Get price\")\n latest_price = get_latest_price(item_code)\n return latest_price",
"def track_price():\n r = requests.get('https://finance.yahoo.com/quote/EURPLN=X?p=EURPLN%3DX&.tsrc=fin-srch&guce_referrer'\n '=aHR0cHM6Ly9maW5hbmNlLnlhaG9vLmNvbS8... | [
"0.707251",
"0.70618635",
"0.7043081",
"0.68868905",
"0.6844024",
"0.68342733",
"0.6802147",
"0.6749037",
"0.670365",
"0.6656732",
"0.6621097",
"0.65562546",
"0.6541665",
"0.6535046",
"0.6507033",
"0.6505526",
"0.6440425",
"0.64329547",
"0.6429208",
"0.6409872",
"0.6402895",
... | 0.76197255 | 0 |
Beendet die Replikation. Wird aufgerufen, wenn die Helicase nicht mehr gebunden ist. Wenn genug Nucleotide vorhanden sind, wird die Polymerase pro Step um 100 Nukelotide verschoben, sonst um die maximal moegliche Anzahl. Ist die Mitte der DNA erreicht, wird die Polymerase abgeloest | def terminate(self,DNA, Pol, Hel):
Helicase = Hel
PolymeraseIII = Pol
#print self.DNA.length, PolymeraseIII.position
#wenn pos= length helicase + polyIII fallen ab
if PolymeraseIII.bound == True:
if self.Nucleotide >= 200 :
PolymeraseIII.position += 100
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elongate(self,DNA, Pol, Hel):\n Helicase = Hel\n PolymeraseIII = Pol\n if self.ATP_molecules >= 100 and (Helicase.position - PolymeraseIII.position) < 3000: #genug ATP, Abstand klein genug\n Helicase.position += 100 \n self.ATP_molecules -= 100\n if self.Nu... | [
"0.59319",
"0.5858611",
"0.56021625",
"0.5557642",
"0.5428448",
"0.53653425",
"0.53559273",
"0.5313522",
"0.52209216",
"0.52209216",
"0.52209216",
"0.52209216",
"0.52209216",
"0.5220617",
"0.521062",
"0.5195131",
"0.5175415",
"0.5171143",
"0.5150962",
"0.51477975",
"0.5145308... | 0.59928906 | 0 |
Testet, ob ein Gen schon doppelt oder einfach vorliegt. Uebergeben werden muessen die DNAPolymerasen, sowie Start und Endpunkt des Gens auf dem Strang. return=2 fuer Gene, die schon repliziert wurden return=1 fuer noch nicht repliziert wurden | def gene_check(self,DNA,Pol_ac,Pol_c,gene_begin,gene_end):
PolymeraseIII_ac = Pol_ac
PolymeraseIII_c = Pol_c
if (gene_end < PolymeraseIII_c.position) or (gene_begin > (2*self.DNA.length-PolymeraseIII_ac.position)):
return 2
else:
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gene_finder(dna):\n all_orfs_both_strands = find_all_ORFs_both_strands(dna)\n longest_fake_orf = longest_ORF_noncoding(dna, 20)\n for element in all_orfs_both_strands:\n if len(element) > longest_fake_orf:\n a_a_string = coding_strand_to_AA(element)\n else:\n a_a_st... | [
"0.58322114",
"0.5767576",
"0.5685688",
"0.5657304",
"0.5654366",
"0.5649262",
"0.5512859",
"0.5488095",
"0.54644287",
"0.54175705",
"0.53916204",
"0.5375912",
"0.5336228",
"0.53010494",
"0.5297189",
"0.52929634",
"0.5282707",
"0.5276658",
"0.5259528",
"0.52401114",
"0.522686... | 0.57869226 | 1 |
Returns eigenvalues of the Laplacian of G | def laplacian_spectrum(G, weight="weight"):
import scipy as sp
return sp.linalg.eigvalsh(nx.laplacian_matrix(G, weight=weight).todense()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def laplacian_spectrum(G,weight='weight'):\n\n try:\n import numpy as np\n except ImportError:\n raise ImportError(\n \"laplacian_spectrum() requires NumPy: http://scipy.org/ \")\n return np.linalg.eigvals(laplacian(G,weight=weight))",
"def normalized_laplacian_spectrum(G, weight=... | [
"0.7259915",
"0.7060399",
"0.67791516",
"0.67284614",
"0.65521836",
"0.64682174",
"0.6402569",
"0.6390024",
"0.634835",
"0.63384664",
"0.63020295",
"0.62860316",
"0.62048584",
"0.62014985",
"0.61464214",
"0.61155266",
"0.60952044",
"0.60862386",
"0.6040493",
"0.60269195",
"0.... | 0.7270116 | 0 |
Return eigenvalues of the normalized Laplacian of G | def normalized_laplacian_spectrum(G, weight="weight"):
import scipy as sp
return sp.linalg.eigvalsh(
nx.normalized_laplacian_matrix(G, weight=weight).todense()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalized_laplacian_eig(A, k=None):\n n, m = A.shape\n ##\n ## TODO: implement checks on the adjacency matrix\n ##\n degs = _flat(A.sum(axis=1))\n # the below will break if\n inv_root_degs = [d ** (-1 / 2) if d > _eps else 0 for d in degs]\n inv_rootD = sps.spdiags(inv_root_degs, [0], ... | [
"0.7213387",
"0.7147146",
"0.7072728",
"0.6660331",
"0.6454285",
"0.64340556",
"0.64190364",
"0.63966185",
"0.637547",
"0.63489413",
"0.62351114",
"0.6224991",
"0.61925143",
"0.61410123",
"0.61347854",
"0.6046363",
"0.60389954",
"0.6030647",
"0.6021971",
"0.5990303",
"0.59651... | 0.75299346 | 0 |
Returns eigenvalues of the adjacency matrix of G. | def adjacency_spectrum(G, weight="weight"):
import scipy as sp
return sp.linalg.eigvals(nx.adjacency_matrix(G, weight=weight).todense()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjacency_spectrum(G,weight='weight'):\n try:\n import numpy as np\n except ImportError:\n raise ImportError(\n \"adjacency_spectrum() requires NumPy: http://scipy.org/ \")\n return np.linalg.eigvals(adj_matrix(G,weight=weight))",
"def analytical_eig(A):\n n = len(A)\n h... | [
"0.6891642",
"0.6423288",
"0.63983595",
"0.63027686",
"0.6252841",
"0.62505156",
"0.62104166",
"0.6199966",
"0.6188516",
"0.61684835",
"0.6147283",
"0.6067081",
"0.60523146",
"0.60511893",
"0.604462",
"0.6037283",
"0.60262215",
"0.5980188",
"0.59671223",
"0.59646595",
"0.5949... | 0.68891317 | 1 |
Returns eigenvalues of the modularity matrix of G. | def modularity_spectrum(G):
import scipy as sp
if G.is_directed():
return sp.linalg.eigvals(nx.directed_modularity_matrix(G))
else:
return sp.linalg.eigvals(nx.modularity_matrix(G)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eigenvalues(self) -> ndarray:\n return self._vals",
"def get_E(J,k):\n E = -2 * J * np.cos(k) # energyeigenvalue \n return E",
"def GetEigenvalues(self, eigenvalues):\n return _hypre.HypreLOBPCG_GetEigenvalues(self, eigenvalues)",
"def eigensystem(mat):\n e, v = numpy.... | [
"0.6733166",
"0.6702884",
"0.66992486",
"0.642786",
"0.6406916",
"0.639992",
"0.6356925",
"0.63515425",
"0.63438994",
"0.6328765",
"0.63085186",
"0.627732",
"0.6240069",
"0.62371206",
"0.6185818",
"0.61492646",
"0.6118799",
"0.6094602",
"0.60107183",
"0.60083413",
"0.60064334... | 0.72664213 | 0 |
Create the element for the given octant. This callback provides the global indices for the filter mesh and the weights applied to each nodal density value to obtain the element density. The local octant is also provided (but not used here). | def createElement(self, order, octant, index, weights):
return self.element | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createNodeElement(_session, _segment, _const):\n return createNode(_session, _segment, _const, \"element\")",
"def _createVetor(cls, elem):\n return cls(elem)",
"def _create(self, creation_type: str = \"Uniform\"):\n if creation_type == \"Uniform\":\n number_of_vectors = comb(\n... | [
"0.51621693",
"0.48073286",
"0.46622384",
"0.45329916",
"0.4529173",
"0.44532076",
"0.44458538",
"0.4413116",
"0.44013977",
"0.43910643",
"0.4382894",
"0.4368806",
"0.43577817",
"0.43466914",
"0.42872855",
"0.42810267",
"0.42793715",
"0.42689186",
"0.42629996",
"0.4261509",
"... | 0.6639912 | 0 |
Create the creator class and filter for the provided OctForest object. This is called for every mesh level when the topology optimization problem is created. | def creator_callback(self, forest):
creator = OctCreator(self.bcs, forest, props=self.props)
return creator, forest | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build(self, prefilt=None):\n self.make_filiation()\n if prefilt is not None:\n self.prefilter(filt=prefilt)\n self.make_trees()\n return",
"def create_forest(comm, depth, htarget=5.0, filename=\"cantilever.stp\"):\n # Load the geometry model\n geo = TMR.LoadModel... | [
"0.5907212",
"0.58128744",
"0.5548508",
"0.54969114",
"0.5438149",
"0.5436613",
"0.5411292",
"0.5390005",
"0.5380561",
"0.53719646",
"0.5296009",
"0.5213716",
"0.5103126",
"0.50868624",
"0.50765324",
"0.5011517",
"0.50012755",
"0.49834257",
"0.49831927",
"0.49813673",
"0.4980... | 0.60544777 | 0 |
Create an initial forest for analysis and optimization This code loads in the model, sets names, meshes the geometry and creates a QuadForest from the mesh. The forest is populated with quadtrees with the specified depth. | def create_forest(comm, depth, htarget=5.0, filename="cantilever.stp"):
# Load the geometry model
geo = TMR.LoadModel(filename)
# Mark the boundary condition faces
verts = geo.getVertices()
faces = geo.getFaces()
volumes = geo.getVolumes()
# Set source and target faces
faces[3].setName... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_forest(self, verbose):\n _antecessors = []\n for key, cluster in self.clusters.items():\n if cluster.leaf_cluster is True:\n _antecessors.append(cluster.antecessor)\n _antecessors = remdup_preserve_order(_antecessors)\n _antecessors = sorted(_antecessors, key=get_cluster_idx, ... | [
"0.5743726",
"0.55672914",
"0.5471897",
"0.53624874",
"0.53486174",
"0.5271481",
"0.5220773",
"0.5185084",
"0.51685864",
"0.5139653",
"0.5102182",
"0.5085573",
"0.50668144",
"0.50427955",
"0.5023448",
"0.502102",
"0.5018734",
"0.49619636",
"0.49612683",
"0.49424347",
"0.49385... | 0.6790161 | 0 |
Create the TMRTopoProblem object and set up the topology optimization problem. This code is given the forest, boundary conditions, material properties and the number of multigrid levels. Based on this info, it creates the TMRTopoProblem and sets up the massconstrained compliance minimization problem. Before the problem... | def create_problem(
forest, bcs, props, nlevels, vol_frac=0.25, density=2600.0, iter_offset=0
):
# Characteristic length of the domain
len0 = 10.0
r0_frac = 0.05
N = 20
# Create the problem and filter object
mfilter = MFilterCreator(r0_frac, N, a=len0)
filter_type = mfilter.filter_call... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, para, ini_cond):\n\n # grid\n self.z = np.linspace(0, para['grid']['zmax'], para['grid']['Nlayers']) # grid [m] above ground\n self.dz = self.z[1] - self.z[0] # gridsize [m]\n self.ones = np.ones(len(self.z)) # dummy\n self.zref = para['zref'] # height of fo... | [
"0.561233",
"0.5598695",
"0.5516206",
"0.55082023",
"0.54308045",
"0.5411817",
"0.5386293",
"0.5379348",
"0.53286433",
"0.5291673",
"0.5284003",
"0.5240421",
"0.51778615",
"0.5159496",
"0.5159075",
"0.51514286",
"0.5132344",
"0.5131389",
"0.51095265",
"0.5104428",
"0.510223",... | 0.63748044 | 0 |
Plots the difference in unemployment between Norway and USA. | def plot_relative_unemployment(norway, usa):
# Use the dates from Norway as x-axis
x = norway[0]
# Calculate the difference between Norway and USA
y = [usa[1][i] - norway[1][i] for i in range(len(norway[1]))]
# Create the plot
fig = go.Figure(layout=layout)
fig.add_trace(go.Scatter(x=x, y... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_unemployment():\n\n # Create the plot\n fig = go.Figure(layout=layout)\n\n # Plot the data from Norway\n norway = get_norway()\n fig.add_trace(go.Scatter(x=norway[0], y=norway[1], mode=\"lines+markers\", name=\"Norway\"))\n\n # Plot the data from USA\n usa = get_usa()\n fig.add_tra... | [
"0.7226451",
"0.5727417",
"0.5417691",
"0.5404283",
"0.5337053",
"0.5313546",
"0.52084684",
"0.51725113",
"0.5169662",
"0.51440084",
"0.5119941",
"0.51021814",
"0.5099616",
"0.5067583",
"0.5065785",
"0.5057951",
"0.5056406",
"0.504999",
"0.50293845",
"0.50276244",
"0.4997353"... | 0.7231196 | 0 |
Plots the unemployment rate of Norway and USA. The result is an html file with the plot. | def plot_unemployment():
# Create the plot
fig = go.Figure(layout=layout)
# Plot the data from Norway
norway = get_norway()
fig.add_trace(go.Scatter(x=norway[0], y=norway[1], mode="lines+markers", name="Norway"))
# Plot the data from USA
usa = get_usa()
fig.add_trace(go.Scatter(x=usa[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_relative_unemployment(norway, usa):\n\n # Use the dates from Norway as x-axis\n x = norway[0]\n\n # Calculate the difference between Norway and USA\n y = [usa[1][i] - norway[1][i] for i in range(len(norway[1]))]\n\n # Create the plot\n fig = go.Figure(layout=layout)\n fig.add_trace(go... | [
"0.7380092",
"0.5902878",
"0.58946776",
"0.57200336",
"0.5568791",
"0.5477208",
"0.5449444",
"0.54090005",
"0.53779197",
"0.5367056",
"0.5335279",
"0.5317123",
"0.527646",
"0.52451736",
"0.52193046",
"0.5216275",
"0.5206476",
"0.5199765",
"0.51784766",
"0.5172489",
"0.5152362... | 0.8006811 | 0 |
Plots the covid cases in Norway and USA per 100 000 citizen. | def plot_relative_covid(norway, usa):
pop_norway = get_norway_population()
pop_usa = get_usa_population()
# Calculate the number of cases per 100 000 citizen
for i, val in enumerate(norway[1]):
norway[1][i] = (val * 100000) / pop_norway
for i, val in enumerate(usa[1]):
usa[1][i] = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_covid():\n\n norway, usa = get_covid()\n _plot_covid(norway[0], norway[1], \"Norway\", \"12 Mar 2020\", \"#636efa\", \"#ef553b\")\n _plot_covid(usa[0], usa[1], \"USA\", \"22 Mar 2020\", \"#ef553b\", \"#636efa\")\n\n plot_relative_covid(norway, usa)",
"def plotCaliCoverage(constants, data, ou... | [
"0.69711107",
"0.6399468",
"0.62426513",
"0.6178845",
"0.61452097",
"0.613694",
"0.6128832",
"0.61033636",
"0.6096911",
"0.60663915",
"0.6007003",
"0.598395",
"0.5964565",
"0.5954614",
"0.5911071",
"0.5860643",
"0.57960933",
"0.5762149",
"0.5749039",
"0.570125",
"0.57004666",... | 0.6726965 | 1 |
Plots the number of Covid cases per day for Norway and USA. | def plot_covid():
norway, usa = get_covid()
_plot_covid(norway[0], norway[1], "Norway", "12 Mar 2020", "#636efa", "#ef553b")
_plot_covid(usa[0], usa[1], "USA", "22 Mar 2020", "#ef553b", "#636efa")
plot_relative_covid(norway, usa) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_new_cases(data, case_type, country, province):\n # Copy the identifying columns on geography\n identifier = data[case_type][[\n 'province/state', 'country/region', 'lat', 'long']]\n\n # Insert first column\n col = data[case_type].iloc[:, 4]\n daily_new = col.to_frame()\... | [
"0.684806",
"0.671814",
"0.63959306",
"0.6374826",
"0.6363994",
"0.6356796",
"0.6186294",
"0.6184675",
"0.6169266",
"0.60575324",
"0.60035706",
"0.58864385",
"0.58654237",
"0.57761854",
"0.57707185",
"0.57450664",
"0.5744827",
"0.5701265",
"0.56952673",
"0.5684716",
"0.568297... | 0.68396235 | 1 |
Combines template.html with the plots. The resulting file (document.html) is the finished report. | def update_template():
# Open, and read, the template file
with open("template.html", "r") as f:
soup = BeautifulSoup(f.read(), features="html5lib")
# Add the plots in the correct places
for div in soup.find_all("div", class_="plot"):
with open(div["src"], "r") as f:
plot =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_html(self, workdir, templatePath, imgFormat):\n plot_tables = []\n plot_set = [ self._expectedPlots_globalAvg, self._expectedPlots_Nino, self._expectedPlots_transportDiags ]\n\n # build up the plot_tables array\n for k in range(len(plot_set)):\n plot_table = []\n ... | [
"0.6883802",
"0.6878068",
"0.66666186",
"0.64968467",
"0.64968467",
"0.64845616",
"0.64245784",
"0.640758",
"0.61694556",
"0.61353934",
"0.6066713",
"0.6010698",
"0.5984748",
"0.59806466",
"0.5980271",
"0.59713936",
"0.59706545",
"0.5967902",
"0.5935875",
"0.59337777",
"0.592... | 0.7910929 | 0 |
Get last 100 received thread invitations as current user {GET} /threads/invitations | def get(self):
# Send request
response = self._get(
url="/threads/invitations"
)
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_inbox(request):\n threads = models.MessageThread.objects.filter(clients=request.user).annotate(\n unread_count=Count('receipts',filter=Q(receipts__recipient=request.user))\n )\n thread_data = serializers.MessageThreadListSerializer(threads).data\n #user = userauth_models.User.objects.fi... | [
"0.57735765",
"0.5764456",
"0.5692115",
"0.56652117",
"0.5647309",
"0.563999",
"0.559273",
"0.554745",
"0.5526691",
"0.54903305",
"0.5490243",
"0.5473487",
"0.540215",
"0.5381637",
"0.5314287",
"0.5308518",
"0.52921236",
"0.527585",
"0.52751327",
"0.5251491",
"0.5239493",
"... | 0.7255056 | 0 |
Will generate a pair of paillier keys bits>5 | def generate_keypair(bits):
p = generate_prime(bits // 2)
#print(p)
q = generate_prime(bits // 2)
#print(q)
n = p * q
return PrivateKey(p, q, n), PublicKey(n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keyGen(key):\n def leftShift(keyBitList):\n \"\"\"Perform a circular left shift on the first and second five bits\"\"\"\n shiftedKey = [None] * KeyLength\n shiftedKey[0:9] = keyBitList[1:10]\n shiftedKey[4] = keyBitList[0]\n shiftedKey[9] = keyBitList[5]\n return sh... | [
"0.6590828",
"0.6445614",
"0.63969773",
"0.6334846",
"0.62564373",
"0.6255874",
"0.6244861",
"0.62422985",
"0.62344897",
"0.6178638",
"0.61746866",
"0.61475027",
"0.6132954",
"0.6094661",
"0.60662895",
"0.6065656",
"0.59602463",
"0.595464",
"0.5920666",
"0.59159654",
"0.59086... | 0.70014495 | 0 |
Multiplies an encrypted integer by a constant | def enc_mul_const(pub, m, c):
mul_result = powmod(m, c, pub.n_sq)
return mul_result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateCrypt(asci: int, e: int, n: int) -> int:\n return pow(int(asci),e,n)",
"def multiply(number, word):\n return int(number) * word",
"def __mul__(self, other):\n if isinstance(other, EncryptedNumber):\n raise NotImplementedError('Good luck with that...')\n if other < 0:... | [
"0.65029836",
"0.64592296",
"0.6372637",
"0.6315182",
"0.6280013",
"0.6276835",
"0.62599325",
"0.6153875",
"0.61174214",
"0.60960615",
"0.60558856",
"0.6050294",
"0.6037608",
"0.6001841",
"0.5989072",
"0.59175265",
"0.59151715",
"0.5910307",
"0.5877904",
"0.58693033",
"0.5810... | 0.69548327 | 0 |
This function does the actual rendering, for render and the template_filter render_knowl_in_template (ultimately for KNOWL_INC) | def render_knowl_in_template(knowl_content, **kwargs):
render_me = u"""\
{%% include "knowl-defs.html" %%}
{%% from "knowl-defs.html" import KNOWL with context %%}
{%% from "knowl-defs.html" import KNOWL_LINK with context %%}
{%% from "knowl-defs.html" import KNOWL_INC with context %%}
{%% from "knowl-def... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(request, *args, **kw):",
"def render_knowl(ID, footer=None, kwargs=None,\n raw=False, k=None, allow_deleted=False, timestamp=None):\n # logger.debug(\"kwargs: %s\", request.args)\n kwargs = kwargs or dict(((k, v) for k, v in request.args.items()))\n # logger.debug(\"kwargs: %s\" , kwar... | [
"0.62964994",
"0.6087797",
"0.6017588",
"0.60043824",
"0.59678346",
"0.5926979",
"0.59199613",
"0.5917015",
"0.5874543",
"0.5777651",
"0.57690376",
"0.5651171",
"0.56243455",
"0.56133586",
"0.5611126",
"0.56095123",
"0.5598745",
"0.5584766",
"0.55800945",
"0.5577091",
"0.5568... | 0.6635778 | 0 |
this method renders the given Knowl (ID) to insert it dynamically in a website. It is intended to be used by an AJAX call, but should do a similar job serverside only, too. Note, that the used knowlrender.html template is not based on any globally defined website and just creates a small and simple html snippet! the ke... | def render_knowl(ID, footer=None, kwargs=None,
raw=False, k=None, allow_deleted=False, timestamp=None):
# logger.debug("kwargs: %s", request.args)
kwargs = kwargs or dict(((k, v) for k, v in request.args.items()))
# logger.debug("kwargs: %s" , kwargs)
if timestamp is None:
# fetch and co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_knowl_in_template(knowl_content, **kwargs):\n render_me = u\"\"\"\\\n {%% include \"knowl-defs.html\" %%}\n {%% from \"knowl-defs.html\" import KNOWL with context %%}\n {%% from \"knowl-defs.html\" import KNOWL_LINK with context %%}\n {%% from \"knowl-defs.html\" import KNOWL_INC with context %%}... | [
"0.6210805",
"0.55757034",
"0.54341483",
"0.53861177",
"0.5347136",
"0.5274865",
"0.52664876",
"0.5237727",
"0.5203966",
"0.51898915",
"0.5178765",
"0.5157696",
"0.51237744",
"0.51210696",
"0.51108015",
"0.5103956",
"0.5098594",
"0.5065835",
"0.5062791",
"0.5060782",
"0.50483... | 0.7056656 | 0 |
Set the dataset meta info to the metric. | def dataset_meta(self, dataset_meta: dict) -> None:
self._dataset_meta = dataset_meta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_metadata(self, data):\r\n pass",
"def meta_data(self, meta_data):\n\n self._meta_data = meta_data",
"def meta(self, meta):\n\n self._meta = meta",
"def meta(self, meta):\n\n self._meta = meta",
"def set_metadata(self, attribute, value):\n self.metadata[attribute] ... | [
"0.7113873",
"0.6959133",
"0.6804629",
"0.6804629",
"0.6615271",
"0.65601104",
"0.65385044",
"0.6381809",
"0.63681597",
"0.63217694",
"0.62548214",
"0.6202046",
"0.6186504",
"0.6185495",
"0.61761415",
"0.61761415",
"0.61761415",
"0.61761415",
"0.61761415",
"0.61761415",
"0.61... | 0.7728363 | 0 |
Compute the metrics from processed results. | def compute_metrics(self, results: list) -> dict: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_metrics(self):\n pass",
"def compute_metrics(self, results: list) -> dict:\n dump(results, self.out_file_path)\n print_log(\n f'Results has been saved to {self.out_file_path}.',\n logger='current')\n return {}",
"def compute_metrics(self):\n ... | [
"0.78212637",
"0.75160414",
"0.74581647",
"0.73755676",
"0.7322359",
"0.7322359",
"0.71207654",
"0.70953584",
"0.7016177",
"0.6922528",
"0.68572897",
"0.68020445",
"0.67422473",
"0.6734681",
"0.6723987",
"0.6684012",
"0.6667367",
"0.6637155",
"0.6622409",
"0.6586669",
"0.6579... | 0.8416106 | 0 |
transfer tensors in predictions to CPU. | def process(self, data_batch: Any, predictions: Sequence[dict]) -> None:
self.results.extend(_to_cpu(predictions)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_prediction(self):\r\n self.get_prediction_indices()\r\n self.walk_forward_prediction()",
"def eval_cpu(prediction_dataloader, model):\n # Put model in evaluation mode\n model.eval() \n\n predictions = []\n\n # Predict \n for batch in prediction_dataloader:\n batc... | [
"0.65521014",
"0.64465463",
"0.63249093",
"0.63161856",
"0.62496567",
"0.6223502",
"0.613773",
"0.61376125",
"0.6113582",
"0.60915965",
"0.6058114",
"0.60571307",
"0.603195",
"0.6005879",
"0.599654",
"0.59947586",
"0.59946436",
"0.5993679",
"0.59894407",
"0.5977644",
"0.59651... | 0.66616493 | 0 |
To correct for chemical perception issues with possible resonance states of arginine, remove all charge from the guanidinium group, and set all bond orders to 4. This will mark the resonant bonds with a unique "$" character in the SMARTS, which we can later replace. | def remove_charge_and_bond_order_from_guanidinium(offmol):
for atom in offmol.atoms:
if atom.element.symbol != "C":
continue
nitrogen_neighbors = 0
for neighbor in atom.bonded_atoms:
if neighbor.element.symbol == "N":
nitrogen_neighbors += 1
if nitrogen_neighbors != 3:
contin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_charge_and_bond_order_from_imidazole(offmol):\n matches = offmol.chemical_environment_matches('[C:1]1~[C:2]~[N:3]~[C:4]~[N:5]1')\n all_imidazole_atoms = set()\n for match in matches:\n for idx in match:\n all_imidazole_atoms.add(idx)\n\n for atom in offmol.atoms:\n if atom.molecule_atom_i... | [
"0.60058707",
"0.5936393",
"0.55313337",
"0.5474705",
"0.5327461",
"0.5131094",
"0.512167",
"0.5119501",
"0.50199974",
"0.49962187",
"0.49056014",
"0.49054185",
"0.48918006",
"0.48838916",
"0.4854412",
"0.4842166",
"0.48315072",
"0.48311853",
"0.4814759",
"0.47966436",
"0.479... | 0.6787749 | 0 |
To correct for chemical perception issues with possible resonance states of histidine, remove all charge from the imidazole group, and set all bond orders to 4. This will mark the resonant bonds with a unique "$" character in the SMARTS, which we can later replace. | def remove_charge_and_bond_order_from_imidazole(offmol):
matches = offmol.chemical_environment_matches('[C:1]1~[C:2]~[N:3]~[C:4]~[N:5]1')
all_imidazole_atoms = set()
for match in matches:
for idx in match:
all_imidazole_atoms.add(idx)
for atom in offmol.atoms:
if atom.molecule_atom_index in all_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_charge_and_bond_order_from_guanidinium(offmol):\n for atom in offmol.atoms:\n if atom.element.symbol != \"C\":\n continue\n nitrogen_neighbors = 0\n for neighbor in atom.bonded_atoms:\n if neighbor.element.symbol == \"N\":\n nitrogen_neighbors += 1\n if nitrogen_neighbors !... | [
"0.6607051",
"0.61745477",
"0.59384525",
"0.5661288",
"0.5392464",
"0.5363626",
"0.5275415",
"0.5261481",
"0.52120835",
"0.52036256",
"0.5198679",
"0.5152463",
"0.5132513",
"0.5093022",
"0.5080391",
"0.50160897",
"0.4995986",
"0.49599898",
"0.49497703",
"0.49257922",
"0.48355... | 0.6892059 | 0 |
Get the SMARTS corresponding to a list of atom indices | def get_smarts(prefix, atom_idxs):
offmol = Molecule.from_file(prefix + '.mol2')
fix_carboxylate_bond_orders(offmol)
remove_charge_and_bond_order_from_guanidinium(offmol)
remove_charge_and_bond_order_from_imidazole(offmol)
if prefix in prefix2pmd_struct:
pmd_struct = prefix2pmd_struct[prefix]
else: ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetSpectraFromIndexList(all_wl,all_spectra,idx_list):\n NBSPEC=len(all_spectra)\n \n \n all_wl_sel=[]\n all_spectra_sel=[]\n \n for idx in np.arange(0,NBSPEC):\n if idx in idx_list:\n all_wl_sel.append(all_wl[idx])\n all_spectra_sel.append(all_spectra[idx])\n ... | [
"0.6344887",
"0.59205484",
"0.57140833",
"0.57140833",
"0.55560106",
"0.5451238",
"0.5425908",
"0.5410789",
"0.53920984",
"0.53697795",
"0.5368882",
"0.535143",
"0.5306481",
"0.5296508",
"0.5222064",
"0.5216659",
"0.5172254",
"0.51720744",
"0.5169743",
"0.51569635",
"0.513482... | 0.66229403 | 0 |
Returns True if this exact dihedral (periodicity, k, phase, idivf) is already defined under this SMIRKS. This is useful in cases where we might see the same dihedral term multiple times and want to check whether a particular periodicity term is already known and shouldn't be repeated (for example, the two CYX residues ... | def dihedral_term_already_defined(dihe_dict, k, phase, periodicity, idivf):
existing_index = 1
while f'k{existing_index}' in dihe_dict.keys():
if ((dihe_dict[f'k{existing_index}'] == k) and
(dihe_dict[f'phase{existing_index}'] == phase) and
(dihe_dict[f'periodicity{existing_index}'] == periodici... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_dihedral(self):\n if self._is_dihedral is not None:\n return self._is_dihedral\n\n order = self.order()\n\n if order % 2 == 1:\n self._is_dihedral = False\n return False\n if order == 2:\n self._is_dihedral = True\n return Tr... | [
"0.6675791",
"0.6134677",
"0.59773755",
"0.57644665",
"0.56748974",
"0.564646",
"0.5628849",
"0.556478",
"0.55057836",
"0.5488828",
"0.53959185",
"0.532975",
"0.52963567",
"0.52935517",
"0.5288566",
"0.5284165",
"0.5278328",
"0.52768433",
"0.5243487",
"0.52430713",
"0.5231521... | 0.8116332 | 0 |
Resolve the variable, or return the value passed to it in the first place | def resolve(var, context):
try:
return var.resolve(context)
except template.VariableDoesNotExist:
return var.var | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve(self, var, context):\n if var[0] in ('\"', \"'\") and var[-1] == var[0]:\n return var[1:-1]\n else:\n return Variable(var).resolve(context)",
"def resolve(self, var, context):\n if var[0] in ('\"', \"'\") and var[-1] == var[0]:\n return var[1:-1]\... | [
"0.73858976",
"0.73858976",
"0.6914317",
"0.68937397",
"0.6877633",
"0.67908216",
"0.64995795",
"0.64905995",
"0.6349942",
"0.6220589",
"0.61456454",
"0.60508025",
"0.60163707",
"0.60101354",
"0.59987104",
"0.59772396",
"0.58101857",
"0.57931876",
"0.57739353",
"0.5772209",
"... | 0.7448513 | 0 |
Return a new mapping of the qubits. It goes through self._saved_commands and tries to find a mapping to apply these gates on a first come first served basis. It reuses the function of a 1D mapper and creates a mapping for a 1D linear chain and then wraps it like a snake onto the square grid. One might create better map... | def _return_new_mapping(self):
# Change old mapping to 1D in order to use LinearChain heuristic
if self._current_row_major_mapping:
old_mapping_1d = {}
for logical_id, mapped_id in self._current_row_major_mapping.items():
old_mapping_1d[logical_id] = self._map_2d_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _run(self): # pylint: disable=too-many-locals.too-many-branches,too-many-statements\n num_of_stored_commands_before = len(self._stored_commands)\n if not self.current_mapping:\n self.current_mapping = {}\n else:\n self._send_possible_commands()\n if len(se... | [
"0.5775415",
"0.5472546",
"0.5457559",
"0.5442311",
"0.53370285",
"0.521329",
"0.52080417",
"0.5194102",
"0.5163259",
"0.51357317",
"0.5117319",
"0.5102718",
"0.51001257",
"0.50929075",
"0.50659585",
"0.5053862",
"0.50113875",
"0.49969497",
"0.49958226",
"0.49663627",
"0.4965... | 0.6828302 | 0 |
If swapped (inplace), then return swap operation so that key(element0) < key(element1). | def _compare_and_swap(self, element0, element1, key):
if key(element0) > key(element1):
mapped_id0 = element0.current_column + element0.current_row * self.num_columns
mapped_id1 = element1.current_column + element1.current_row * self.num_columns
swap_operation = (mapped_id0, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap(self):\n return _coconut_tail_call(Eq, self.b, self.a)",
"def swap((u, v)):\n return (v, u)",
"def __elementSwap(self,\n index1: int,\n index2: int):\n self.__ordered_holder[index1], self.__ordered_holder[index2] = self.__ordered_holder[index2... | [
"0.5953973",
"0.5920716",
"0.5891269",
"0.57867384",
"0.57297826",
"0.5721775",
"0.5698104",
"0.5666503",
"0.56626624",
"0.5658265",
"0.56564546",
"0.5646911",
"0.56094223",
"0.5571082",
"0.55625135",
"0.55528694",
"0.55442584",
"0.5543415",
"0.55414706",
"0.55372673",
"0.553... | 0.7868407 | 0 |
Send the stored commands possible without changing the mapping. | def _send_possible_commands(self): # pylint: disable=too-many-branches
active_ids = deepcopy(self._currently_allocated_ids)
for logical_id in self._current_row_major_mapping:
# So that loop doesn't stop before AllocateGate applied
active_ids.add(logical_id)
new_stored_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_command(self, commands):\n action_space = self.action_space\n commands = np.clip(commands, action_space.low, action_space.high)\n i = 0\n joint_commands = {}\n for joint in self._used_joints:\n joint_commands[joint] = commands[i]\n i += 1\n\n ... | [
"0.69433117",
"0.6786136",
"0.6724367",
"0.65342885",
"0.65274376",
"0.6501102",
"0.64962757",
"0.6452933",
"0.64433986",
"0.63641334",
"0.6269014",
"0.6264307",
"0.6246121",
"0.6176289",
"0.6171755",
"0.61665565",
"0.6115516",
"0.61027396",
"0.6061256",
"0.603324",
"0.602872... | 0.6936952 | 1 |
Create a new mapping and executes possible gates. It first allocates all 0, ..., self.num_qubits1 mapped qubit ids, if they are not already used because we might need them all for the swaps. Then it creates a new map, swaps all the qubits to the new map, executes all possible gates, and finally deallocates mapped qubit... | def _run(self): # pylint: disable=too-many-locals.too-many-branches,too-many-statements
num_of_stored_commands_before = len(self._stored_commands)
if not self.current_mapping:
self.current_mapping = {}
else:
self._send_possible_commands()
if len(self._stored_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_queries_qrels_new_ids(self):\n self.dict_mapper_old_to_new_qid = {}\n self.count_subtasks = {}\n self.dict_missingqueries = {}\n self.dict_assessed_queries = self.get_queries_assessed()\n self.map_old_qid_to_new()\n self.map_qrels_to_newqids()\n exit()... | [
"0.5897",
"0.5667038",
"0.55281574",
"0.5508988",
"0.538626",
"0.51828766",
"0.5163915",
"0.5136017",
"0.51119363",
"0.51073563",
"0.50950164",
"0.5085504",
"0.5080595",
"0.508058",
"0.5068446",
"0.5056068",
"0.50365084",
"0.49873877",
"0.4965752",
"0.4964577",
"0.49474922",
... | 0.62740016 | 0 |
Receive a list of commands. Receive a command list and, for each command, stores it until we do a mapping (FlushGate or Cache of stored commands is full). | def receive(self, command_list):
for cmd in command_list:
if isinstance(cmd.gate, FlushGate):
while self._stored_commands:
self._run()
self.send([cmd])
else:
self._stored_commands.append(cmd)
# Storage is ful... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive(self, command_list):\n for cmd in command_list:\n self._send_cmd_with_mapped_ids(cmd)",
"def receive(self, command_list):\n for cmd in command_list:\n self._handle_command(cmd)",
"def receive(self, command_list):\n for cmd in command_list:\n if ... | [
"0.8027519",
"0.77966726",
"0.76843834",
"0.6712189",
"0.6083511",
"0.5970459",
"0.59575194",
"0.59414506",
"0.58542866",
"0.58185494",
"0.58040476",
"0.5798971",
"0.57877177",
"0.57834053",
"0.57743245",
"0.57696056",
"0.5751746",
"0.5740803",
"0.5719902",
"0.5718472",
"0.56... | 0.83096355 | 0 |
SGD with momentum and gradient clipping | def sgdmgc(cost, params, lr=1.0, alpha=0.1, max_magnitude=5.0, infDecay=0.1):
grads = T.grad(cost=cost, wrt=params)
updates = []
norm = norm_gs(params, grads)
sqrtnorm = T.sqrt(norm)
not_finite = T.or_(T.isnan(sqrtnorm), T.isinf(sqrtnorm))
adj_norm_gs = T.switch(T.ge(sqrtnorm, max_magnitude), m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sgd(cost, params, lr=1.0, alpha=0.1):\n grads = T.grad(cost=cost, wrt=params)\n updates = []\n for p, g in zip(params, grads):\n v = shared(p.get_value() * 0.)\n v_new = v * (1.0 - alpha) - alpha * lr * g\n updates.append((v, v_new))\n updates.append((p, p + v_new )) #+ T.... | [
"0.6515423",
"0.6467896",
"0.6360838",
"0.63439536",
"0.6194156",
"0.6018094",
"0.59948224",
"0.59542906",
"0.59356433",
"0.5926075",
"0.5922897",
"0.5922328",
"0.5892434",
"0.58728117",
"0.58543175",
"0.58291054",
"0.5824617",
"0.5823849",
"0.581078",
"0.57923365",
"0.579233... | 0.6483405 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.