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 |
|---|---|---|---|---|---|---|
Take conversation text and calculates the confidence score using Watson Tone Analyzer | def analyze_tone(conversation):
tone_analyzer = ToneAnalyzerV3Beta(username=WATSON_USERNAME,password=WATSON_PASSWORD,version=WATSON_API_VERSION)
tone_response = tone_analyzer.tone(conversation)
confidence = tone_response['document_tone']['tone_categories'][1]['tones'][1]['score']
return confidence | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyze(self, text):\n\n # start from 0 for each Analyser variable\n self.positives = 0\n self.negatives = 0\n\n # precise self text value\n self.text = text\n\n # declare a tokenased word\n tokenizer = nltk.tokenize.TweetTokenizer()\n tokens = tokenizer.... | [
"0.65629125",
"0.643105",
"0.638353",
"0.6379149",
"0.63738453",
"0.635537",
"0.6338651",
"0.63331306",
"0.6307086",
"0.6306271",
"0.62828654",
"0.6266538",
"0.62520146",
"0.6215256",
"0.621029",
"0.6186863",
"0.61214954",
"0.61082006",
"0.6096289",
"0.6078521",
"0.60707635",... | 0.7215387 | 0 |
Return a dictionary of crime categories and sum of crimes. | def get_crimes_by_category(self):
result = {}
for crime in self.crimes:
cat_name = crime.category.category_name
if cat_name in result:
result[cat_name] += 1
else:
result[cat_name] = 1
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_crimes(cs:CrimeStatistics)-> int:\n # return 0 # stub\n #template from atomic\n crimes_total = (cs.violent_crimes+cs.property_crimes+cs.arson)\n return crimes_total",
"def get_coordinates_by_category(self):\n\n result = {}\n for crime in self.crimes:\n cat_name = crim... | [
"0.644157",
"0.61237645",
"0.5664426",
"0.56131846",
"0.556375",
"0.55603516",
"0.5524103",
"0.5414242",
"0.5403029",
"0.5379142",
"0.53707236",
"0.5358697",
"0.53495306",
"0.5344111",
"0.5340817",
"0.5312425",
"0.53085023",
"0.53033715",
"0.5292981",
"0.5292524",
"0.5218506"... | 0.8110491 | 0 |
Return a dictionary of crime categories and list of coordinates. | def get_coordinates_by_category(self):
result = {}
for crime in self.crimes:
cat_name = crime.category.category_name.strip()
if cat_name in result:
result[cat_name].append((crime.latitude, crime.longitude))
else:
result[cat_name] = [(c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_crimes_by_category(self):\n\n result = {}\n for crime in self.crimes:\n cat_name = crime.category.category_name\n if cat_name in result:\n result[cat_name] += 1\n else:\n result[cat_name] = 1\n \n return resu... | [
"0.6538004",
"0.603138",
"0.5898592",
"0.58867985",
"0.5820991",
"0.56723803",
"0.5661209",
"0.55859613",
"0.5483333",
"0.5474434",
"0.54702455",
"0.54404277",
"0.5436366",
"0.54201627",
"0.53648657",
"0.5358755",
"0.531535",
"0.52981925",
"0.529552",
"0.528204",
"0.5281181",... | 0.8434634 | 0 |
return the route id | def get_route_id(self):
return self.route_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RouteID(self):\n route_id = self.SR\n if self.RRT:\n route_id += self.RRT\n if self.RRQ:\n route_id += self.RRQ\n return route_id",
"def route_map_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"route_map_id\")",
"def route_idx(se... | [
"0.7587031",
"0.7087121",
"0.694256",
"0.690186",
"0.68969196",
"0.67987394",
"0.67987394",
"0.67798674",
"0.67798674",
"0.6695325",
"0.6695325",
"0.66084903",
"0.66054034",
"0.6564537",
"0.6547674",
"0.65456295",
"0.65456295",
"0.65456295",
"0.65456295",
"0.6486264",
"0.6469... | 0.85870904 | 0 |
Make causal mask used for bidirectional selfattention. | def _make_causal_mask(
input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device, past_key_values_length: int = 0
):
bsz, tgt_len = input_ids_shape
mask = torch.full((tgt_len, tgt_len), torch.finfo(dtype).min, device=device)
mask_cond = torch.arange(mask.size(-1), device=device)
mask.mas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_attention_mask_3d_causal(source_mask, target_mask):\n causal_mask = make_inference_history_mask_3d(target_mask)\n mask = make_attention_mask_3d(source_mask, target_mask)\n mask = mask * causal_mask\n # invert mask for Megatron\n return mask < 0.5",
"def get_causal_mask(model_dim):\n a... | [
"0.6701625",
"0.5880225",
"0.5806054",
"0.5805493",
"0.5771913",
"0.5734302",
"0.5636548",
"0.56013423",
"0.556381",
"0.54872257",
"0.54100525",
"0.5408892",
"0.53997034",
"0.53633064",
"0.53322333",
"0.5319295",
"0.5303393",
"0.5284447",
"0.5255125",
"0.5236887",
"0.52152634... | 0.62958115 | 1 |
Rotates half the hidden dims of the input. | def rotate_half(x):
x1 = x[..., : x.shape[-1] // 2]
x2 = x[..., x.shape[-1] // 2 :]
return torch.cat((-x2, x1), dim=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fix_dimension(self, rot: tf.Tensor) -> tf.Tensor:\n even_n = [i for i in range(0, self.circuit_model.nqubit * 2, 2)]\n odd_n = [i for i in range(1, self.circuit_model.nqubit * 2, 2)]\n perm = even_n + odd_n\n rot = tf.transpose(rot, perm=perm)\n rot = tf.reshape(rot, shape=(... | [
"0.6447909",
"0.5587377",
"0.5508792",
"0.54771554",
"0.5473802",
"0.5468499",
"0.54290074",
"0.54104304",
"0.5391904",
"0.5381794",
"0.5374847",
"0.536035",
"0.53580415",
"0.5299022",
"0.5298043",
"0.5298043",
"0.5251104",
"0.52426225",
"0.5236352",
"0.5229538",
"0.5224368",... | 0.64703625 | 0 |
Returns a gaussian random number | def _get_gaussian_random(self):
u1 = generateRandom()
u2 = generateRandom()
if u1 < 1e-6:
u1 = 1e-6
return sqrt(-2 * log(u1)) * cos(2 * pi * u2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_gaussian():\n amp = 10 * numpy.random.chisquare(3)\n width = numpy.random.chisquare(3)\n mean = numpy.random.uniform(-10 + width, 10 - width)\n x = numpy.linspace(-10, 10, 500)\n y = amp * numpy.exp(- (x - mean) ** 2 / width ** 2)\n add_noise(y, 0.1)\n return x, y",
"def rand_ga... | [
"0.76417845",
"0.74124026",
"0.74117035",
"0.7400872",
"0.73885965",
"0.73865706",
"0.7355771",
"0.73550445",
"0.7354002",
"0.7345279",
"0.7341788",
"0.7283857",
"0.72462964",
"0.722161",
"0.72148955",
"0.71684784",
"0.7155654",
"0.70906794",
"0.69348806",
"0.6895141",
"0.688... | 0.8234892 | 0 |
Returns the displacement texture, storing the 3D Displacement in the RGB channels | def get_displacement_texture(self):
return self.displacement_tex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rgb_image(self):\n z3 = self.z[:,:,newaxis]\n return z3 * self.c",
"def GetOutTextureCoord(self):\n ...",
"def ci(x, y, z):\n\n return (x * 16 + z) * CHUNK_HEIGHT + y",
"def GetInTextureCoord(self):\n ...",
"def rgb_to_xyz(image: tf.Tensor) -> tf.Tensor:\n r, g, b = tf... | [
"0.57808304",
"0.5724655",
"0.5575158",
"0.55007845",
"0.5495631",
"0.5442849",
"0.53449386",
"0.53127766",
"0.52633506",
"0.5257021",
"0.52545923",
"0.52391744",
"0.5231013",
"0.5198924",
"0.51982945",
"0.51770604",
"0.51602405",
"0.51500976",
"0.5144836",
"0.51301616",
"0.5... | 0.7183238 | 0 |
Returns the normal texture, storing the normal in world space in the RGB channels | def get_normal_texture(self):
return self.normal_tex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_normal(self):\n c, s = np.cos(self.eangles), np.sin(self.eangles)\n r = np.array([[c, -s], [s, c]])\n u = np.array([1, 0])\n return np.dot(r, u)",
"def normal(self, uv):\n res = GeomLProp_SLProps(self.surface(), uv[0], uv[1], 1, 1e-9)\n if not res.IsNormalDefined... | [
"0.6566784",
"0.6541615",
"0.6512049",
"0.64429337",
"0.6339668",
"0.6276351",
"0.6200656",
"0.6118488",
"0.61088574",
"0.607771",
"0.60631305",
"0.6046111",
"0.6028556",
"0.60196614",
"0.60163665",
"0.5973171",
"0.5903069",
"0.5851999",
"0.58481455",
"0.57989216",
"0.5756422... | 0.78915715 | 0 |
Convert (rows, cols) raster row and column indices to geographic coordinates based on the affine transformation of the raster. | def rowcol_to_xy(rows, cols, affine):
# make it a 3x3 matrix
aff_array = numpy.array(affine).reshape((3, 3))
# check that rows amd cols are indeed 1-D vectors
rows = validate.is_vector(rows)
cols = validate.is_vector(cols)
# filler
layers = numpy.ones_like(rows)
vector = numpy.array([... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __affine_geo_transformation(x, y, gtr):\n\n # https://gdal.org/user/raster_data_model.html#affine-geotransform\n # Affine transformation rewritten for rasterio:\n gtr_x = gtr[2] + (x + 0.5) * gtr[0] + (y + 0.5) * gtr[1]\n gtr_y = gtr[5] + (x + 0.5) * gtr[3] + (y + 0.5) * gtr[4]\n\n ... | [
"0.7374341",
"0.63459325",
"0.6277448",
"0.62138504",
"0.61124843",
"0.61005765",
"0.6083403",
"0.6077274",
"0.6064563",
"0.60560596",
"0.5998631",
"0.59866047",
"0.5951056",
"0.5938208",
"0.5902591",
"0.589468",
"0.5876953",
"0.5858457",
"0.58484095",
"0.5841645",
"0.5835178... | 0.646609 | 1 |
Convert (x, y) coordinates to raster column and row indices based on the affine transformation of the raster. | def xy_to_rowcol(x, y, affine):
# affine might be an Affine object, might be 3x3 array or
# 9-element vector. Let's first make damn sure is a 9-element
# vector
aff_array = numpy.array(affine).reshape(9)
# now be damn sure we have an Affine object, and reverse it to
# go from coordinates to ind... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pixel2coord(self, x, y):\n # NEED TO CHANGE TO USE INVERSE TRANSFORM COEFFS\n # partly taken from Sean Gillies \"affine.py\"\n a,b,c,d,e,f = self.coordspace_transform\n det = a*e - b*d\n idet = 1 / float(det)\n ra = e * idet\n rb = -b * idet\n rd = -d * i... | [
"0.7161936",
"0.6930285",
"0.6911302",
"0.6767629",
"0.6755321",
"0.6702426",
"0.6593449",
"0.6577924",
"0.65381414",
"0.64958143",
"0.6494961",
"0.6420091",
"0.6297772",
"0.62835073",
"0.62815624",
"0.62698585",
"0.6257687",
"0.62332827",
"0.61786354",
"0.61742276",
"0.61528... | 0.720692 | 0 |
gets api credentials using keyring returns a list [user name, password] | def get_credentials(service_name="dataforSeo", uname="matteo.jriva@gmail.com"):
pw = keyring.get_password(service_name, uname)
return [uname, pw] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetUserCredentials(self):\r\n # Create a local alias to the email variable to avoid Python's crazy\r\n # scoping rules.\r\n global keyring\r\n email = self.email\r\n if email is None:\r\n email = GetEmail(\"Email (login for uploading to %s)\" % self.server)\r\n password = None\r\n if ... | [
"0.70940423",
"0.70528555",
"0.70423704",
"0.6831092",
"0.6688551",
"0.6600526",
"0.6581192",
"0.6568028",
"0.65603054",
"0.65516466",
"0.6522141",
"0.6507727",
"0.6496433",
"0.6482267",
"0.6443662",
"0.6442605",
"0.64323187",
"0.640169",
"0.63583547",
"0.63330716",
"0.628744... | 0.7742585 | 0 |
checks connection with api by verifying error codes and number of tasks between post_data/requests and response | def check_api_connection(post_data, response) -> list:
# check status code
if response['status_code'] != 20000:
raise ConnectionError(f"Status code is not ok: {response['status_message']}")
# check
id_list = []
for a, b in zip(post_data.values(), response['tasks']):
if a['keyword'] !... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_connection(self):\n for _ in range(3):\n try:\n r = get(f\"http://{self.ip}/student/{self.user}\")\n if r.ok:\n break \n except OSError as e:\n print(f\"Connection error:\\n{e}\")\n sleep(2)\n ... | [
"0.6313354",
"0.6221306",
"0.6189494",
"0.6163173",
"0.61223114",
"0.6110808",
"0.60752267",
"0.60510343",
"0.6002983",
"0.5962135",
"0.59314",
"0.5928525",
"0.5911796",
"0.59043324",
"0.5895254",
"0.58699054",
"0.5863783",
"0.5842427",
"0.58288515",
"0.5811535",
"0.57947063"... | 0.7266906 | 0 |
Convert an object serialization that was generated by the object serializer into a vocabulary handle. | def deserialize(self, descriptor: Dict, data: List) -> ObjectHandle:
return VocabularyHandle(
values=set(data),
name=descriptor['name'],
namespace=descriptor['namespace'],
label=descriptor.get('label'),
description=descriptor.get('description')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_serialize_vocabulary():\n # Serialize minimal vocabulary handle.\n v = VocabularyHandle(values={'A', 'B', 'C'}, name='my_vocab')\n doc, data = VocabularyFactory().serialize(v)\n vocab = VocabularyFactory().deserialize(descriptor=doc, data=data)\n assert vocab.name == 'my_vocab'\n assert ... | [
"0.62096655",
"0.5864106",
"0.56451684",
"0.56001896",
"0.55511445",
"0.5335712",
"0.5323669",
"0.52616173",
"0.52586997",
"0.5231618",
"0.5181435",
"0.518052",
"0.51429373",
"0.51414454",
"0.51291484",
"0.5112931",
"0.5105933",
"0.50208855",
"0.50041157",
"0.4997506",
"0.497... | 0.65390325 | 0 |
Compute the mewe estimator for misspecified models Inputs | def mewe_misspecified(M,N,m,n,target):
output = []
for k in tqdm(range(0,M)):
# Allocate space for output
mewe_store = np.zeros((len(n),target['thetadim']))
mewe_runtimes = np.zeros(len(n))
mewe_evals = np.zeros(len(n))
# generate all observations and sets of randomness to be used
if targe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimator(envs, model, seed=99999, model_type=\"rf\", _idx=None, name=None):\n\n #wandb.watch(model, log='all')\n wandb.init(project='rgm_single', reinit=True, tags=[flags.wandb_tag])\n wandb.config.update(flags)\n wandb.config.actual_measure = name\n\n if flags.optim == 'adam':\n optimizer... | [
"0.5930371",
"0.58639264",
"0.5833472",
"0.57596225",
"0.5755409",
"0.5754674",
"0.57527477",
"0.57213014",
"0.56541514",
"0.5622811",
"0.5616077",
"0.56119925",
"0.56081957",
"0.5604912",
"0.5601415",
"0.5573714",
"0.55722886",
"0.55464065",
"0.55427945",
"0.5542184",
"0.553... | 0.6397469 | 0 |
Initiates the report object attached to the flowcell and sequencing run but not attached to any pipelines as of yet. | def __init__(self,config,key=int(-1),flowcell=None,seq_run=None,base_output_dir=None,process_name='flowcell_reports',**kwargs):
if not flowcell is None:
GenericProcess.__init__(self,config,key=key,process_name=process_name,**kwargs)
if base_output_dir == None:
self.base_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,config,sample_keys=None,number=None,key=int(-1),flowcell=None,input_dir=None,base_output_dir=None,output_dir=None,date=strftime(\"%Y%m%d\",localtime()),time=strftime(\"%H:%M:%S\",localtime()),process_name='flowcell_report',complete_file=None,**kwargs):\n if flowcell is None:\n f... | [
"0.64415294",
"0.59275347",
"0.5872562",
"0.58031285",
"0.5752513",
"0.5710506",
"0.5687142",
"0.5601731",
"0.5572101",
"0.5545518",
"0.55392045",
"0.5517224",
"0.5504108",
"0.54795575",
"0.5469122",
"0.54628384",
"0.5459609",
"0.54314554",
"0.54296523",
"0.5393991",
"0.53872... | 0.62101597 | 1 |
Connects the report with a pipeline by recoding the pipeline key and pipeline obj_type in a string. | def __add_pipeline__(self,pipeline):
if not re.search('Pipeline',pipeline.obj_type):
raise Exception("Trying to add non-pipeline key to flowcell statistics reports")
if not self.pipelines is None:
self.pipelines += ';'
self.pipelines += str(pipeline.key) + ":" + pipel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pipeline_id(self):\n pass",
"def pipeline_id(self, pipeline_id):\n\n self._pipeline_id = pipeline_id",
"def _set_pipeline_cfg(self, field, value):",
"def __init__(self, pipeline, config=None):\n self.config = config\n self.pipeline = pipeline",
"def _setup_pipeline_cfg(self)... | [
"0.5497617",
"0.53822815",
"0.5282645",
"0.52708805",
"0.52638996",
"0.5247205",
"0.5247205",
"0.5194562",
"0.51895684",
"0.5155318",
"0.51416343",
"0.5130589",
"0.5123417",
"0.5112902",
"0.50113124",
"0.50014526",
"0.49835396",
"0.49828",
"0.49824667",
"0.496152",
"0.4943308... | 0.7252879 | 0 |
Uses the pipelines string stored in self to generate a list of pipeline objects. | def __current_pipeline_list__(self,mockdb):
pipelines = []
if self.pipelines is None:
return pipelines
pipelines_dict = self.pipelines.split(';')
for d in pipelines_dict:
pipeline_key, obj_type = d.split(':')
try:
pipeline = mockdb[obj_type].objects[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pipelines(self) -> list:\n if not self._pipelines:\n if \"pipelines\" not in self._pipeline_definition:\n raise ValueError(\"Pipeline is missing 'pipelines' field.\")\n elif len(self._pipeline_definition[\"pipelines\"]) == 0:\n raise ValueError(\"Pipel... | [
"0.64970875",
"0.6224952",
"0.6171325",
"0.59650576",
"0.59019244",
"0.5801626",
"0.5700288",
"0.5635955",
"0.561687",
"0.5602918",
"0.558298",
"0.55374354",
"0.54890347",
"0.5482137",
"0.5480424",
"0.5476726",
"0.5439776",
"0.5429055",
"0.54281485",
"0.5370522",
"0.5369393",... | 0.6630521 | 0 |
Returns a list of sample keys associated with pipelines that have completed. | def __completed_samples_list__(self,mockdb):
sample_keys = []
for pipeline in self.__current_pipeline_list__(mockdb):
if pipeline.__is_complete__():
sample_keys.append(pipeline.sample_key)
return sample_keys | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_log_keys(learner: adaptive.BaseLearner) -> list[str]:\n # Check if the result contains the expected keys\n expected_keys = [\n \"elapsed_time\",\n \"overhead\",\n \"npoints\",\n \"cpu_usage\",\n \"mem_usage\",\n ]\n if not _at_least_adaptive_version(\"0.1... | [
"0.58077824",
"0.57011235",
"0.55749696",
"0.55166054",
"0.5502152",
"0.5502144",
"0.5501071",
"0.54757553",
"0.5468525",
"0.54596",
"0.5451035",
"0.54484963",
"0.54165906",
"0.53382456",
"0.5324936",
"0.532412",
"0.53238577",
"0.5314545",
"0.52536863",
"0.5247326",
"0.523778... | 0.81249654 | 0 |
Checks the number of completed samples and generates reports based on this number and what has been previously reported. Return True only if a new report object is initialized. | def __generate_reports__(self,configs,mockdb):
sample_keys = self.__completed_samples_list__(mockdb)
n = len(sample_keys)
numbers = configs['pipeline'].get('Flowcell_reports','numbers').split(',')
numbers.sort(key=int,reverse=True)
flowcell = mockdb['Flowcell'].__get__(configs['s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_report(self):\n return self.report is not None",
"def Report(self):\n return True",
"def has_more_samples(self):\n return True",
"def has_more_samples(self):\n return True",
"def has_more_samples(self):\n return True",
"def is_ready_to_reap(self):\n self.... | [
"0.6579948",
"0.6464013",
"0.60099596",
"0.60099596",
"0.60099596",
"0.6004687",
"0.5992304",
"0.59684485",
"0.5916682",
"0.5828449",
"0.57452166",
"0.5734676",
"0.5715299",
"0.5679798",
"0.5673723",
"0.5657325",
"0.56381965",
"0.561074",
"0.56070954",
"0.55903435",
"0.557329... | 0.6739479 | 0 |
Fills the qsub file from a template. Since not all information is archived in the parent object, the function also gets additional information on the fly for the qsub file. | def __fill_qsub_file__(self,configs):
template_file= os.path.join(configs['system'].get('Common_directories','template'),configs['pipeline'].get('Template_files','flowcell_report'))
dictionary = {}
for k,v in self.__dict__.iteritems():
dictionary.update({k:str(v)})
dictionary... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __fill_template__(self,template_file,output_fname):\n dictionary = {}\n for k,v in self.__dict__.iteritems():\n if k == 'sample_key':\n try:\n int(v)\n new_sample_key = \"Sample_\" + str(v)\n dictionary.update({k:n... | [
"0.6398042",
"0.59318715",
"0.57331526",
"0.56946903",
"0.56846076",
"0.5610546",
"0.5556413",
"0.5502752",
"0.546865",
"0.54102975",
"0.5395212",
"0.5394656",
"0.5380861",
"0.5331941",
"0.5326681",
"0.5309131",
"0.52896446",
"0.5275481",
"0.524707",
"0.52117896",
"0.5208709"... | 0.71228755 | 0 |
Simple test to check that raw target data does NOT leak during validation. | def test_for_leakage(self):
src, trg = next(iter(self.validation_loader))
trg_mem = trg.clone().detach()
result = greedy_decode(self.model, src, 20, trg)
self.assertNotEqual(result[0, 1, 0], trg_mem[0, 1, 0])
self.assertEqual(result[0, 1, 1], trg_mem[0, 1, 1])
self.assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_raw_data(self):\n self.assertEqual(self.tester.raw_data, 1)",
"def testCheckSourceCopyOperation_FailContainsData(self):\n payload_checker = checker.PayloadChecker(self.MockPayload())\n self.assertRaises(PayloadError, payload_checker._CheckSourceCopyOperation,\n 134, 0, ... | [
"0.63760984",
"0.61903423",
"0.61187553",
"0.6034975",
"0.59867835",
"0.58931315",
"0.58748543",
"0.5858307",
"0.5847851",
"0.58443165",
"0.58315504",
"0.5814813",
"0.58093095",
"0.5804731",
"0.5799579",
"0.5769792",
"0.57684606",
"0.57661027",
"0.57597375",
"0.5759114",
"0.5... | 0.66377693 | 0 |
Helper to clear workers. | def clear_workers(self):
# seems sometimes that workers will cause
# print "calling destructor"
# first set the exit flag for each of the workers.
for worker in self.workers:
worker.no_exit = False
# next clear the queue, the workers might be waiting to add data to
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_workers(self, workers):\n for obj_ref, ev in self._tasks.copy().items():\n if ev not in workers:\n del self._tasks[obj_ref]\n del self._objects[obj_ref]\n\n # We want to keep the same deque reference so that we don't suffer from\n # stale refe... | [
"0.7626767",
"0.7542355",
"0.7180268",
"0.7154682",
"0.6952088",
"0.68525493",
"0.66856486",
"0.65819097",
"0.65408283",
"0.64911026",
"0.64703065",
"0.64379334",
"0.6434519",
"0.6424239",
"0.6419156",
"0.6379613",
"0.63488203",
"0.6319778",
"0.6311553",
"0.62962127",
"0.6281... | 0.78377396 | 0 |
listens for incoming data. calls the callback when EOL character is received or nothing more received after frame_interval delay. | def __listener__(self):
frame_interval = 0.1
str_list = []
c = ''
while True:
with Timeout(frame_interval, False):
while True:
try:
c = self.ser.read()
except:
self.ser.clo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n while True:\n line = self.stream.readline()\n if not len(line):\n # EOF, stop!\n break\n else:\n # Put the text on the queue, along with the time it was read.\n self.callback_queue.put(line)",
"de... | [
"0.65784127",
"0.6168723",
"0.6104151",
"0.60715026",
"0.6070223",
"0.60645175",
"0.6064057",
"0.5994367",
"0.5993057",
"0.5985244",
"0.594018",
"0.5926664",
"0.59176093",
"0.5900453",
"0.58874613",
"0.58724445",
"0.5861622",
"0.58127826",
"0.5803357",
"0.5771629",
"0.5733422... | 0.6448255 | 1 |
Run depth first search from the start page to a specified depth (n) | def depth_first_search(self, start_page: str, n: int = 1):
url = name_to_url(start_page)
i = self.add_node(WikiNode(url, 0))
stack = deque()
stack.append(i)
while stack:
nd = self.nodes[stack.pop()]
if nd.level > n:
continue
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth_limited_search(initial_state, goal_state, limit):\n\n return recursive_dls(createRootNode(initial_state), goal_state, limit)",
"def search(board):\n depth = 0\n while True:\n result = depth_first(board, depth)\n if result:\n return result\n else:\n de... | [
"0.6694698",
"0.614414",
"0.6132657",
"0.60701245",
"0.6066893",
"0.595954",
"0.5902348",
"0.5713828",
"0.5664526",
"0.56568605",
"0.5646772",
"0.56425816",
"0.56281155",
"0.5602723",
"0.5602259",
"0.5561969",
"0.5543314",
"0.5535719",
"0.55312914",
"0.5527265",
"0.55212325",... | 0.7672866 | 0 |
Caches current values of this scaler. | def cache(self):
self.cached_mu = self.mu.eval()
self.cached_var = self.var.eval()
self.cached_count = self.count.eval() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cache_values(self):\n width = self.width.current\n center = self.horizontal.current\n\n # If center would need to be rounded, increase the width by 1 to make a smoother fade between LEDs.\n if center % 2 != 0:\n width += 1\n # Moving right\n if cent... | [
"0.68166256",
"0.6293583",
"0.6013564",
"0.5906083",
"0.58870524",
"0.5878629",
"0.5794002",
"0.5788975",
"0.5729468",
"0.5700146",
"0.5641709",
"0.5626525",
"0.562225",
"0.5617957",
"0.5611663",
"0.5600222",
"0.5584668",
"0.55765784",
"0.55575067",
"0.5549433",
"0.5529761",
... | 0.6696546 | 1 |
Loads values from the cache | def load_cache(self):
self.mu.load(self.cached_mu)
self.var.load(self.cached_var)
self.count.load(self.cached_count) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_cache():\n return {}",
"def _load_cache(self):\n self.cache = self.cache_manager.retrieve(self.cache_file)\n if self.cache is None:\n self.cache = {}\n return",
"def _load_cache(self):\n logger.debug(\"Loading coherence data for %s from cache\", self.w1)\n\n ... | [
"0.7575775",
"0.7280087",
"0.7223931",
"0.7177263",
"0.70998794",
"0.70036113",
"0.69161636",
"0.67685753",
"0.67554885",
"0.6736556",
"0.66704935",
"0.66339123",
"0.65642005",
"0.6550079",
"0.65268654",
"0.64958376",
"0.6484298",
"0.6474443",
"0.64711505",
"0.6470632",
"0.64... | 0.82253915 | 0 |
Run spark job that will associate vendor's users (loaded from REST API) with our users (loaded from MySQL) | def run(sc, logger):
start = time.time()
# Spark SQL Context
sqlContext = sql.context.SQLContext(sc)
# 1) Practices - Small table so no need to partition it, could even broadcast across all executors
# Spark SQL JDBC Options: https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html
prac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def myjob(spark: SparkSession, **kwargs):\n df = spark.read.csv(\"spark-data/climatewatch-usemissions.csv\")\n\n df.show()",
"def main():\n sc = pyspark.SparkContext(conf=sparkConf())\n sql = pyspark.SQLContext(sc)\n args = parse_args()\n cleanOutputDir(args.output)\n users = os.listdir(args... | [
"0.60789704",
"0.5929695",
"0.57598954",
"0.5682684",
"0.56565857",
"0.5645783",
"0.55553067",
"0.55104584",
"0.5424839",
"0.5386339",
"0.53613216",
"0.53369313",
"0.5331455",
"0.52619505",
"0.5234679",
"0.51690274",
"0.51419294",
"0.5136389",
"0.5131487",
"0.5121975",
"0.511... | 0.62689376 | 0 |
DB Table (user) RDD | def getUsersRDD(sqlContext):
# Currently the id field ranges from '0' to '1000000'.
# To avoid loading it all in memory, partition on the id field (100 partitions, about 10k records per partition).
# Also setting fetch size to 10,000 to avoid multiple database calls per partition.
# All records from a s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPracticesRDD(sqlContext):\n from db import *\n return sqlContext \\\n .read \\\n .format(\"jdbc\") \\\n .options(\n driver=driver,\n url=url,\n dbtable=\"user_practice\",\n user=user,\n password=password\n ) \\\n ... | [
"0.67998576",
"0.5744766",
"0.5728073",
"0.5698959",
"0.56625485",
"0.5611208",
"0.5545845",
"0.5541903",
"0.5511742",
"0.54902637",
"0.5478023",
"0.546456",
"0.5460285",
"0.54463327",
"0.54219323",
"0.53919584",
"0.53734076",
"0.53692913",
"0.53442574",
"0.5303176",
"0.52917... | 0.7346135 | 0 |
DB Table (user_practice) RDD | def getPracticesRDD(sqlContext):
from db import *
return sqlContext \
.read \
.format("jdbc") \
.options(
driver=driver,
url=url,
dbtable="user_practice",
user=user,
password=password
) \
.load() \
.rdd \... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUsersRDD(sqlContext):\n # Currently the id field ranges from '0' to '1000000'.\n # To avoid loading it all in memory, partition on the id field (100 partitions, about 10k records per partition).\n # Also setting fetch size to 10,000 to avoid multiple database calls per partition.\n # All records... | [
"0.7516853",
"0.5981532",
"0.5914595",
"0.5749075",
"0.5651898",
"0.5564147",
"0.5504629",
"0.5466716",
"0.53867334",
"0.5365914",
"0.53556013",
"0.53233206",
"0.53024125",
"0.52994925",
"0.5294507",
"0.5259196",
"0.5251913",
"0.52423704",
"0.52172804",
"0.52047914",
"0.52028... | 0.7766232 | 0 |
Modify cherrypy.response status, headers, and body to represent self. CherryPy uses this internally, but you can also use it to create an HTTPRedirect object and set its output without raising the exception. | def set_response(self):
import cherrypy
response = cherrypy.response
response.status = status = self.status
if status in (300, 301, 302, 303, 307):
response.headers['Content-Type'] = "text/html"
# "The ... URI SHOULD be given by the Location field
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_response(self):\r\n import cherrypy\r\n \r\n response = cherrypy.response\r\n \r\n clean_headers(self.status)\r\n \r\n # In all cases, finalize will be called after this method,\r\n # so don't bother cleaning up response values here.\r\n respon... | [
"0.80094314",
"0.64838946",
"0.64483994",
"0.64255804",
"0.64048517",
"0.6346558",
"0.6325356",
"0.62837017",
"0.6198728",
"0.618486",
"0.609106",
"0.609106",
"0.6029773",
"0.6029773",
"0.60140204",
"0.59765",
"0.597243",
"0.5957101",
"0.59427726",
"0.5942422",
"0.5940268",
... | 0.79674995 | 1 |
Remove any headers which should not apply to an error response. | def clean_headers(status):
import cherrypy
response = cherrypy.response
# Remove headers which applied to the original content,
# but do not apply to the error page.
respheaders = response.headers
for key in ["Accept-Ranges", "Age", "ETag", "Location", "Retry-After",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteResponseHeader(self, name):\n assert name.islower()\n self._wpr_response.original_headers = \\\n [x for x in self._wpr_response.original_headers if x[0].lower() != name]",
"def get204(self):\n bad = ('content-length', 'content-type')\n for h in bad:\n bottle.respon... | [
"0.70664626",
"0.6766832",
"0.67029774",
"0.65894616",
"0.65733063",
"0.6347384",
"0.62985134",
"0.62751406",
"0.6233765",
"0.620523",
"0.62022334",
"0.62022334",
"0.61543894",
"0.6121957",
"0.60959095",
"0.59708506",
"0.59368455",
"0.5910138",
"0.5903606",
"0.5784915",
"0.57... | 0.7672321 | 0 |
Modify cherrypy.response status, headers, and body to represent self. CherryPy uses this internally, but you can also use it to create an HTTPError object and set its output without raising the exception. | def set_response(self):
import cherrypy
response = cherrypy.response
clean_headers(self.status)
# In all cases, finalize will be called after this method,
# so don't bother cleaning up response values here.
response.status = self.status... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_response(self):\r\n import cherrypy\r\n response = cherrypy.response\r\n response.status = status = self.status\r\n \r\n if status in (300, 301, 302, 303, 307):\r\n response.headers['Content-Type'] = \"text/html\"\r\n # \"The ... URI SHOULD be given ... | [
"0.7279636",
"0.6841792",
"0.6596323",
"0.6478856",
"0.63977695",
"0.6384832",
"0.63642305",
"0.6360515",
"0.6346353",
"0.6292077",
"0.62432635",
"0.6235534",
"0.62161624",
"0.61403537",
"0.6117794",
"0.6098712",
"0.60923874",
"0.60923874",
"0.60763764",
"0.60666084",
"0.6066... | 0.79920655 | 0 |
Return an HTML page, containing a pretty error response. status should be an int or a str. kwargs will be interpolated into the page template. | def get_error_page(status, **kwargs):
import cherrypy
try:
code, reason, message = _http.valid_status(status)
except ValueError, x:
raise cherrypy.HTTPError(500, x.args[0])
# We can't use setdefault here, because some
# callers send None for kwarg values.
if k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _error(self, request, status, headers={}, prefix_template_path=False, **kwargs):\n\n return self._render(\n request = request,\n template = str(status),\n status = status,\n context = {\n 'error': kwargs\n },\n headers = he... | [
"0.7486714",
"0.71014893",
"0.70575845",
"0.6884129",
"0.68273413",
"0.66129935",
"0.6582311",
"0.6527852",
"0.63832134",
"0.6349418",
"0.62882286",
"0.6281123",
"0.6267836",
"0.62180173",
"0.6196485",
"0.61800444",
"0.6087222",
"0.6086159",
"0.6083011",
"0.60501426",
"0.6045... | 0.75789016 | 0 |
Return exc (or sys.exc_info if None), formatted. | def format_exc(exc=None):
if exc is None:
exc = _exc_info()
if exc == (None, None, None):
return ""
import traceback
return "".join(traceback.format_exception(*exc)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_exc():\n from traceback import format_exc\n return format_exc().decode('utf-8', 'surrogateescape')",
"def _FormatException(exc):\n return ''.join(traceback.format_exception_only(type(exc), exc))",
"def exc_info(): # real signature unknown; restored from __doc__\n pass",
"def exc_... | [
"0.74286795",
"0.7414739",
"0.7375478",
"0.7347589",
"0.7310034",
"0.72899365",
"0.7289055",
"0.72446114",
"0.7233393",
"0.7170941",
"0.71380997",
"0.70984167",
"0.70755666",
"0.70068014",
"0.70056164",
"0.698292",
"0.6949396",
"0.69382375",
"0.688788",
"0.6868626",
"0.682099... | 0.8027619 | 0 |
Produce status, headers, body for a critical error. Returns a triple without calling any other questionable functions, so it should be as errorfree as possible. Call it from an HTTP server if you get errors outside of the request. If extrabody is None, a friendly but rather unhelpful error message is set in the body. I... | def bare_error(extrabody=None):
# The whole point of this function is to be a last line-of-defense
# in handling errors. That is, it must not raise any errors itself;
# it cannot be allowed to fail. Therefore, don't add to it!
# In particular, don't call any other CP functions.
body... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, req):\n\n user_locale = req.best_match_language()\n # Replace the body with fault details.\n code = self.wrapped_exc.status_int\n fault_name = self._fault_names.get(code, \"computeFault\")\n explanation = self.wrapped_exc.explanation\n LOG.debug(_(\"Retu... | [
"0.5321928",
"0.52629745",
"0.5132919",
"0.5015631",
"0.49685788",
"0.4951957",
"0.49515012",
"0.48696885",
"0.48568124",
"0.48105162",
"0.48014742",
"0.47840595",
"0.47553754",
"0.4739833",
"0.47328785",
"0.47322333",
"0.4730517",
"0.47163033",
"0.47095564",
"0.46958682",
"0... | 0.6682402 | 0 |
Called when an interest for the specified name is recieved | def onInterest(self, prefix, interest, transport, registeredPrefixId):
interestName = interest.getName()
data = Data(interestName)
data.setContent("Hello, " + interestName.toUri())
hourMilliseconds = 3600 * 1000
data.getMetaInfo().setFreshnessPeriod(hourMilliseconds)
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_notify(self, name):\r\n pass",
"def on_callback_myname(self, pubsub, topic, value):\n raise NotImplementedError()",
"def enter_name(self, name):\n self.name = name",
"def get_next_single_name_classic(self, arg: str):\n current_name = arg\n self.sent_interests[str(cur... | [
"0.60658574",
"0.5551281",
"0.5527813",
"0.5408764",
"0.53355795",
"0.5331701",
"0.5316069",
"0.5271348",
"0.52610093",
"0.5228865",
"0.52115935",
"0.5185267",
"0.5160243",
"0.51520616",
"0.51286995",
"0.5124869",
"0.51123345",
"0.50867796",
"0.50811255",
"0.5079059",
"0.5076... | 0.6637799 | 0 |
Called when forwarder can't register prefix | def onRegisterFailed(self, prefix):
dump("Register failed for prefix", prefix.toUri())
self.isDone = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route_rejected(self, prefix, next_hop, as_path):",
"def test_prefix():\n\n dispatcher = ntelebot.dispatch.Dispatcher()\n dispatcher.add_prefix('prefix', lambda ctx: 'PREFIX')\n ctx = MockContext()\n ctx.type = 'message'\n assert dispatcher(ctx) is False\n ctx.prefix = 'prefix'\n assert d... | [
"0.63499",
"0.5765259",
"0.5601321",
"0.5575383",
"0.5490063",
"0.54715466",
"0.5461371",
"0.5442819",
"0.53290313",
"0.5288423",
"0.52614975",
"0.524435",
"0.5240158",
"0.52038664",
"0.5189467",
"0.51688075",
"0.5157592",
"0.51413566",
"0.512637",
"0.5113935",
"0.50908184",
... | 0.6864617 | 0 |
Returns default metadata of type ``name``, where ``name`` is one of "tree_sequence", "edge", "site", "mutation", "mutation_list_entry", "node", "individual", or "population". | def default_slim_metadata(name):
if name == "tree_sequence":
out = {
"SLiM" : {
"model_type" : "nonWF",
"cycle" : 1,
"tick" : 1,
"file_version" : slim_file_version,
"spatial_dimensionality" : "",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self) -> str:\n return self.type_data.name",
"def _getMetadataName(self):\n pass",
"def get_metadata (self, name):\n return self.metadata.get(name)",
"def get_or_create_meddra_type(self, name: str) -> MeddraType:\n return self._get_or_create_model(self.meddra_types, MeddraTyp... | [
"0.5959555",
"0.58948135",
"0.5858112",
"0.5682448",
"0.5663172",
"0.5657096",
"0.55724984",
"0.55313265",
"0.5495867",
"0.5495678",
"0.54869545",
"0.5458396",
"0.5452425",
"0.5430432",
"0.5417629",
"0.5389796",
"0.5383348",
"0.5370883",
"0.5369414",
"0.535739",
"0.53353643",... | 0.6202577 | 0 |
Tests whether the tree sequence or table collection provided is the current SLiM file format or not. If not, use `pyslim.update( )` to bring it up to date. | def is_current_version(ts, _warn=False):
out = (
isinstance(ts.metadata, dict)
and
('SLiM' in ts.metadata)
and
(ts.metadata['SLiM']['file_version'] == slim_file_version)
)
if _warn and not out:
warnings.warn(
"This tree sequence is not the curr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tables(tables):\n # First we ensure we can find the file format version number\n # in top-level metadata. Then we proceed to fix up the tables as necessary.\n if not (isinstance(tables.metadata, dict) and 'SLiM' in tables.metadata):\n # Old versions kept information in provenance, not to... | [
"0.5645714",
"0.5205285",
"0.47525713",
"0.473416",
"0.46577895",
"0.4646021",
"0.46265066",
"0.4595514",
"0.4574456",
"0.45528594",
"0.45147106",
"0.45048997",
"0.44993272",
"0.44980407",
"0.4485074",
"0.4447759",
"0.44419795",
"0.44316334",
"0.44212565",
"0.4402587",
"0.435... | 0.59775496 | 0 |
Update tables produced by a previous verion of SLiM to the current file version. Modifies the tables in place. | def update_tables(tables):
# First we ensure we can find the file format version number
# in top-level metadata. Then we proceed to fix up the tables as necessary.
if not (isinstance(tables.metadata, dict) and 'SLiM' in tables.metadata):
# Old versions kept information in provenance, not top-level m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_vluln_table():",
"def run_sql_file(filename, connection, version, lastversion):\n cursor = connection.cursor()\n for line in open(filename):\n cursor.execute(line)\n connection.commit()\n cursor.execute(\n \"update ecs.versionTable SET ecs.versionTable.version='{}' \"\n ... | [
"0.64403546",
"0.62191427",
"0.6161551",
"0.6083598",
"0.60682315",
"0.59898955",
"0.59780186",
"0.5969097",
"0.59629166",
"0.5858584",
"0.5825505",
"0.5784813",
"0.5734493",
"0.5684447",
"0.5658647",
"0.56252503",
"0.5621925",
"0.5621925",
"0.56180346",
"0.56000155",
"0.5599... | 0.74815 | 0 |
Uses a dictionary to convert a DNA sequence into the complement strand. C G, T A | def fast_complement(dna):
str = ''
dict = {'C':'G','G':'C','A':'T','T':'A'}
for char in dna:
if char == 'C' or char == 'G' or char == 'T' or char == 'A':
str = str + dict[char]
else :
str = 'invalid character entered, please check the input'
break
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_complement(dna):\n str = ''\n dict = {'C': 'G', 'G': 'C', 'A': 'T', 'T': 'A'}\n for char in dna:\n if char == 'C' or char == 'G' or char == 'T' or char == 'A':\n str = str + dict[char]\n else :\n str = 'invalid character entered, please check the input'\n ... | [
"0.7362567",
"0.6997333",
"0.69915193",
"0.68732756",
"0.6788549",
"0.67824614",
"0.6681162",
"0.6663421",
"0.65523094",
"0.6519002",
"0.6517805",
"0.6516243",
"0.6514966",
"0.6506109",
"0.6447673",
"0.6435777",
"0.6419471",
"0.6395348",
"0.63883877",
"0.63750035",
"0.6363215... | 0.7598703 | 0 |
Removes the interval of characters from a string or list inclusively, 0 based | def remove_interval(s, start, stop):
#s[:start] will get the string from start of string to 'start'->value stored in start
#s[stop:] will get the string from 'stop'->value stored in the stop to end of the string
temp_list = s[:start] + s[stop+1:]
return temp_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anything_but_range(*args:List[str]) -> str:\n return range(*args, negate=True)",
"def remove_4s_every_other_in_between(seq):\n seq_copy = seq [4:-4:2]\n return seq_copy",
"def anything_but_chars(*args:List[str]) -> str:\n # TODO uniq\n chars = \"\".join(args)\n return f\"[^{chars}]\"",
... | [
"0.61851144",
"0.5980326",
"0.5857507",
"0.58541673",
"0.580172",
"0.57548076",
"0.563322",
"0.5611872",
"0.5602925",
"0.55550575",
"0.55322695",
"0.55312544",
"0.5528412",
"0.54889864",
"0.5466602",
"0.54589194",
"0.5456114",
"0.5435535",
"0.54222876",
"0.5413383",
"0.539561... | 0.70485836 | 0 |
Generates all kmers of size k for a string s and store them in a set | def kmer_set(s, k):
kmer = set([])
n = len(s)
#n-k+1 is the available range of values or probablities.
for x in range(0, n - k + 1):
kmer.add(s[x:x + k])
return kmer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clump_forming_kmers(string, k, l, t):\n clumpFormingKmers = set()\n # Initial counts of k-mers within length l window starting from the first\n # chracter of the string.\n counts = Counter([kmer for i, kmer in enumerate_kmers(string[:l], k)])\n clumpFormingKmers = add_clump_forming_kmers(counts,... | [
"0.76189435",
"0.7363111",
"0.6979085",
"0.6867179",
"0.6815722",
"0.67906415",
"0.67450863",
"0.6658662",
"0.66486514",
"0.66284275",
"0.6626568",
"0.6619437",
"0.6613662",
"0.64602196",
"0.6456886",
"0.64392704",
"0.6331464",
"0.6325849",
"0.63245183",
"0.6272226",
"0.62616... | 0.76864225 | 0 |
Generates all kmers of size k for a string s and store them in a dictionary with the kmer(string) as the key and the number of occurances of the kmer as the value(int). | def kmer_dict(s, k):
kmer = {}
#calculating the length as n.
n = len(s)
for x in range(0, n - k + 1):
#checking if the entry alread in the dictionary kmer
if s[x:x+k] in kmer:
#if the entry is available then increament 1
kmer[s[x:x + k]] += 1
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_kmers(seq, k=3):\n # Start with an empty dictionary\n counts = {}\n # Calculate how many kmers of length k there are\n num_kmers = len(str(seq)) - k + 1\n # Loop over the kmer start positions\n for i in range(num_kmers):\n # Slice the string to get the kmer\n kmer = str(se... | [
"0.83377427",
"0.74581957",
"0.7419587",
"0.7218793",
"0.7165491",
"0.7158098",
"0.7143614",
"0.68497807",
"0.6764127",
"0.6763646",
"0.6749679",
"0.67431635",
"0.6696293",
"0.66370577",
"0.661861",
"0.6601165",
"0.65593135",
"0.65568435",
"0.64502054",
"0.6405555",
"0.636928... | 0.79432833 | 1 |
Prints the FIRST 10 lines of a file | def head(file_name):
#from itertools import islice
with open('../test_files/' + file_name, 'r') as infile:
list = infile.readlines()
#printing the 1st 10 lines
print('list of first 10 lines',list[:10]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head(filename, lines=5):\n from itertools import islice\n with open(filename, \"r\") as f:\n return list(islice(f, lines))",
"def head(filename, n=10):\n\tprint(\"[HEAD {}] {}\".format(n,filename))\n\tif filename[-3:].casefold()=='.gz':\n\t\twith gzip.open(filename, 'rt') as previewfile:\n\t\t\t... | [
"0.6985806",
"0.6973528",
"0.6691345",
"0.6686263",
"0.6660941",
"0.6617253",
"0.6611951",
"0.65246826",
"0.64488167",
"0.63853645",
"0.6347137",
"0.63329756",
"0.63230157",
"0.6308031",
"0.62810165",
"0.62323415",
"0.61938477",
"0.6095313",
"0.6090691",
"0.6051577",
"0.60468... | 0.81507313 | 0 |
Prints the LAST 10 lines of a file | def tail(file_name):
with open('../test_files/' + file_name, 'r') as infile:
list = infile.readlines()
#calculating the last 10 lines using len(list)-10:len(list)
print('list of last 10 lines',list[len(list)-10:len(list)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_tail(filename, n):\n result = ''\n with open(filename, 'r') as f:\n for line in (f.readlines()[-n:]):\n result += line\n\n return result",
"def tail(filepath, n):\n with open(filepath) as file_fd:\n lines = ''.join(file_fd.readlines())\n lines = lines.splitlin... | [
"0.74048",
"0.70670325",
"0.69681805",
"0.69455147",
"0.6894602",
"0.67591935",
"0.6747669",
"0.6644481",
"0.65139806",
"0.6490487",
"0.6489199",
"0.6370238",
"0.6363277",
"0.6346032",
"0.63062066",
"0.6291511",
"0.62899953",
"0.6274384",
"0.6269273",
"0.62548035",
"0.6221642... | 0.7993086 | 0 |
Prints the even numbered lines of a file | def print_even(file_name):
with open('../test_files/' + file_name, 'r') as infile:
#initialising 1 to 1 so that it evaluate from line 1
i = 1
for x in infile.readlines():
#performing operation to find the even number entry
if i%2 == 0:
#actual printing... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_titles(file, inc=3):\n count = 0\n with open(file) as f:\n for line in f:\n if count == 0 or count % 3 == 0:\n print(line.strip() + '\\t 0')\n count += 1",
"def fc():\n try:\n revfile = sys.argv[1]\n with open(revfile) as f:\n for revnumber in f... | [
"0.61693466",
"0.6092263",
"0.60504764",
"0.60123736",
"0.59696233",
"0.59063226",
"0.58038336",
"0.5767786",
"0.5724785",
"0.56689507",
"0.5647623",
"0.5638165",
"0.5592854",
"0.5588552",
"0.5547456",
"0.553177",
"0.5497751",
"0.54832536",
"0.5455734",
"0.5450205",
"0.542118... | 0.85165477 | 0 |
Reads in a CSV file and returns a list of values belonging to the column specified | def get_csv_column(file_name, column):
list = []
with open('../test_files/' + file_name, 'r') as infile:
for x in infile.readlines():
x = x.replace('\n', '')
# splitting based on ',' that are encountered in csv files.
#column-1 because the range start from 0 , so if u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def values_of_col(csvf,col_name,sepchar=' '):\n\tcol_values=[]\n\twith open(csvf,'rb') as f:\n\t\treader=csv.reader(f,delimiter=sepchar)\n\t\tcsv_list=list(reader)\n\t\theader_row=csv_list[0]\t\t\n\t\tcol_name_index=header_row.index(col_name)\n\t\tfor row in csv_list:\n\t\t\tcol_values.append(row[col_name_index])\... | [
"0.75514627",
"0.74750394",
"0.7196764",
"0.7163925",
"0.7137294",
"0.70621157",
"0.7006086",
"0.70048636",
"0.69896185",
"0.6975001",
"0.6971096",
"0.690734",
"0.6904262",
"0.6882441",
"0.68709296",
"0.6865765",
"0.6844638",
"0.6837288",
"0.68288726",
"0.6812737",
"0.6811516... | 0.775621 | 0 |
Reads in a FASTA file and returns a list of only the sequences | def fasta_seqs(file_name):
list = []
with open('../test_files/' + file_name, 'r') as infile:
text = infile.read()
seqs = text.split('>')
for seq in seqs:
try:
x = seq.split('\n', 1)
# sequence will be stored in x[1], and i am removing nextline ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readFastaFile(filename):\n if os.path.exists(filename)==False:return {}\n sequences={}\n fhr=open(filename,\"r\")\n for line in fhr:\n if line[0]==\">\":\n sequences[line.strip()[1:].split()[0]]=fhr.readline().strip()\n fhr.close()\n return sequences",
"def ReadFASTA(fasta... | [
"0.78360283",
"0.77743053",
"0.7728829",
"0.7471323",
"0.74618864",
"0.7347454",
"0.73288727",
"0.73279846",
"0.73026425",
"0.72431064",
"0.7187846",
"0.7174564",
"0.71720695",
"0.71589667",
"0.714582",
"0.7135067",
"0.71167755",
"0.7116155",
"0.710813",
"0.7086274",
"0.70719... | 0.7978697 | 0 |
Reads in a FASTA file and returns a list of only the headers (Lines that start with ">") | def fasta_headers(file_name):
list = []
with open('../test_files/' + file_name, 'r') as infile:
text = infile.read()
seqs = text.split('>')
for seq in seqs:
try:
x = seq.split('\n', 1)
if x[0] != '':
#x[0] contains only head... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ReadFASTA(fastafile):\n lines = open(fastafile).readlines()\n headers_seqs = []\n header = None\n seq = []\n for line in lines:\n if line[0] == '>':\n if (not header) and (not seq):\n pass # first sequence in file\n elif header and not seq:\n ... | [
"0.76121736",
"0.6860627",
"0.67152005",
"0.6706671",
"0.6701969",
"0.6697289",
"0.6667222",
"0.6633265",
"0.65563095",
"0.65458727",
"0.65280664",
"0.6475872",
"0.64492995",
"0.64413077",
"0.6364521",
"0.6364521",
"0.63030875",
"0.6302384",
"0.62837064",
"0.61853427",
"0.618... | 0.8069983 | 0 |
Reads in a FASTQ file and writes it to a new FASTA file. This definition should also keep the same file name and change the extension to from .fastq to .fasta if new_name is not specified. | def fastq_to_fasta(file_name, new_name=None):
if(file_name.endswith('.fastq')):
with open('../test_files/' + file_name, 'r') as infile:
text = infile.read()
if new_name == None:
f = open('../test_files/'+file_name.split('.')[0]+'.fasta','w+')
print('Ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fastq_to_fasta(input_file, wanted_set):\n file_name = os.path.splitext(os.path.basename(input_file))[0]\n with open(file_name + \"_filtered.fasta\", \"w\") as out:\n for record in SeqIO.parse(input_file, \"fastq\"):\n ID = str(record.id)\n SEQ = str(record.seq)\n i... | [
"0.5908012",
"0.57850957",
"0.5716593",
"0.56831974",
"0.56598663",
"0.56053895",
"0.5586926",
"0.5581481",
"0.5579382",
"0.5540243",
"0.55108505",
"0.55101264",
"0.54717064",
"0.5441375",
"0.54151505",
"0.5385739",
"0.53766024",
"0.5341403",
"0.5340518",
"0.5337158",
"0.5326... | 0.848807 | 0 |
Generates a list of all 6 possible reading frames for a given strand of DNA | def reading_frames(dna):
#the 6 types are as follows
# the actual string and the reverse complement
list = []
#this is the actual string
list.append(dna)
#this is the reverse complement of the string
# done reusing the fastcomplement() method that was already available.
#others are done ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_ORFs(dna):\n\n readingFrame0 = ''\n readingFrame1 = ''\n readingFrame2 = ''\n output = ''\n for k in range(0,3): \n if k ==0: \n readingFrame0 = find_all_ORFs_oneframe(dna[k:])\n elif k ==1: \n readingFrame1 = find_all_ORFs_oneframe(dna[k:])\n ... | [
"0.65610415",
"0.654116",
"0.6465748",
"0.6425101",
"0.6400191",
"0.6245368",
"0.61965746",
"0.6174377",
"0.6132045",
"0.6130481",
"0.60865504",
"0.6047133",
"0.6040552",
"0.60298204",
"0.60196996",
"0.5954839",
"0.591576",
"0.5874647",
"0.5840224",
"0.58145535",
"0.58045846"... | 0.7209891 | 0 |
fetches instruction from ROM, increases IP and returns instruction | def fetch_instruction(self) -> dict:
instruction = self.__ROM.read(self.regs["ip"].read())
self.regs["ip"].inc()
return self.disassembler.decode_instruction(instruction) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_execute(self):\n\n op_code = self.mem.read(self.reg.ip)\n self.reg.ip_inc()\n addr = self.mem.read(self.reg.ip)\n self.reg.ip_inc()\n\n # Execute the instruction on addr.\n self.op_codes[op_code.num](addr)",
"def fetch(self):\n line = self.code[self.ip]\... | [
"0.677617",
"0.63121897",
"0.57688415",
"0.57639194",
"0.56438655",
"0.56249213",
"0.5590774",
"0.5558426",
"0.5549947",
"0.55308354",
"0.5505338",
"0.54756784",
"0.5458533",
"0.5436289",
"0.53643537",
"0.53420275",
"0.533024",
"0.53019565",
"0.5229638",
"0.51992863",
"0.5196... | 0.7375822 | 0 |
Gets book statuses from the dim_book_statuses table. | def get_book_statuses() -> list:
return data.get_book_statuses() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_statuses(self):\n return self.statuses",
"def statuses(self):\n return self._get_paged(\"statuses\")",
"async def getstatuses(self, ctx):\n final_list = \"\"\n statuses = await ex.get_bot_statuses()\n if statuses is not None:\n for status in await ex.get_bo... | [
"0.63397527",
"0.62338936",
"0.6056262",
"0.5881798",
"0.58743775",
"0.5870557",
"0.5784424",
"0.5598575",
"0.53600687",
"0.53600687",
"0.5335189",
"0.52850866",
"0.5255495",
"0.5245465",
"0.5239241",
"0.52107036",
"0.52041435",
"0.51484483",
"0.51168203",
"0.5098181",
"0.508... | 0.7752342 | 0 |
compute the LR1 closure of items | def closure(items, ruleSet, terminals):
I = copy.deepcopy(items)
added = 1
while added:
added = 0
#for each item [A -> alpha . B Beta, a] in I (result)
for item in I:
if item.pointAtEnd(): continue
A = item.lhs
alpha = item.rhs[:item.dotPos]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_item_closure(itemset, productionset):\r\n #For every item inside current itemset, if we have the following rule:\r\n # xxx <cursor><nonterminalSymbol> xxx append every rule from self._productionruleset that begins with that NonTerminalSymbol\r\n if not isinstance(itemset, LR0ItemSet):\r\n ... | [
"0.5816267",
"0.57219464",
"0.5648127",
"0.54384965",
"0.54112405",
"0.54015505",
"0.533691",
"0.52744246",
"0.52543527",
"0.5183656",
"0.5157742",
"0.514377",
"0.5122546",
"0.51188684",
"0.51163983",
"0.51161325",
"0.51054764",
"0.5103773",
"0.5095413",
"0.50749654",
"0.5074... | 0.61120766 | 0 |
find targetSet in C | def fullIndex(C, targetSet):
for i in range(len(C)):
if not fullCmpSets(C[i], targetSet):
return i
raise 'OhShit', "couldn't find %s\n%s" % (targetSet, C[4]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSets():",
"def test_find_sets(self):\n cards = numpy.array([[1,1,1,2,0],\n [0,1,2,2,2],\n [0,1,2,2,2],\n [0,1,2,2,2]])\n\n set_indices = set_solver.find_sets(cards)\n self.assertEqual(len(set_indices),... | [
"0.6221172",
"0.6146109",
"0.6115618",
"0.6065418",
"0.60626835",
"0.6042033",
"0.6042033",
"0.59801114",
"0.59222025",
"0.5874613",
"0.58715564",
"0.58662826",
"0.58362824",
"0.5833347",
"0.58118105",
"0.5797853",
"0.57861584",
"0.57830733",
"0.5778525",
"0.57779676",
"0.577... | 0.6192314 | 1 |
Generate an LR(1) state table | def generateStateTable(C, ruleSet, terminals, indexFunc):
#initialize the state dictionary
stateDict = {}
for i in range(len(C)):
stateDict[i] = {}
gotoDict = {}
for i in range(len(C)):
gotoDict[i] = {}
#compute the states
for state in range(len(C)):
for item in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_table(self):\n states = self.get_canonical_collection()\n # self.print_canonical_collection(states)\n table = [{} for _ in range(len(states))]\n\n for index in range(len(states)):\n state = states[index]\n first_rule_cnt = 0\n second_rule_cn... | [
"0.6823201",
"0.59635055",
"0.59432924",
"0.59324837",
"0.5919664",
"0.5785841",
"0.5745793",
"0.5742737",
"0.5727405",
"0.5704459",
"0.5688638",
"0.5662519",
"0.5636774",
"0.56181955",
"0.561092",
"0.5608363",
"0.56077516",
"0.5607666",
"0.5600288",
"0.559829",
"0.55503726",... | 0.6284223 | 1 |
Print the invoice and mark it as sent, so that we can see more easily the next step of the workflow This Method overrides the one in the original invoice class | def invoice_print(self):
self.ensure_one()
self.sent = True
return self.env['report'].get_action(self, 'ferrua_report.report_invoice') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_invoice_dian_resend(self):\n self.ensure_one()\n template = self.env.ref('l10n_co_e-invoice.email_template_edi_invoice_dian', False)\n compose_form = self.env.ref('mail.email_compose_message_wizard_form', False)\n ctx = dict(\n default_model='account.invoice',\n ... | [
"0.6223257",
"0.60884035",
"0.6055741",
"0.60072035",
"0.5954929",
"0.5904435",
"0.5853541",
"0.5839624",
"0.58209735",
"0.57507336",
"0.57295054",
"0.5693066",
"0.56464297",
"0.5634363",
"0.5624102",
"0.56167454",
"0.5604158",
"0.56001776",
"0.5599313",
"0.55901307",
"0.5583... | 0.8144645 | 0 |
Test the retrieval system. For each input in image_ids, generate a list of IDs returned for that image. | def test(label_dict, image_ids, args):
log_header('Starting image retrieval preparations')
queries = []
if args.test_image is not None:
queries.append(args.test_image)
else:
logging.info('Generating random test queries')
number_of_images = len(image_ids)
# Generate r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_multi_images_ids(self, num_images=0): \n availability_images = imageInstance()\n images = availability_images.get_images()\n images_ids = []\n for image in images:\n if image.type == 'machine':\n images_ids.append( image.id.encode(\"latin-1\") ... | [
"0.7080062",
"0.6665811",
"0.6469198",
"0.643074",
"0.639978",
"0.6186044",
"0.61784416",
"0.6166096",
"0.6166096",
"0.6113377",
"0.6014358",
"0.5991673",
"0.5991526",
"0.5941047",
"0.5906495",
"0.5866268",
"0.5865587",
"0.5854042",
"0.58208966",
"0.5806179",
"0.5782617",
"... | 0.6839561 | 1 |
Square 32 < n < 99 | def square(n: int) -> int:
return int(n ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_squares(n):\n\n return sum([i * i for i in range(n)])",
"def square(n):\r\n squared = n ** 2\r\n print (\"%d squared is %d.\" % (n, squared)) ## გიო: შეცდომას აგდებდა სანამ ფრჩხილებში არ ჩავსვი\r\n return squared",
"def make_magic_square(N): # part a\n if N % 2 == 0:\n print('N must be... | [
"0.73049027",
"0.7087057",
"0.7078491",
"0.70378524",
"0.6993337",
"0.6979318",
"0.6968695",
"0.69222224",
"0.68997127",
"0.684079",
"0.6803975",
"0.6786549",
"0.67735994",
"0.67726743",
"0.6746669",
"0.67392933",
"0.67251664",
"0.67251664",
"0.67251664",
"0.6713144",
"0.6673... | 0.74875534 | 0 |
Pentagonal 26 < n < 81 | def pentagonal(n: int) -> int:
return int(n * (3 * n - 1) / 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pentagonal(n):\n return (n * ((3 * n) - 1)) / 2",
"def is_pentagonal(n):\r\n if ((1+(24*n+1)**0.5) / 6)%1 == 0:\r\n return True\r\n return False",
"def pentagon(n) -> int:\n\n return (n * (3 * n - 1)) // 2",
"def isPentagonal(n):\n test = (sqrt(1+24*n)+1)/6\n return test == (int)... | [
"0.7227314",
"0.6879778",
"0.68287385",
"0.6813105",
"0.68031704",
"0.6631665",
"0.6621119",
"0.6595571",
"0.64292324",
"0.6410007",
"0.6353537",
"0.63163114",
"0.62923586",
"0.6150827",
"0.61487466",
"0.614311",
"0.6083966",
"0.6078726",
"0.6017164",
"0.6017101",
"0.6011597"... | 0.7106296 | 1 |
Hexagonal 23 < n < 70 | def hexagonal(n: int) -> int:
return int(n * (2 * n - 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hexagonal_number(n):\n return n * (2 * n - 1)",
"def is_hexagonal_number(n):\n _, x = quadratic.solve(2, -1, -n)\n return is_number(x) and x.is_integer()",
"def is_hex(n):\n hex_test = (1 + sqrt(1 + 8*n))/4\n if hex_test == int(hex_test):\n return True\n return False",
"def McNug... | [
"0.73256433",
"0.649887",
"0.64827543",
"0.63866496",
"0.62783104",
"0.6215221",
"0.61989176",
"0.6133955",
"0.61159766",
"0.61101925",
"0.60988736",
"0.60578424",
"0.6041439",
"0.60011524",
"0.5965139",
"0.59388924",
"0.59315044",
"0.59012663",
"0.5898888",
"0.58850104",
"0.... | 0.72794765 | 1 |
Heptagonal 21 < n < 63 | def heptagonal(n: int) -> int:
return int(n * (5 * n - 3) / 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hexagonal(n: int) -> int:\n return int(n * (2 * n - 1))",
"def H(n,x):\n if(n == 0):\n hn = 1\n elif(n == 1):\n hn = 2*x\n else:\n Hnm1 = 1; Hn = 2*x\n for i in range(1,n):\n H = 2*x*Hn - 2*i*Hnm1\n Hnm1 = Hn\n Hn = H\n hn = ... | [
"0.6687355",
"0.65955836",
"0.6554876",
"0.652879",
"0.64516014",
"0.64367026",
"0.6418375",
"0.63759947",
"0.6347117",
"0.6294453",
"0.6294453",
"0.62828547",
"0.6234204",
"0.61670166",
"0.6138718",
"0.6136461",
"0.6133237",
"0.60687983",
"0.60186327",
"0.6014623",
"0.601341... | 0.81946015 | 0 |
Octagonal 19 < n < 58 | def octagonal(n: int) -> int:
return int(n * (3 * n - 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hexagonal_number(n):\n return n * (2 * n - 1)",
"def horne1986_Ni(N):\n return -6.362 + 1.193*N + 0.00098*N**2",
"def hexagonal(n: int) -> int:\n return int(n * (2 * n - 1))",
"def isPentagonal(n):\n test = (sqrt(1+24*n)+1)/6\n return test == (int) (test)",
"def McNuggets(n):\n # Your... | [
"0.63575953",
"0.63354844",
"0.6244672",
"0.61414593",
"0.61299133",
"0.61168927",
"0.60856116",
"0.6066138",
"0.60464036",
"0.6032416",
"0.6026403",
"0.6007042",
"0.5979031",
"0.5948708",
"0.59418005",
"0.59248644",
"0.5901751",
"0.5899809",
"0.58847505",
"0.5876129",
"0.585... | 0.6601916 | 0 |
computes the number of zernike coefficients given the radial polynomial order/level n. | def zernike_num_coeff(n):
if not (n>=0):
print('Input parameter must be >= 0')
raise AssertionError()
return sum(xrange(n+1)) + n+1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def N_z(self) -> int:\n return self.params.N_z",
"def formula_n(self, n: int, x: np.ndarray) -> np.ndarray:\n\n # express x as z = x/(x-1)\n z = x / (x - 1)\n\n # special case @n=0\n if n == 0:\n kn = 1 - self._vlerchphi(1 / z, n + 1)\n else:\n kn =... | [
"0.69166356",
"0.6618227",
"0.65092444",
"0.63854516",
"0.63752306",
"0.6365634",
"0.634402",
"0.6255035",
"0.6190102",
"0.61696285",
"0.6107539",
"0.60845035",
"0.60397416",
"0.593207",
"0.5926248",
"0.5918641",
"0.5896914",
"0.5892694",
"0.58867955",
"0.58669955",
"0.585806... | 0.74826425 | 0 |
Function to compute the Zernike polynomial (n, m) given a grid of radial coordinates rho and azimuthal coordinates phi. >>> zernike(3,5, 0.12345, 1.0) 0.0073082282475042991 | def zernike_poly(m, n, rho, phi):
if (m > 0): return zernike_rad(m, n, rho) * np.cos(m * phi)
if (m < 0): return zernike_rad(-m, n, rho) * np.sin(-m * phi)
return zernike_rad(0, n, rho) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zernike(m, n, rho, phi):\n if (m > 0): return zernike_rad(m, n, rho) * np.cos(m * phi)\n if (m < 0): return zernike_rad(-m, n, rho) * np.sin(-m * phi)\n return zernike_rad(0, n, rho)",
"def zernikel(j, rho, phi):\n n = 0\n while (j > n):\n n += 1\n j -= n\n m = -n+2*j\n ret... | [
"0.72611326",
"0.67792964",
"0.63562363",
"0.6140943",
"0.60044694",
"0.5997871",
"0.5987661",
"0.58109844",
"0.5753353",
"0.56706387",
"0.5536199",
"0.5432994",
"0.5377874",
"0.5369935",
"0.5335055",
"0.52910936",
"0.5261898",
"0.52562475",
"0.5235264",
"0.5219978",
"0.52159... | 0.72030765 | 1 |
Create an unit disk and convert to rho, phi and and masking the grid. | def unit_disk(imgSize):
# src = np.nan_to_num(imgsrc)
if not (imgSize > 0):
print('Nside must be > 0')
raise AssertionError()
nx = imgSize #, ny = src.shape
grid = (np.indices((nx, nx), dtype=np.float) - nx/2) / (nx*1./2) # create unit grid [-1,1]
grid_rho, gr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tt72_disk(m=10.e11|units.MSun,\n r_min=25.|units.kpc,\n n_rings=[12,15,18,21,24,27,30,33,36,39,42,45],\n r_rings_rel=[0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75],\n disk_id='a',\n eps=0.|units.m):\n disk = Part... | [
"0.62119544",
"0.59816885",
"0.5803847",
"0.5753763",
"0.5676403",
"0.5614738",
"0.55297625",
"0.5526763",
"0.55237687",
"0.5414932",
"0.5387417",
"0.5368581",
"0.52788943",
"0.5258257",
"0.52431476",
"0.5216729",
"0.52134144",
"0.5209183",
"0.52089286",
"0.518013",
"0.516423... | 0.70307744 | 0 |
Truncate the coefficients upto the given threshold | def truncate(coeffs, threshold=99):
sortedindex = np.argsort(np.abs(coeffs))[::-1]
Ncoeff = coeffs.shape[-1]
cutoff = np.int(np.round(Ncoeff*threshold/100.))
# print "Keeping %2.0f %% (N=%s) of the biggest coefficients"%(threshold,cutoff)
coeffs_trunc = coeffs.copy() ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncate(self, precision) :\n precision = self.parent().action().filter(precision)\n nprec = min(self.precision(), precision)\n\n ncoefficients = dict( (ch, copy(self.__coefficients[ch]))\n for ch in self.__coefficients )\n return EquivariantMonoidPower... | [
"0.64514995",
"0.6273887",
"0.6269911",
"0.62587625",
"0.61372244",
"0.6091238",
"0.6072903",
"0.5973585",
"0.5852989",
"0.5852989",
"0.5834595",
"0.5436423",
"0.540269",
"0.5387345",
"0.5347651",
"0.5327133",
"0.53194124",
"0.5311541",
"0.53010476",
"0.52519625",
"0.524019",... | 0.82398957 | 0 |
Reconstruct a model image from the coeffcicients | def reconstruct_image(imgsrc, nlevels, trunc_threshold=None):
coeffs = zernike_basis_n_coeffs(imgsrc, nlevels, return_basis=False)
if trunc_threshold is not None:
coeffs = truncate(coeffs, threshold=trunc_threshold)
# Generate (rho, phi) grids and masking grid
grid_rho, grid_phi, grid_mask = unit_disk(img... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sweep_image_model():\n for c1 in [4, 8, 16]:\n for c2 in [2, 4]:\n for c3 in [2, 4]:\n for c4 in [1, 2]:\n flags = flag_reader.read_flag()\n print(c1)\n flags.channel_list = c1 * np.array([1, c2, c2*c3, c2*c3*c4])\n ... | [
"0.58549684",
"0.5555387",
"0.55510896",
"0.55296147",
"0.55021566",
"0.5373655",
"0.5363906",
"0.53565735",
"0.5355798",
"0.5353091",
"0.53364193",
"0.5315074",
"0.5299631",
"0.5290952",
"0.5287503",
"0.52676666",
"0.5245175",
"0.5205611",
"0.5202884",
"0.5200446",
"0.519828... | 0.5812254 | 1 |
figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k') 2Dpolynomials Computes 2 indices (n,m) to specify Zernike functions, starting from the top, shifts to the left and then right. | def zernike_visuo__pyramid(zbasis, n, m, nlevels, figsize=(12, 12), cmap='jet', fontsize=20, colorbar_labelsize=10):
cmap = plt.get_cmap('%s' %cmap)
index = 0
if not (nlevels>=0):
print('Input parameter must be >= 0')
raise AssertionError()
axlist = []
if (nle... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_poly(t, n, sz):\r\n\r\n\tfor i in range(n):\r\n\t\tt.forward(sz)\r\n\t\tt.left(360/n)",
"def draw_poly(t, n, sz):\n\tfor side in range(n):\n\t\tangle = (360/n)\n\t\tt.pendown()\n\t\tt.forward(sz)\n\t\tt.right(angle)",
"def draw_poly(t, n, sz):\r\n angle = 180 - (n - 2) * 180 / n\r\n for i in ran... | [
"0.5828909",
"0.5704472",
"0.56556016",
"0.550975",
"0.5487325",
"0.5477178",
"0.5431211",
"0.540554",
"0.52885914",
"0.5253599",
"0.5251076",
"0.52264196",
"0.5221086",
"0.5194837",
"0.5173083",
"0.5154963",
"0.5153161",
"0.515265",
"0.5121226",
"0.51142865",
"0.5109068",
... | 0.60281724 | 0 |
Create a dummy Supervisor structure and start a global patch. | def setUp(self):
from supvisors.plugin import expand_faults
self.supervisor = DummySupervisor()
# add a global patch
self.supvisors_patcher = patch('supvisors.rpcinterface.Supvisors')
self.mocked_supvisors = self.supvisors_patcher.start()
self.mocked_supvisors.return_valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supervisor_start():\n log('start supervisor', green)\n sudo('/etc/init.d/supervisor start')",
"def start():\n if env.latest:\n if env.python3:\n sudo('/bin/systemctl start demo-latest-py3', shell=False)\n else:\n sudo('/bin/systemctl start demo-latest.service', sh... | [
"0.60909",
"0.60832024",
"0.59310883",
"0.5775345",
"0.57694423",
"0.5722168",
"0.5652203",
"0.5642636",
"0.56172496",
"0.56158453",
"0.55636376",
"0.555367",
"0.55494773",
"0.5527663",
"0.55231017",
"0.55197024",
"0.551933",
"0.55121124",
"0.55111945",
"0.5498793",
"0.549747... | 0.69613576 | 0 |
Test the get_api_version RPC. | def test_api_version(self):
from supvisors.rpcinterface import API_VERSION, RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
self.assertEqual(API_VERSION, rpc.get_api_version()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_oapi_version(self):\n pass",
"def test_GetVersion(self):\n ret = wrap_xmlrpc_call(\n self.am_client.GetVersion, [], {}, settings.TIMEOUT)\n self.assertEqual(ret['geni_api'], 1)",
"def test_get_version(self):\n pass",
"def test_api_versioning(self):\n ... | [
"0.8000525",
"0.7959162",
"0.7700109",
"0.7642845",
"0.7372035",
"0.7357288",
"0.7071142",
"0.702428",
"0.6985507",
"0.69261676",
"0.6923056",
"0.6875212",
"0.68481594",
"0.68181723",
"0.680943",
"0.6766287",
"0.6759909",
"0.6751502",
"0.6746091",
"0.6720698",
"0.6720222",
... | 0.7964401 | 1 |
Test the get_supvisors_state RPC. | def test_supvisors_state(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.fsm.serial.return_value = 'RUNNING'
# create RPC instance
rpc = RPCInterface(self.supervisor)
self.assertEqual('RUNNING', rpc.get_supvisors_state()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_state(self):\n from supvisors.rpcinterface import RPCInterface\n # prepare context\n self.supervisor.supvisors.fsm.state = 1\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n # test there is no exception when internal state is in list\n ... | [
"0.73319936",
"0.5963998",
"0.5954794",
"0.5952734",
"0.583573",
"0.56402594",
"0.5603491",
"0.55639404",
"0.55524933",
"0.5551539",
"0.5479721",
"0.542013",
"0.5410942",
"0.5388947",
"0.53072816",
"0.53072816",
"0.52877516",
"0.52841717",
"0.52824414",
"0.5274595",
"0.524525... | 0.8239171 | 0 |
Test the get_master_address RPC. | def test_master_address(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.master_address = '10.0.0.1'
# create RPC instance
rpc = RPCInterface(self.supervisor)
self.assertEqual('10.0.0.1', rpc.get_master_address()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_client_address_retrieve(self):\n pass",
"def test_address_info(self):\n from supvisors.rpcinterface import RPCInterface\n # prepare context\n self.supervisor.supvisors.context.addresses = {\n '10.0.0.1': Mock(**{'serial.return_value': 'address_info'})}\n # c... | [
"0.7373237",
"0.7007187",
"0.6640062",
"0.6608692",
"0.65847445",
"0.6574519",
"0.6425423",
"0.635024",
"0.6174339",
"0.61202514",
"0.6092526",
"0.60028934",
"0.5985169",
"0.59719956",
"0.5930091",
"0.59041667",
"0.58911395",
"0.5854046",
"0.58010584",
"0.57993996",
"0.579268... | 0.808054 | 0 |
Test the get_strategies RPC. | def test_strategies(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.options.auto_fence = True
self.supervisor.supvisors.options.conciliation_strategy = 1
self.supervisor.supvisors.options.starting_strategy = 2
# create RP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_scenario(self):\n pass",
"def list_active_strategies():\n response = houston.get(\"/zipline/trade\")\n\n houston.raise_for_status_with_json(response)\n return response.json()",
"def test_get_scenarios(self):\n pass",
"def test_load_strategies_help_nc_params(self) -> None:\... | [
"0.6222215",
"0.6173919",
"0.609311",
"0.5985206",
"0.5939424",
"0.5787142",
"0.5773158",
"0.5661657",
"0.5650904",
"0.56022173",
"0.558637",
"0.5583461",
"0.5525984",
"0.550063",
"0.54794484",
"0.54728687",
"0.5461746",
"0.54616755",
"0.54547167",
"0.5448073",
"0.5440383",
... | 0.7040536 | 0 |
Test the get_address_info RPC. | def test_address_info(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.addresses = {
'10.0.0.1': Mock(**{'serial.return_value': 'address_info'})}
# create RPC instance
rpc = RPCInterface(self.supervisor)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_client_address_retrieve(self):\n pass",
"def rpc_getaddressinfo(self, address: str) -> dict:\n return self._call_command([\"getaddressinfo\", address])",
"def test_get_address(self):\n with self.subprocess_getoutput_patch:\n ret = self.inst._get_address()\n s... | [
"0.7554395",
"0.74039465",
"0.73748916",
"0.71039975",
"0.6900985",
"0.66765416",
"0.66494095",
"0.6630977",
"0.65611506",
"0.6506627",
"0.64812136",
"0.6447592",
"0.6382673",
"0.6365876",
"0.63463646",
"0.6344738",
"0.62960494",
"0.6278117",
"0.6209523",
"0.6179435",
"0.6157... | 0.855229 | 0 |
Test the get_all_addresses_info RPC. | def test_all_addresses_info(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.addresses = {
'10.0.0.1': Mock(**{'serial.return_value': 'address_info_1'}),
'10.0.0.2': Mock(**{'serial.return_value': 'address_info_2'}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_address_info(self):\n from supvisors.rpcinterface import RPCInterface\n # prepare context\n self.supervisor.supvisors.context.addresses = {\n '10.0.0.1': Mock(**{'serial.return_value': 'address_info'})}\n # create RPC instance\n rpc = RPCInterface(self.supervi... | [
"0.73864514",
"0.725401",
"0.7201281",
"0.70590824",
"0.69797766",
"0.69144094",
"0.67823094",
"0.66993743",
"0.6611087",
"0.65053475",
"0.64855546",
"0.64352447",
"0.6397789",
"0.6297383",
"0.6290662",
"0.6125736",
"0.6102892",
"0.607289",
"0.60336214",
"0.60237765",
"0.5996... | 0.84211046 | 0 |
Test the get_application_info RPC. | def test_application_info(self, mocked_serial, mocked_check):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test RPC call
self.assertEqual({'name': 'appli'}, rpc.get_application_info('dummy'))
self.assertEqual(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_application(self):\n from supvisors.rpcinterface import RPCInterface\n # prepare context\n self.supervisor.supvisors.context.applications = {\n 'appli_1': 'first application'}\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n # test wi... | [
"0.7368261",
"0.73541594",
"0.6974",
"0.6691222",
"0.6589215",
"0.65312827",
"0.6484086",
"0.6422234",
"0.6345299",
"0.63110584",
"0.6306084",
"0.62044394",
"0.6204126",
"0.62031215",
"0.61840945",
"0.6136629",
"0.6117112",
"0.6070039",
"0.6049411",
"0.604861",
"0.60403824",
... | 0.78726745 | 0 |
Test the get_all_applications_info RPC. | def test_all_applications_info(self, mocked_get, mocked_check):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.applications = {
'dummy_1': None, 'dummy_2': None}
# create RPC instance
rpc = RPCInterface(self.supervi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_application(self):\n from supvisors.rpcinterface import RPCInterface\n # prepare context\n self.supervisor.supvisors.context.applications = {\n 'appli_1': 'first application'}\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n # test wi... | [
"0.7007239",
"0.68767536",
"0.68270475",
"0.67084014",
"0.660541",
"0.66011083",
"0.65988123",
"0.65746206",
"0.6562028",
"0.6561185",
"0.6498757",
"0.6494644",
"0.64858603",
"0.64830405",
"0.6474421",
"0.6452741",
"0.64078385",
"0.6402389",
"0.635788",
"0.63436806",
"0.63235... | 0.8159693 | 0 |
Test the get_process_info RPC. | def test_process_info(self, mocked_get, mocked_check):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test first RPC call with process namespec
self.assertEqual([{'name': 'proc'}], rpc.get_process_info('appli:proc'))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_process(self):\n from supvisors.rpcinterface import RPCInterface\n # prepare context\n self.supervisor.supvisors.context.processes = {\n 'proc_1': 'first process'}\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n # test with known app... | [
"0.729027",
"0.70583725",
"0.69484574",
"0.6644473",
"0.652423",
"0.63419306",
"0.63237894",
"0.62368655",
"0.6222356",
"0.61415535",
"0.59827346",
"0.59538347",
"0.592685",
"0.5902934",
"0.5892789",
"0.58857656",
"0.58735555",
"0.58320194",
"0.582809",
"0.5811989",
"0.579052... | 0.7721014 | 0 |
Test the get_all_process_info RPC. | def test_all_process_info(self, mocked_check):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.processes = {
'proc_1': Mock(**{'serial.return_value': {'name': 'proc_1'}}),
'proc_2': Mock(**{'serial.return_value': {'name'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_process_info(self, mocked_get, mocked_check):\n from supvisors.rpcinterface import RPCInterface\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n # test first RPC call with process namespec\n self.assertEqual([{'name': 'proc'}], rpc.get_process_info('appli:... | [
"0.7329342",
"0.6957903",
"0.65616316",
"0.6420114",
"0.6354122",
"0.6345824",
"0.63279754",
"0.61812145",
"0.6033765",
"0.5974393",
"0.5931024",
"0.5903762",
"0.58925045",
"0.5880775",
"0.5865628",
"0.57525575",
"0.57450235",
"0.5720751",
"0.5692252",
"0.56884235",
"0.566540... | 0.79585636 | 0 |
Test the get_application_rules RPC. | def test_application_rules(self, mocked_get, mocked_check):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test RPC call with aplpication name
self.assertDictEqual(rpc.get_application_rules('appli'),
{'appl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rules(app):\n rules = [\n Rule('/', endpoint='home', handler='apps.busstopped.handlers.MainPage'),\n Rule('/ajax/busstopped/<line>/<direction>', endpoint='ajax-busstopped', handler='apps.busstopped.handlers.AjaxGetBusStopped'),\n Rule('/ajax/point', endpoint='ajax-point', handler='a... | [
"0.61743987",
"0.6174281",
"0.60503745",
"0.5967797",
"0.58577245",
"0.5849165",
"0.5733583",
"0.5689103",
"0.5606323",
"0.5581847",
"0.5567735",
"0.55466115",
"0.5459906",
"0.54573005",
"0.5432083",
"0.5393312",
"0.53748804",
"0.5352753",
"0.5312163",
"0.5278006",
"0.5268371... | 0.79674536 | 0 |
Test the get_process_rules RPC. | def test_process_rules(self, mocked_rules, mocked_get, mocked_check):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test first RPC call with process namespec
self.assertEqual([{'start': 1}], rpc.get_process_rules('appl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_internal_process_rules(self):\n from supvisors.rpcinterface import RPCInterface\n # prepare context\n process = Mock(application_name='appli', process_name='proc',\n **{'rules.serial.return_value': {'start': 0, 'stop': 1}})\n # create RPC instance\n rpc = ... | [
"0.7312982",
"0.68353486",
"0.5950732",
"0.5772875",
"0.56735706",
"0.56297094",
"0.550906",
"0.5429404",
"0.5396469",
"0.52568597",
"0.5201953",
"0.50758487",
"0.50694406",
"0.5058028",
"0.50381976",
"0.5031389",
"0.50032556",
"0.49975392",
"0.49968067",
"0.4989191",
"0.4978... | 0.7942605 | 0 |
Test the get_conflicts RPC. | def test_conflicts(self, mocked_check):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.processes = {
'proc_1': Mock(**{'conflicting.return_value': True,
'serial.return_value': {'name': 'proc_1'}}),
'proc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_conflicts(self):\n query = read_query('content exploration/all_conflicts')\n response = self._submit_query(query)\n return response",
"def get_conflicts(self):\n return []",
"def conflicts(self):\r\n params = {\r\n 'f' : 'json',\r\n 'sessionID' :... | [
"0.6577668",
"0.64147437",
"0.5933698",
"0.58578426",
"0.56442785",
"0.5582066",
"0.55808526",
"0.55581826",
"0.5516254",
"0.54974395",
"0.541847",
"0.5407259",
"0.53910816",
"0.53509426",
"0.53324175",
"0.532675",
"0.5297989",
"0.52902627",
"0.5282945",
"0.5280912",
"0.52803... | 0.6872376 | 0 |
Test the start_application RPC. | def test_start_application(self, mocked_check):
from supvisors.rpcinterface import RPCInterface
from supvisors.ttypes import ApplicationStates
# prepare context
self.supervisor.supvisors.context.applications = {'appli_1': Mock()}
# get patches
mocked_start = self.supervis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_application_start():\n\n process = subprocess.Popen(['python', 'runserver.py'],\n stderr=subprocess.STDOUT,\n stdout=subprocess.PIPE)\n\n assert process.pid\n debug_logging = process.stdout.read(100)\n process.kill()\n assert 'Starti... | [
"0.7454864",
"0.7355862",
"0.71761405",
"0.69260675",
"0.6739427",
"0.66530526",
"0.6608374",
"0.65118265",
"0.65054536",
"0.6480569",
"0.64436203",
"0.64220744",
"0.63778853",
"0.63504833",
"0.63466454",
"0.63317406",
"0.63304865",
"0.6306708",
"0.6297485",
"0.627524",
"0.62... | 0.77363515 | 0 |
Test the stop_application RPC. | def test_stop_application(self, mocked_check):
from supvisors.rpcinterface import RPCInterface
from supvisors.ttypes import ApplicationStates
# prepare context
self.supervisor.supvisors.context.applications = {'appli_1': Mock()}
# get patches
mocked_stop = self.supervisor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_stop(self, app_name=None):\n rc = self.socket_command_with_project('stop', app_name)\n return rc",
"def stop_app(package):\n G.DEVICE.stop_app(package)",
"def stop_app(self, app: str, **kwargs) -> None:\n kwargs[\"app\"] = app\n kwargs[\"namespace\"] = \"admin\"\n ... | [
"0.7295855",
"0.6790891",
"0.67763025",
"0.6693041",
"0.6658353",
"0.6607735",
"0.65045136",
"0.6495884",
"0.64950496",
"0.64893675",
"0.64876133",
"0.6467326",
"0.64614654",
"0.6457347",
"0.64467245",
"0.64464545",
"0.6444125",
"0.6443598",
"0.64290714",
"0.6423376",
"0.6399... | 0.8004846 | 0 |
Test the start_args RPC. | def test_start_args(self, mocked_check, mocked_proc):
from supvisors.rpcinterface import RPCInterface
# prepare context
info_source = self.supervisor.supvisors.info_source
info_source.update_extra_args.side_effect = KeyError
info_source.supervisor_rpc_interface.startProcess.side_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start( *args, **kwargs ):",
"def test_arguments(self):\n args = []\n def main(reactor, x, y, z):\n args.extend((x, y, z))\n return defer.succeed(None)\n r = _FakeReactor()\n exitError = self.assertRaises(\n SystemExit, task.react, main, [1, 2, 3], ... | [
"0.6905139",
"0.65304023",
"0.64246875",
"0.63796157",
"0.6378576",
"0.6330152",
"0.63238597",
"0.62722135",
"0.62404764",
"0.6227943",
"0.6223856",
"0.61745465",
"0.612772",
"0.61003673",
"0.60885257",
"0.6064845",
"0.60415494",
"0.60415494",
"0.60408163",
"0.6035867",
"0.60... | 0.73286694 | 0 |
Test the start_process RPC. | def test_start_process(self, mocked_check):
from supvisors.rpcinterface import RPCInterface
# get patches
mocked_start = self.supervisor.supvisors.starter.start_process
mocked_progress = self.supervisor.supvisors.starter.in_progress
# create RPC instance
rpc = RPCInterfac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_startProcess(self):\r\n self.pm.addProcess(\"foo\", [\"foo\"])\r\n self.pm.startProcess(\"foo\")\r\n self.assertIsInstance(self.pm.protocols[\"foo\"], LoggingProtocol)\r\n self.assertIn(\"foo\", self.pm.timeStarted.keys())",
"def test_startProcessAlreadyStarted(self):\r\n ... | [
"0.76212543",
"0.72994727",
"0.7251439",
"0.71272534",
"0.68497163",
"0.683988",
"0.6688136",
"0.66484785",
"0.6599558",
"0.65992403",
"0.65560764",
"0.6489021",
"0.6480702",
"0.64585495",
"0.64510113",
"0.64510113",
"0.64510113",
"0.64309233",
"0.63594514",
"0.6302075",
"0.6... | 0.73775786 | 1 |
Test the stop_process RPC. | def test_stop_process(self, mocked_check):
from supvisors.rpcinterface import RPCInterface
# get patches
mocked_stop = self.supervisor.supvisors.stopper.stop_process
mocked_progress = self.supervisor.supvisors.stopper.in_progress
# create RPC instance
rpc = RPCInterface(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_stopProcessAlreadyStopped(self):\r\n self.pm.addProcess(\"foo\", [\"foo\"])\r\n self.assertIdentical(None, self.pm.stopProcess(\"foo\"))",
"def stop(self):\n if not self.process_pid:\n raise Exception('why is this being called? %s' % self.server_name)\n\n if self.s... | [
"0.7195323",
"0.7141915",
"0.71212816",
"0.7064413",
"0.6944247",
"0.69071764",
"0.6824049",
"0.6727711",
"0.66971034",
"0.6683262",
"0.6661832",
"0.6655495",
"0.6623781",
"0.65811753",
"0.65610534",
"0.6559678",
"0.65566313",
"0.65525216",
"0.65419906",
"0.65386456",
"0.6491... | 0.7584913 | 0 |
Test the restart_process RPC. | def test_restart_process(self, mocked_check, mocked_stop, mocked_start):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test RPC call with sub-RPC calls return a direct result
mocked_stop.return_value = True
moc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_restart(self, mocked_check):\n from supvisors.rpcinterface import RPCInterface\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n # test RPC call\n self.assertTrue(rpc.restart())\n self.assertEqual([call()], mocked_check.call_args_list)\n self.... | [
"0.74959534",
"0.66252",
"0.6596089",
"0.65471625",
"0.6435779",
"0.64335114",
"0.6431384",
"0.6397377",
"0.6390887",
"0.638588",
"0.63406944",
"0.63202333",
"0.63175344",
"0.63125736",
"0.62787807",
"0.62722135",
"0.62677217",
"0.6243573",
"0.6206397",
"0.62012064",
"0.61994... | 0.69359463 | 1 |
Test the restart RPC. | def test_restart(self, mocked_check):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test RPC call
self.assertTrue(rpc.restart())
self.assertEqual([call()], mocked_check.call_args_list)
self.assertEqual(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restart(self):\n self.client.post(self.path+'/action', { 'restart': {} })\n return True",
"def test_workflows_restart(self):\n pass",
"def request_shutdown(self, restart=False):",
"def test_restart_with_permission(self):\n self.create_user_with_role(\n self.user.nam... | [
"0.7226226",
"0.7071774",
"0.7053413",
"0.70081186",
"0.7006562",
"0.698987",
"0.69765115",
"0.69687736",
"0.6965393",
"0.69375616",
"0.68979055",
"0.6863509",
"0.68230516",
"0.6762587",
"0.67550564",
"0.67488146",
"0.67346156",
"0.66920686",
"0.6683994",
"0.6678042",
"0.6675... | 0.8111426 | 0 |
Test the shutdown RPC. | def test_shutdown(self, mocked_check):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test RPC call
self.assertTrue(rpc.shutdown())
self.assertEqual([call()], mocked_check.call_args_list)
self.assertEqua... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_shutdown(self):\n server, client = loopback()\n assert not server.shutdown()\n assert server.get_shutdown() == SENT_SHUTDOWN\n with pytest.raises(ZeroReturnError):\n client.recv(1024)\n assert client.get_shutdown() == RECEIVED_SHUTDOWN\n client.shutdown... | [
"0.783223",
"0.77352977",
"0.77224475",
"0.7679559",
"0.76429117",
"0.76429117",
"0.7637141",
"0.7588095",
"0.7582137",
"0.7575391",
"0.75700086",
"0.75486475",
"0.7517524",
"0.7471619",
"0.74646",
"0.7327999",
"0.73250216",
"0.73169494",
"0.7295251",
"0.72056586",
"0.7205658... | 0.80968934 | 0 |
Test the _check_state utility. | def test_check_state(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.fsm.state = 1
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test there is no exception when internal state is in list
rpc._check_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_state(self):\n pass",
"def testCheck(self):\n change = ChangeState(self.config, \"changestate_t\")\n\n # Run through all good state transitions and assert that they work\n for state in self.transitions:\n for dest in self.transitions[state]:\n chang... | [
"0.79675",
"0.71266323",
"0.70088804",
"0.6942538",
"0.6725998",
"0.6645437",
"0.6645181",
"0.65727943",
"0.6550575",
"0.6542334",
"0.6542207",
"0.6537113",
"0.64828724",
"0.6481464",
"0.6468",
"0.6467975",
"0.64562637",
"0.6441143",
"0.64320195",
"0.64166635",
"0.6395076",
... | 0.73738015 | 1 |
Test the _check_operating_conciliation utility. | def test_check_operating_conciliation(self):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test the call to _check_state
with patch.object(rpc, '_check_state') as mocked_check:
rpc._check_operating_concilia... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_operating(self):\n from supvisors.rpcinterface import RPCInterface\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n # test the call to _check_state\n with patch.object(rpc, '_check_state') as mocked_check:\n rpc._check_operating()\n ... | [
"0.6519928",
"0.6440953",
"0.61492294",
"0.590797",
"0.5904521",
"0.5858469",
"0.56378543",
"0.55682796",
"0.5562345",
"0.5540245",
"0.5521831",
"0.5508402",
"0.5452533",
"0.5452016",
"0.54487675",
"0.5446748",
"0.54436237",
"0.54253554",
"0.53988814",
"0.5389293",
"0.5381409... | 0.7427168 | 0 |
Test the _check_operating utility. | def test_check_operating(self):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test the call to _check_state
with patch.object(rpc, '_check_state') as mocked_check:
rpc._check_operating()
self.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_guest_os(self):\n self.check_guest_os()",
"def test_guest_os(self):\n self.check_guest_os()",
"def test_guest_os(self):\n self.check_guest_os()",
"def test_guest_os(self):\n self.check_guest_os()",
"def test_guest_os(self):\n self.check_guest_os()",
"def test_g... | [
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.68196166",
"0.67601526",
"0.6475166",
"0.643593",
"0.6278641",
... | 0.6844397 | 0 |
Test the _check_conciliation utility. | def test_check_conciliation(self):
from supvisors.rpcinterface import RPCInterface
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test the call to _check_state
with patch.object(rpc, '_check_state') as mocked_check:
rpc._check_conciliation()
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testConsistency(self):\n #self.assertAlmostEqual(self.fxlinkedcashflow.amount(),0)",
"def testConsistency(self):",
"def test_check_operating_conciliation(self):\n from supvisors.rpcinterface import RPCInterface\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n ... | [
"0.68510354",
"0.6846493",
"0.6562092",
"0.63179034",
"0.61420643",
"0.6091703",
"0.60424334",
"0.59893084",
"0.5966891",
"0.59391546",
"0.5938386",
"0.5933276",
"0.59315526",
"0.5929876",
"0.589915",
"0.58848256",
"0.58695066",
"0.581776",
"0.5805792",
"0.57975614",
"0.57876... | 0.7145031 | 0 |
Test the _get_application utility. | def test_get_application(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.applications = {
'appli_1': 'first application'}
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test with known app... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_current_app():\n\n assert isinstance(application_services.get_current_app(), PyrinUnitTestApplication)",
"def test_duo_application_get(self):\n pass",
"def test_get_app(self):\n settings = SparkSettings()\n self.device.app_name = 'test_app'\n app = self.device.get_ap... | [
"0.79300493",
"0.7923467",
"0.7482519",
"0.72564995",
"0.7204716",
"0.7126646",
"0.7114369",
"0.70957977",
"0.70542693",
"0.69555336",
"0.68862665",
"0.6877717",
"0.6860193",
"0.6796819",
"0.67926157",
"0.67229486",
"0.67151153",
"0.66720337",
"0.66657794",
"0.66657794",
"0.6... | 0.8022673 | 0 |
Test the _get_process utility. | def test_get_process(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.processes = {
'proc_1': 'first process'}
# create RPC instance
rpc = RPCInterface(self.supervisor)
# test with known application
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_process_id():\n output = sh.process_id()\n assert isinstance(output, int) and output > 0",
"def available_process(**kwargs):\n return LazySubprocessTester([sys.executable, \"-c\", \"import sys; sys.exit(0)\"], **kwargs)",
"def testProcess(self):\n self.grr_hunt_osquery_collector.Process()\... | [
"0.6831519",
"0.6654932",
"0.6633849",
"0.649761",
"0.6460552",
"0.636034",
"0.6298995",
"0.62798244",
"0.6242188",
"0.6223125",
"0.6124697",
"0.61064655",
"0.61037904",
"0.606647",
"0.6062281",
"0.6037169",
"0.603703",
"0.60273314",
"0.6011603",
"0.59744817",
"0.5972552",
... | 0.7586149 | 0 |
Test the _get_application_process utility. | def test_get_application_process(self):
from supvisors.rpcinterface import RPCInterface
# prepare context
self.supervisor.supvisors.context.applications = {
'appli_1': 'first application'}
self.supervisor.supvisors.context.processes = {
'appli_1:proc_1': 'first pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_process(self):\n from supvisors.rpcinterface import RPCInterface\n # prepare context\n self.supervisor.supvisors.context.processes = {\n 'proc_1': 'first process'}\n # create RPC instance\n rpc = RPCInterface(self.supervisor)\n # test with known app... | [
"0.7337078",
"0.6793422",
"0.6699983",
"0.6477558",
"0.62719095",
"0.6189609",
"0.6161677",
"0.6108943",
"0.61022514",
"0.6090383",
"0.6088105",
"0.6086325",
"0.60370046",
"0.6022044",
"0.6007411",
"0.59575355",
"0.5954603",
"0.59493035",
"0.59328574",
"0.59290457",
"0.591145... | 0.75706846 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.