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 |
|---|---|---|---|---|---|---|
Read image using its path. Default value is grayscale, and image is read by YCbCr format as the paper said. | def imread(path, is_grayscale=True):
if is_grayscale:
return scipy.misc.imread(path, flatten=True, mode='YCbCr').astype(np.float)
else:
return scipy.misc.imread(path, mode='YCbCr').astype(np.float) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imread(path, is_grayscale=True):\n if is_grayscale:\n #flatten=True 以灰度图的形式读取 \n return scipy.misc.imread(path, flatten=True, mode='YCbCr').astype(np.float)\n else:\n return scipy.misc.imread(path, mode='YCbCr').astype(np.float)",
"def imread(path, is_grayscale=True):\n if is_grayscale:\n ... | [
"0.778447",
"0.77261835",
"0.7638995",
"0.75208247",
"0.74676746",
"0.74573797",
"0.7367039",
"0.722754",
"0.721408",
"0.72122663",
"0.71996546",
"0.7183188",
"0.70761466",
"0.7057287",
"0.7026387",
"0.70155853",
"0.6943071",
"0.6942862",
"0.69331473",
"0.689974",
"0.6891293"... | 0.7768587 | 1 |
Dynamically generate options for resource group form field based on the user's selection for Environment. This method requires the user to set the resource_group parameter as dependent on environment. | def generate_options_for_resource_group(control_value=None, **kwargs):
if control_value is None:
return []
env = Environment.objects.get(id=control_value)
if CB_VERSION_93_PLUS:
# Get the Resource Groups as defined on the Environment. The Resource Group is a
# CustomField that is o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_options_for_cloudbolt_environment(group=None, **kwargs):\n envs = Environment.objects.filter(\n resource_handler__resource_technology__name='Google Cloud Platform') \\\n .select_related('resource_handler')\n if group:\n group_env_ids = [env.id for env in group.get_available_... | [
"0.6358487",
"0.5937777",
"0.55043066",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
"0.54691523",
... | 0.6859024 | 0 |
Return the initialized output formatter based upon the configuration. | def initialize_formatter(config):
if config.json: # pylint: disable=R1705
return formatters.JsonFormatter()
elif config.severity: # pylint: disable=R1705
return formatters.SeverityFormatter(config.colored)
return formatters.Formatter(config.colored) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_formatter(self):\n return SectionedFormatter(\n sections=self.sections,\n width=self.terminal_width,\n max_width=self.max_content_width,\n )",
"def set_formatter_string(config: dict):\n formatter_str = \"%(levelname)s %(name)s\"\n\n if config.get(\"fo... | [
"0.6507591",
"0.59741753",
"0.5937114",
"0.5926568",
"0.5859191",
"0.58575606",
"0.5845092",
"0.5838448",
"0.5783071",
"0.57651764",
"0.57422423",
"0.5739221",
"0.5724411",
"0.56877214",
"0.56793237",
"0.56695",
"0.5667886",
"0.566292",
"0.56339353",
"0.56309354",
"0.56209934... | 0.74388397 | 0 |
Returns the sorted list of problems. | def sort_problems(problems):
# Note: sort() doesn't return the sorted list; rather, it sorts the list
# in place
problems.sort(
key=lambda problem: (
problem.filename,
problem.linenumber,
problem.rule.id
)
)
return problems | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem_list(self):\r\n return [{\r\n 'location': location, 'problem_name': name,\r\n 'num_graded': self.DUMMY_DATA['problem_list_num_graded'],\r\n 'num_pending': self.DUMMY_DATA['problem_list_num_pending'],\r\n 'num_required': self.DUMMY_DATA['problem_list_nu... | [
"0.6703581",
"0.6595729",
"0.62168723",
"0.6204288",
"0.6180413",
"0.61678904",
"0.6021558",
"0.5934097",
"0.5893262",
"0.58796406",
"0.58487594",
"0.5641037",
"0.5635462",
"0.5628445",
"0.5586737",
"0.5583212",
"0.54723084",
"0.5472102",
"0.547204",
"0.5451602",
"0.54358476"... | 0.75329185 | 0 |
Returns the name of the class attribute to be used for classification. | def get_class_attribute(self):
return self.class_attr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self) -> str:\n return self.class_names[self.class_num]",
"def get_attribute_class(self, attr_name):\n return self.attrs.get_attribute_class(attr_name)",
"def class_name(self) -> str:\n return pulumi.get(self, \"class_name\")",
"def get_attribute_class(self):\n return sel... | [
"0.7220845",
"0.7191606",
"0.7166631",
"0.70328903",
"0.6854248",
"0.68273634",
"0.68061316",
"0.6639919",
"0.66164047",
"0.65259147",
"0.64209676",
"0.64048225",
"0.63896745",
"0.637577",
"0.637577",
"0.6366623",
"0.6366623",
"0.63627464",
"0.63504124",
"0.63288695",
"0.6326... | 0.7351364 | 0 |
Returns the value used in the dataset to indicate the positive classification choice. | def get_positive_class_val(self, tag):
# FIXME this dependence between tags and metadata is bad; don't know how to fix it right now
if tag == 'numerical-binsensitive':
return 1
else:
return self.positive_class_val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __value_of(sentiment):\n if sentiment == 'positive': return 1\n if sentiment == 'negative': return -1\n return 0",
"def get_prediction_from_score(score):\n if(score >= 0.03):\n return 'Positive'\n elif(score <= -0.03):\n return 'Negative'\n else:\n return 'Neutral'",
... | [
"0.6920214",
"0.6468132",
"0.6377437",
"0.6298673",
"0.6298673",
"0.6276346",
"0.62528133",
"0.62347436",
"0.6230235",
"0.61446166",
"0.61428374",
"0.6095599",
"0.60748625",
"0.6050616",
"0.6050616",
"0.6050616",
"0.6050616",
"0.6029829",
"0.60096",
"0.5973834",
"0.5958873",
... | 0.73992556 | 0 |
Returns a list of the names of any sensitive / protected attribute(s) that will be used for a fairness analysis and should not be used to train the model. | def get_sensitive_attributes(self):
return self.sensitive_attrs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __listAttr(self):\n attr = dir(self) # already sorted\n filter = []\n for name in attr:\n if name[:2] == '__': pass\n elif name[:10] == '_HelpDoc__': pass # used to mask private attr\n elif name in self.__exclude: pass\n else: filter.append(name)... | [
"0.70694345",
"0.66682184",
"0.6661344",
"0.66439575",
"0.66118485",
"0.654151",
"0.6416619",
"0.6314357",
"0.63003594",
"0.626828",
"0.6239923",
"0.62366736",
"0.62366736",
"0.6221969",
"0.6175809",
"0.61643624",
"0.61223054",
"0.6114993",
"0.61009276",
"0.6096935",
"0.60964... | 0.7331742 | 0 |
Same as get_sensitive_attributes, but also includes the joint sensitive attribute if there is more than one sensitive attribute. | def get_sensitive_attributes_with_joint(self):
if len(self.get_sensitive_attributes()) > 1:
return self.get_sensitive_attributes() + ['-'.join(self.get_sensitive_attributes())]
return self.get_sensitive_attributes() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sensitive_attributes(self):\n return self.sensitive_attrs",
"def get_sensitive_terms(self):\n sensitive_terms_dict = {}\n for attribute in self.__non_redundant_entity_attributes:\n for record_id, sensitive_terms in self.__df[attribute].dropna().iteritems():\n ... | [
"0.7723388",
"0.61657095",
"0.5457752",
"0.53589123",
"0.5331123",
"0.5112113",
"0.5105332",
"0.51015556",
"0.5088783",
"0.50400466",
"0.5025615",
"0.5014114",
"0.5013227",
"0.49880865",
"0.4979075",
"0.495395",
"0.4940964",
"0.49345672",
"0.49345672",
"0.49008775",
"0.489157... | 0.85016006 | 0 |
Returns a list in the same order as the sensitive attributes list above of the privileged class name (exactly as it appears in the data) of the associated sensitive attribute. | def get_privileged_class_names(self, tag):
# FIXME this dependence between tags and privileged class names is bad; don't know how to
# fix it right now
if tag == 'numerical-binsensitive':
return [1 for x in self.get_sensitive_attributes()]
else:
return self.privil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDataAttributes(self):\n asRet = [];\n asAttrs = dir(self);\n for sAttr in asAttrs:\n if sAttr[0] == '_' or sAttr[0] == 'k':\n continue;\n if sAttr in self.kasInternalAttributes:\n continue;\n oValue = getattr(self, sAttr);... | [
"0.70606923",
"0.7041535",
"0.69863814",
"0.6956516",
"0.6759619",
"0.66697687",
"0.66511804",
"0.6639891",
"0.64760447",
"0.638376",
"0.6333704",
"0.632314",
"0.62966156",
"0.61981976",
"0.6196645",
"0.6196645",
"0.6156528",
"0.6151096",
"0.61357003",
"0.6134827",
"0.6129417... | 0.7225402 | 0 |
Same as get_privileged_class_names, but also includes the joint sensitive attribute if there is more than one sensitive attribute. | def get_privileged_class_names_with_joint(self, tag):
priv_class_names = self.get_privileged_class_names(tag)
if len(priv_class_names) > 1:
return priv_class_names + ['-'.join(str(v) for v in priv_class_names)]
return priv_class_names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_privileged_class_names(self, tag):\n # FIXME this dependence between tags and privileged class names is bad; don't know how to\n # fix it right now\n if tag == 'numerical-binsensitive':\n return [1 for x in self.get_sensitive_attributes()]\n else:\n return ... | [
"0.73706985",
"0.6840645",
"0.6202078",
"0.594918",
"0.5039532",
"0.50019443",
"0.49859846",
"0.49820405",
"0.49799612",
"0.49191874",
"0.49018767",
"0.48560244",
"0.48521727",
"0.48503172",
"0.48184666",
"0.478812",
"0.47643054",
"0.47436982",
"0.47109863",
"0.47010607",
"0.... | 0.7298145 | 1 |
A passing grade in the Ricci data is defined as any grade above a 70 in the combined oral and written score. (See Miao 2010.) | def passing_grade(row):
if row['Combine'] >= 70.0:
return 1
else:
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grade(self):\n if round(self.numAvg,0) >= 70:\n return round(self.numAvg,0)\n elif self.PassSummer:\n return 70\n elif round(self.numAvg,0) >= 55 and not self.PassSummer:\n return round(self.numAvg,0)\n else:\n return 55",
"def calc_grad... | [
"0.7085485",
"0.6440944",
"0.63578296",
"0.63572264",
"0.6289942",
"0.6267479",
"0.60695726",
"0.59769577",
"0.5956954",
"0.59330213",
"0.5848372",
"0.5821019",
"0.58090127",
"0.58062154",
"0.57650155",
"0.57590044",
"0.5737819",
"0.5693649",
"0.5693649",
"0.5689963",
"0.5680... | 0.7371235 | 0 |
Given a ZEROindexed position `pos` on the contig, what is the relative ZEROindexed nucleotide position within this annotation's coding sequence? | def nt_pos(self, pos):
seq_consumed = 0
if self.coding_blocks is None or len(self.coding_blocks) == 0:
return int(self.end - pos - 1 if self.rev_strand else pos - self.start)
for block in (reversed(self.coding_blocks) if self.rev_strand else self.coding_blocks):
if pos >=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_offset_pos(seq, pos):\n \n nogap_seq = transform_seq(seq)\n assert(pos >= 0 and pos < len(nogap_seq))\n\n maps = dict()\n cnt = 0\n maxi = 0\n for i in range(len(seq)):\n if seq[i] not in msa_characters:\n maps[i-cnt] = i\n maxi = i\n else:\n ... | [
"0.71565324",
"0.70421827",
"0.6502028",
"0.6497681",
"0.64480406",
"0.6386525",
"0.6327573",
"0.63075775",
"0.6233408",
"0.6213303",
"0.62095505",
"0.6183801",
"0.6171228",
"0.6140234",
"0.6121173",
"0.6088656",
"0.60556525",
"0.6051068",
"0.6037078",
"0.6037078",
"0.6037078... | 0.7121677 | 1 |
Given an iterable `alts` of nucleotides to be substituted at contig position `pos`, return a list of the corresponding amino acid changes that would occur. `transl_table` is the NCBI genetic code to use when translating the coding sequence. | def aa_alts(self, alts, pos, transl_table=11):
aa_alts = []
nt_pos = self.nt_pos(pos)
aa_pos = self.aa_pos(pos)
for i, allele in enumerate(alts):
mut_seq = str(self.seq_record.seq)
if self.rev_strand:
allele = str(Seq(allele, generic_dna).reverse_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_AA_subs(s):\r\n test_seq = s.toseq()[70:217].translate() #Translate the mutated region\r\n substitutions = []\r\n \r\n for i in range(len(test_seq)):\r\n if test_seq[i] != align_temp[i]:\r\n substitutions.append(''.join([str(align_temp[i]),\r\n ... | [
"0.5816646",
"0.5639811",
"0.5312178",
"0.52944434",
"0.5252611",
"0.5239229",
"0.52306616",
"0.5195211",
"0.5128543",
"0.5119812",
"0.507834",
"0.5040113",
"0.5009105",
"0.49986827",
"0.49927104",
"0.49352637",
"0.49287802",
"0.49183488",
"0.4885356",
"0.48789275",
"0.486549... | 0.73933816 | 0 |
Load all genes in the BED file as SeqRecords, fetching their sequence data from the reference. ref_contigs is a dictionary of ref contig sequences created with BioPython's SeqIO.to_dict(). | def get_bed_annots(bed_path, ref_contigs, quiet=False):
annots = defaultdict(list)
with open(bed_path) as f:
for line in f:
line = line.strip().split("\t")
# Note: BED coordinates are 0-indexed, right-open.
chrom, start, end, name, strand = line[0], int(line[1]), int(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_gene_dict(reference_genbank_name=\"data/covid-19-genbank.gb\"):\n recs = [rec for rec in SeqIO.parse(reference_genbank_name, \"genbank\")]\n gene_dict = {}\n for rec in recs:\n feats = [feat for feat in rec.features if feat.type == \"CDS\"]\n for feat in feats:\n content ... | [
"0.67605436",
"0.6540504",
"0.6476846",
"0.6414153",
"0.6203886",
"0.6145601",
"0.61397177",
"0.6064767",
"0.58231187",
"0.5773407",
"0.575686",
"0.57291776",
"0.55980134",
"0.5574859",
"0.5554105",
"0.55270934",
"0.5468517",
"0.54490787",
"0.54445904",
"0.5379438",
"0.537297... | 0.6616143 | 1 |
Load all genes in the Sequin table as SeqRecords, fetching their sequence data from the reference. ref_contigs is a dictionary of ref contig sequences created with BioPython's SeqIO.to_dict(). | def get_sequin_annots(sequin_path, ref_contigs, quiet=False):
annots = defaultdict(list)
# We need a dummy class to hold the current state while parsing
# (otherwise the below private functions can't modify it; there's no "nonlocal" in python 2.x)
class _:
in_contig = None
in_featur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadReferenceContigs(referencePath, alignmentSet, windows=None):\n # FIXME we should get rid of this entirely, but I think it requires\n # fixing the inconsistency in how contigs are referenced here versus in\n # pbcore.io\n\n # Read contigs from FASTA file (or XML dataset)\n ... | [
"0.63969433",
"0.6097736",
"0.5661921",
"0.56599265",
"0.5587677",
"0.5557396",
"0.5501603",
"0.5493998",
"0.54772866",
"0.5400377",
"0.53919554",
"0.53289264",
"0.53228486",
"0.52766865",
"0.52260077",
"0.5225814",
"0.5206542",
"0.5159658",
"0.5155864",
"0.5155864",
"0.51552... | 0.64372444 | 0 |
Create event files, having milliseconds data of running train at every interval of one minute | def runEventCreation():
config = CONFIG['steps']['EventCreation']
ci = config['inputs']
co = config['outputs']
min_window_size = ci['min_window_size']
change_speed_by = ci['change_speed_by']
speed_ratio = ci['train_zero_speed_ratio']
datetime_limit = ci['datetime_limit']
csv_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\r\n # handle arguments\r\n parser = argparse.ArgumentParser()\r\n\r\n parser.add_argument('-t', '--time', help = 'start time', default = \"2018-12-26 18:11:08.509654\")\r\n parser.add_argument('-bd', '--min_duration', type = int, help = 'minimum duration', default = 25)\r\n parser.add_a... | [
"0.6032952",
"0.5831476",
"0.57964736",
"0.579341",
"0.56763124",
"0.5651286",
"0.55910707",
"0.5543689",
"0.550672",
"0.5505693",
"0.54488367",
"0.5447712",
"0.5447712",
"0.54450935",
"0.5443203",
"0.5438387",
"0.5438387",
"0.54381704",
"0.54252434",
"0.53706056",
"0.5366133... | 0.6412924 | 0 |
Compute an n x n Mandelbrot matrix with maxi maximum iterations. | def mandel_numpy(n=400,maxi=512):
# get 2-d arrays for x and y, using numpy's convenience function
xs, ys = N.meshgrid(N.linspace(x0,x1,n), N.linspace(y0,y1,n))
z = N.zeros((n,n),'complex128') # a matrix of complex zeros
c = xs + 1j*ys
escape = N.empty((n,n),'int32')
escape[:,:] = maxi ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_mandelbrot(self, iterations):\n if self.grid is None:\n raise RuntimeError(\"Grid hasn't been setup - call set_grid first.\")\n # Define the tensorflow variables\n c = tf.constant(self.grid.astype(np.complex64))\n z = tf.Variable(c)\n n = tf.Variable(tf.ze... | [
"0.6948238",
"0.6483979",
"0.647635",
"0.60975",
"0.577624",
"0.56804156",
"0.56472903",
"0.56135315",
"0.55913776",
"0.54975516",
"0.5475175",
"0.5427021",
"0.5401388",
"0.5397574",
"0.5332212",
"0.53113306",
"0.5310061",
"0.526007",
"0.52369773",
"0.5234702",
"0.5232932",
... | 0.6586663 | 1 |
Flattens each 2D detector layer into a 1D array | def flatten_layers(data):
return data.reshape((data.shape[0], data.shape[1], -1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_array(tiffs: list[np.ndarray], idx: int, shape: tuple[int, ...], dtype: type | np.dtype) -> np.ndarray:\n feature_arrays = (np.atleast_3d(img)[..., idx] for img in tiffs)\n return np.asarray(list(feature_arrays), dtype=dtype).reshape(*shape, 1)",
"def flattenImage(input_array):\r\n ... | [
"0.65512943",
"0.63869417",
"0.6224323",
"0.62073267",
"0.6146212",
"0.61214846",
"0.60448676",
"0.6012312",
"0.6004641",
"0.59888744",
"0.5885316",
"0.587274",
"0.58667505",
"0.58584476",
"0.5855942",
"0.58501977",
"0.58499795",
"0.5836353",
"0.5810114",
"0.57356036",
"0.572... | 0.6616059 | 0 |
Allow dumping the packed files to a folder. Returns a zipfile.write() method. | def get_zip_writer(zipfile: ZipFile):
dump_folder = CONF['packfile_dump', '']
if not dump_folder:
return zipfile.write
dump_folder = os.path.abspath(dump_folder)
# Delete files in the folder, but don't delete the folder itself.
try:
dump_files = os.listdir(dump_folder)
except F... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pack_file(zip_write, filename: str, suppress_error=False):\n if '\\t' in filename:\n # We want to rename the file!\n filename, arcname = filename.split('\\t')\n else:\n arcname = filename\n\n if filename[-1] == '*':\n # Pack a whole folder (blah/blah/*)\n directory =... | [
"0.7331823",
"0.7246399",
"0.70958483",
"0.7027812",
"0.6948637",
"0.6911189",
"0.68038255",
"0.6792268",
"0.6757164",
"0.6726353",
"0.6699952",
"0.6696708",
"0.66505677",
"0.6580177",
"0.65668654",
"0.65554553",
"0.65272367",
"0.6514948",
"0.650231",
"0.6482944",
"0.64609164... | 0.7529858 | 0 |
Generate a new game_sounds_manifest.txt file. This includes all the current scripts defined, plus any custom ones. Excludes is a list of scripts to remove from the listing this allows overriding the sounds without VPK overrides. | def gen_sound_manifest(additional, excludes):
if not additional:
return # Don't pack, there aren't any new sounds..
orig_manifest = os.path.join(
'..',
SOUND_MAN_FOLDER.get(CONF['game_id', ''], 'portal2'),
'scripts',
'game_sounds_manifest.txt',
)
try:
w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_sounds(names, path, base_label='Sound_'):\n\tfor filename, output in dump_sounds(names, base_label):\n\t\twith open(os.path.join(path, filename), 'w') as out:\n\t\t\tout.write(output)",
"def add_sounds(self) -> None:\n self.sounds.append(arcade.Sound(\"sounds/minecraft-theme.mp3\"))\n se... | [
"0.634194",
"0.6167628",
"0.6143036",
"0.574207",
"0.5583267",
"0.5577609",
"0.55683976",
"0.54692596",
"0.53306884",
"0.52429533",
"0.523025",
"0.5224628",
"0.5199384",
"0.5083675",
"0.50342655",
"0.49966714",
"0.49445674",
"0.48723647",
"0.48541355",
"0.48308998",
"0.48279"... | 0.82363987 | 0 |
Generate a new particle system manifest file. This includes all the current ones defined, plus any custom ones. | def gen_part_manifest(additional):
if not additional:
return # Don't pack, there aren't any new particles..
orig_manifest = os.path.join(
'..',
GAME_FOLDER.get(CONF['game_id', ''], 'portal2'),
'particles',
'particles_manifest.txt',
)
try:
with open(orig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_manifest(self):\n import time\n import sys\n with open('bake-manifest-' + time.strftime('%Y-%m-%d-%H:%M:%S') + \n '.txt', 'w') as hout:\n hout.write(' '.join(sys.argv) + '\\n')\n for k, v in self.table.items():\n hout.write(';'.join([k... | [
"0.62623477",
"0.61897093",
"0.61677384",
"0.60479397",
"0.58180106",
"0.5817169",
"0.5700848",
"0.56880516",
"0.5666152",
"0.56610906",
"0.55579436",
"0.554421",
"0.5497124",
"0.548652",
"0.5405297",
"0.5399095",
"0.538896",
"0.5375458",
"0.5372112",
"0.5355626",
"0.5350976"... | 0.7731379 | 0 |
Generate a soundscript file for music. | def generate_music_script(data: Property, pack_list):
# We also pack the filenames used for the tracks - that way funnel etc
# only get packed when needed. Stock sounds are in VPKS or in aperturetag/,
# we don't check there.
# The voice attrs used in the map - we can skip tracks
voice_attr = CONF['V... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_audio():\n text, lang = introduction()\n ses = boto3.Session(profile_name=\"default\")\n pol = ses.client(\"polly\")\n res = pol.synthesize_speech(Text=text, LanguageCode=lang, OutputFormat=\"mp3\", VoiceId=VOICE)\n return res",
"def make_a_sound(): # document string\n print('quack... | [
"0.69354683",
"0.69074094",
"0.6694641",
"0.6556796",
"0.6548967",
"0.6373594",
"0.6314922",
"0.62685734",
"0.62347925",
"0.61781305",
"0.614819",
"0.6109333",
"0.61045724",
"0.60798234",
"0.6031474",
"0.60156626",
"0.5977319",
"0.5961787",
"0.5923874",
"0.5900185",
"0.588932... | 0.7483942 | 0 |
Write either a single sound, or multiple rndsound. snd_prefix is the prefix for each filename , , @, etc. | def write_sound(file, snds: Property, pack_list, snd_prefix='*'):
if snds.has_children():
file.write('"rndwave"\n\t{\n')
for snd in snds:
file.write(
'\t"wave" "{sndchar}{file}"\n'.format(
file=snd.value.lstrip(SOUND_CHARS),
sndchar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_sounds(names, path, base_label='Sound_'):\n\tfor filename, output in dump_sounds(names, base_label):\n\t\twith open(os.path.join(path, filename), 'w') as out:\n\t\t\tout.write(output)",
"def write_wav(fname, samps, sampling_rate=16000, normalize=True):\n\t# for multi-channel, accept ndarray [Nsamples,... | [
"0.6428006",
"0.63598406",
"0.63356966",
"0.62533575",
"0.613192",
"0.6080928",
"0.6072929",
"0.60464036",
"0.60073996",
"0.6006992",
"0.6005394",
"0.59996164",
"0.5970193",
"0.5965686",
"0.59485584",
"0.59431666",
"0.59283555",
"0.59256744",
"0.59218687",
"0.5920869",
"0.589... | 0.8022576 | 0 |
Generate the names of files to inject, if they exist.. | def inject_files():
for filename, arcname in INJECT_FILES.items():
filename = os.path.join('bee2', 'inject', filename)
if os.path.exists(filename):
yield filename, arcname
# Additionally add files set in the config.
for prop in CONF.find_children('InjectFiles'):
filename... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processed_file_names(self):\n if self.force_reprocess == True:\n self.force_reprocess = False\n return 'reprocess.pt'\n \n ''' HR 01/06/22 Workaround to avoid FileNotFoundError '''\n print('self.processed_dir:', self.processed_dir)\n # folder,file = os.p... | [
"0.6215151",
"0.6173545",
"0.6165678",
"0.6132175",
"0.60765666",
"0.60045236",
"0.59673595",
"0.5943801",
"0.5906433",
"0.5898301",
"0.5871709",
"0.5870495",
"0.5845655",
"0.58379316",
"0.5836181",
"0.583417",
"0.58176804",
"0.58070236",
"0.57988113",
"0.5745292",
"0.5741855... | 0.6815235 | 0 |
Find candidate screenshots to overwrite. | def find_screenshots():
# Inside SCREENSHOT_DIR, there should be 1 folder with a
# random name which contains the user's puzzles. Just
# attempt to modify a screenshot in each of the directories
# in the folder.
for folder in os.listdir(SCREENSHOT_DIR):
full_path = os.path.join(SCREENSHOT_DI... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grab_heroes_pool_images(screenshot):\n\n #screenshot = WindowManager.preprocess_image(screenshot)\n return [screenshot.crop((509, 280, 820, 790)),\n screenshot.crop((820, 280, 1131, 790)),\n screenshot.crop((1131, 280, 1442, 790)),\n screenshot.crop((1... | [
"0.56268287",
"0.55836725",
"0.5466227",
"0.54593205",
"0.54427487",
"0.5429798",
"0.5360617",
"0.5355129",
"0.533144",
"0.52600294",
"0.52395785",
"0.516024",
"0.513637",
"0.5128769",
"0.51157874",
"0.5084877",
"0.50637954",
"0.5062044",
"0.50510454",
"0.5047947",
"0.5047658... | 0.66657865 | 0 |
Returns the UofT Graduate GPA for a given grade. | def grade_to_gpa(grade):
letter_grade = ""
gpa = 0.0
if type(grade) is str:
accepted_values = ["A+", "A", "A-", "B+", "B", "B-", "FZ"]
# check that the grade is one of the accepted values
if grade in accepted_values:
# assign grade to letter_grade
letter_grade... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_gpa(current_bucket_gpa):\r\n\r\n computed_grade = re.findall(r\"\\d+[.]?\\d*\", current_bucket_gpa)\r\n if len(computed_grade) > 0:\r\n computed_grade = computed_grade[0]\r\n if float(computed_grade) > 10:\r\n computed_grade = float(computed_grade[0]) / 10.0\r\n return... | [
"0.6791343",
"0.64294994",
"0.610843",
"0.59711015",
"0.593342",
"0.5807375",
"0.57462656",
"0.5738365",
"0.5735842",
"0.5732751",
"0.5731037",
"0.572275",
"0.5679913",
"0.56496114",
"0.5646817",
"0.5641173",
"0.5636095",
"0.5517465",
"0.5508186",
"0.5495881",
"0.5381232",
... | 0.6462246 | 1 |
Connect a datacenter to this endpoint. An endpoint can only be connected to a single datacenter. | def connect_datacenter(self, dc):
self.compute.dc = dc
for ep in self.openstack_endpoints.values():
ep.manage = self.manage
logging.info \
("Connected DC(%s) to API endpoint %s(%s:%d)" % (dc.label, self.__class__.__name__, self.ip, self.port)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_dc_network(self, dc_network):\n self.manage.net = dc_network\n self.compute.nets[self.manage.floating_network.id] = self.manage.floating_network\n logging.info(\"Connected DCNetwork to API endpoint %s(%s:%d)\" % (\n self.__class__.__name__, self.ip, self.port))",
"def ... | [
"0.68350774",
"0.59132737",
"0.5732963",
"0.57322764",
"0.57078254",
"0.5706639",
"0.5680314",
"0.5666111",
"0.5593733",
"0.5567479",
"0.5567184",
"0.55639863",
"0.55574876",
"0.55011344",
"0.5458151",
"0.54542726",
"0.54163355",
"0.540785",
"0.5394772",
"0.53901094",
"0.5384... | 0.7805443 | 0 |
Connect the datacenter network to the endpoint. | def connect_dc_network(self, dc_network):
self.manage.net = dc_network
self.compute.nets[self.manage.floating_network.id] = self.manage.floating_network
logging.info("Connected DCNetwork to API endpoint %s(%s:%d)" % (
self.__class__.__name__, self.ip, self.port)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_datacenter(self, dc):\n self.compute.dc = dc\n for ep in self.openstack_endpoints.values():\n ep.manage = self.manage\n logging.info \\\n (\"Connected DC(%s) to API endpoint %s(%s:%d)\" % (dc.label, self.__class__.__name__, self.ip, self.port))",
"def connec... | [
"0.75026584",
"0.6867479",
"0.64917773",
"0.6375236",
"0.6371488",
"0.62445194",
"0.62019926",
"0.61340374",
"0.6125503",
"0.61206913",
"0.6095818",
"0.60791093",
"0.606961",
"0.6069137",
"0.60621864",
"0.6056231",
"0.6043292",
"0.6030431",
"0.6009846",
"0.6002214",
"0.600133... | 0.75623393 | 0 |
Start all connected OpenStack endpoints that are connected to this API endpoint. | def start(self, wait_for_port=False):
for c in self.openstack_endpoints.values():
c.compute = self.compute
c.manage = self.manage
c.server_thread = threading.Thread(target=c._start_flask, args=())
c.server_thread.daemon = True
c.server_thread.name = c.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def start_all(self):\n try:\n for service in self.services:\n try:\n await service.start()\n await service.healthcheck()\n except Exception as e:\n log.exception(\"Exception while starting %s service\", s... | [
"0.6081534",
"0.60684043",
"0.59456795",
"0.5857773",
"0.58120763",
"0.5776767",
"0.57513654",
"0.56928366",
"0.5676735",
"0.56644404",
"0.563852",
"0.5633027",
"0.5626252",
"0.5604621",
"0.5600612",
"0.559889",
"0.5575616",
"0.5568452",
"0.55555224",
"0.5530493",
"0.55136335... | 0.6768158 | 0 |
Stop all connected OpenStack endpoints that are connected to this API endpoint. | def stop(self):
for c in self.openstack_endpoints.values():
c.stop()
#for c in self.openstack_endpoints.values():
# if c.server_thread:
# print("Waiting for WSGIServers to be stopped ...")
# c.server_thread.join() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shutdown_all_endpoints(self):\n logger.debug('Removing all endpoints')\n endpoints = []\n with self._endpoint_lock:\n endpoints = list(self._endpoints)\n # be sure we're not holding the lock when shutdown calls\n # _remove_endpoint.\n for e in endpoints:\n ... | [
"0.7218453",
"0.71554255",
"0.6913532",
"0.6757825",
"0.6647372",
"0.6572691",
"0.6498089",
"0.64354163",
"0.6427609",
"0.6418356",
"0.63848424",
"0.63806695",
"0.635318",
"0.63259894",
"0.6320032",
"0.63064104",
"0.62986004",
"0.6274114",
"0.622263",
"0.6214541",
"0.6208437"... | 0.7770021 | 0 |
Download and generate Alexia top 1 million url lists | def get_alexia_urls():
#download top 1 million site urls
zip_top_urls = requests.get(ALEXIA_URL)
response_buf = StringIO.StringIO(zip_top_urls.content)
# unzip contents
zfile = zipfile.ZipFile(response_buf)
buf = StringIO.StringIO(zfile.read('top-1m.csv'))
for line in buf.readlines():
(rank,domain) = line.spl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_50(url):\n\n results = requests.get(url,headers = headers).json()\n return results",
"def main(url):\n \n words = fetch_words(url)\n print_items(words)",
"def _fetch_large():\n # Large training data:\n resource(\n target=data_path(\"eeg\", \"SMNI_CMI_TRAIN.tar.gz\"),\n ur... | [
"0.6438779",
"0.6052566",
"0.600989",
"0.5963049",
"0.59457004",
"0.59386194",
"0.5916427",
"0.59098995",
"0.5860502",
"0.5847924",
"0.57740724",
"0.5756279",
"0.575132",
"0.5734446",
"0.5716643",
"0.56921947",
"0.5688688",
"0.56574255",
"0.56539947",
"0.5652997",
"0.5643443"... | 0.7255304 | 0 |
Format new sequence so it matches the type of the original sequence. | def format_seq(seq, new_seq):
if type(seq) == str:
return "".join(new_seq)
elif type(seq) == tuple:
return tuple(new_seq)
else:
return new_seq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asformat(self, format):",
"def test_sequence_to_moltype(self):\n s = Sequence(\"TTTTTTTTTTAAAA\", name=\"test1\")\n annot1 = s.add_annotation(Feature, \"exon\", \"fred\", [(0, 10)])\n annot2 = s.add_annotation(Feature, \"exon\", \"trev\", [(10, 14)])\n got = s.to_moltype(\"rna\")\... | [
"0.5782192",
"0.57681745",
"0.56224316",
"0.5617714",
"0.5553125",
"0.55416995",
"0.5499011",
"0.5464796",
"0.5445919",
"0.54286814",
"0.5403455",
"0.5346777",
"0.5314133",
"0.5298421",
"0.52948034",
"0.52948034",
"0.52077514",
"0.5198649",
"0.5171699",
"0.51702905",
"0.51660... | 0.73359036 | 0 |
Return sequence with every other item removed. | def remove_every_other(seq):
# Make a copy of the original sequence and step by 2
new_seq = seq[::2]
return new_seq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_every_other_item(seq):\n seq_copy = seq [0::2]\n return seq_copy",
"def remove_every_other(seq):\n length = len(seq)\n new_seq = seq[0:length:2]\n return new_seq",
"def remove_four_and_every_other(seq):\n # Make a copy of the original sequence, but omit the first four and last four... | [
"0.814443",
"0.7579058",
"0.65186775",
"0.64783514",
"0.6305853",
"0.61302996",
"0.6013019",
"0.59792227",
"0.5977844",
"0.5863139",
"0.58459187",
"0.58252424",
"0.5821521",
"0.565928",
"0.565343",
"0.5642883",
"0.5621129",
"0.55982196",
"0.55754906",
"0.55539966",
"0.5539476... | 0.7961374 | 1 |
Return sequence with the first four and last four items removed, plus every other item in the remaining sequence. | def remove_four_and_every_other(seq):
# Make a copy of the original sequence, but omit the first four and last four elements
new_seq = seq[4:-4]
# Make a copy of new sequence and step by 2
new_seq = new_seq[::2]
return new_seq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_4s_every_other_in_between(seq):\n seq_copy = seq [4:-4:2]\n return seq_copy",
"def fours_removed(seq):\n length = len(seq) - 4\n new_seq = seq[4:length:2]\n return new_seq",
"def remove_every_other_item(seq):\n seq_copy = seq [0::2]\n return seq_copy",
"def remove_every_other(... | [
"0.7949985",
"0.72331405",
"0.6958973",
"0.66397864",
"0.6586896",
"0.65185237",
"0.61443645",
"0.5820111",
"0.5701834",
"0.5620001",
"0.5594261",
"0.55820346",
"0.5514332",
"0.5510886",
"0.54914135",
"0.54914135",
"0.54914135",
"0.545188",
"0.5427004",
"0.5376906",
"0.533284... | 0.8401329 | 0 |
Return a sequence with the last third, then first third, then middle third in the new order. | def last_first_middle_third(seq):
# Using the length of the sequence, figure out roughly what one third should be
one_third = len(seq) // 3
new_seq = list(seq[-one_third:])
new_seq.extend(seq[:-one_third])
return format_seq(seq, new_seq) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def third_reorder(seq):\n third = len(seq)//3\n return seq[third:-third]+seq[-third:]+seq[:third]",
"def replace_thirds(seq):\n third = int(len(seq)/3)\n middle_third = seq[third:-third]\n last_third = seq[-third:]\n first_third = seq[0:third]\n seq_copy = middle_third + last_third + first_t... | [
"0.84744817",
"0.7467445",
"0.7467445",
"0.7054174",
"0.7008001",
"0.6548605",
"0.6217295",
"0.6016097",
"0.58688897",
"0.5803951",
"0.57408905",
"0.57041776",
"0.565916",
"0.565916",
"0.56146777",
"0.5578442",
"0.55430853",
"0.55274",
"0.549154",
"0.5474041",
"0.5442637",
... | 0.7918163 | 1 |
Given the zenith PWV (reported by APEX) and altitude of source, returns the real amount of water between the telescope and space. Basically returns pwv/cos(zenith_angle) | def get_real_pwv(pwv, altitude):
zenith_angle = 90-altitude
airmass = 1/np.cos(zenith_angle*np.pi/180)
return pwv*airmass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def VaporPressure(dwpt):\n\n return 611.2*exp(17.67*dwpt/(243.5+dwpt))",
"def pressure(altitude):\n t = temperature(altitude) # R\n if altitude <= 36152:\n p = 2116*(t/518.6)**5.256 # psf\n else:\n p = 473.1*exp(1.73-0.000048*altitude) # psf\n return p",
"def water_vapour(t):\n ... | [
"0.6731954",
"0.6352121",
"0.6210927",
"0.6185982",
"0.6112099",
"0.6091341",
"0.60461605",
"0.60024655",
"0.5860308",
"0.5859313",
"0.5838366",
"0.5835615",
"0.58182067",
"0.57965446",
"0.575435",
"0.5737927",
"0.5728905",
"0.5710867",
"0.57060504",
"0.57017237",
"0.5690225"... | 0.7299661 | 0 |
Insert a Follower into the database | def fillFollowerInDB(self):
sqlInsertFollowers = "INSERT INTO follower screen_name VALUES %s"
mycursor.execute(sqlInsertFollowers,self.screen_name)
mydb.commit() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def followUser(following):\n\n cur, user_id, con = initialise(3, True)\n cur.execute(\"INSERT INTO followers (user, following) VALUES ((SELECT username FROM users WHERE id = ?), ?)\", (user_id, following))\n finish(con)",
"def follow(self, followerId: int, followeeId: int) -> None:\n if followeeI... | [
"0.78603786",
"0.6736899",
"0.6574572",
"0.6521408",
"0.6442153",
"0.6402648",
"0.6336011",
"0.6331151",
"0.6322974",
"0.6309035",
"0.63037306",
"0.6298957",
"0.62458616",
"0.62110263",
"0.6175521",
"0.61738724",
"0.6148766",
"0.6145518",
"0.61096025",
"0.6083749",
"0.6081882... | 0.76846194 | 1 |
Calculate the total loss on a single tower running the CIFAR model. | def tower_loss(scope):
# Get images and flows for Flownet.
img1, img2, flo = flownet_input.inputs(False, FLAGS.data_dir, FLAGS.batch_size)
# Build a Graph that computes predictions from the inference model.
logits = flowNet.inference(img1, img2, FLAGS.batch_size)
# Add to the Graph the Ops for loss calculation... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss_total(self):\r\n def loss(y_true, y_pred):\r\n l2 = 1/2*K.sum(K.square(y_true-y_pred))\r\n\r\n return l2\r\n return loss",
"def compute_loss(self):",
"def loss_total(self, mask):\n\n def loss(y_true, y_pred):\n\n # Compute predicted image with non-... | [
"0.6700091",
"0.6494981",
"0.64351314",
"0.6419666",
"0.6419666",
"0.635259",
"0.634228",
"0.6337857",
"0.6266046",
"0.61995566",
"0.61981475",
"0.61751956",
"0.61435133",
"0.6103842",
"0.6090877",
"0.60856736",
"0.6064605",
"0.60511935",
"0.60422295",
"0.6033311",
"0.6024074... | 0.67803407 | 0 |
Random Subdomain attack packet builder | def randomSubBuilder(dom: string, src_ip: string, dst_ip: string, src_port: int, t: float, seed: float):
id_IP = int(RandShort()) #id for IP layer
id_DNS = int(RandShort()) #id for DNS layer
sub = randomSub(seed) #Random subdomain
q_name = sub + '.' + dom #Complete domain request
ans = Ether(src= '1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_domainname():\n domainname = ''.join(generate_string(10, valid_domain_name_chars))\n domain = random.choice(['com', 'co.il', 'info'])\n return domainname+'.'+domain",
"def generateBaseDRQ(self, domain):\n if not DB.isValidTarget(domain):\n Error.printErrorAndExit(domain + ... | [
"0.5977173",
"0.59681684",
"0.57653284",
"0.57206655",
"0.5675084",
"0.5635172",
"0.54800284",
"0.54657984",
"0.5421064",
"0.53999",
"0.53358173",
"0.532985",
"0.53167856",
"0.5308277",
"0.52976847",
"0.5266126",
"0.5246301",
"0.52280766",
"0.52115506",
"0.5182972",
"0.516677... | 0.71283317 | 0 |
Gives an array of arguments to create packets | def argsBuilder(target_dom:string, server_ip: string, domain_ip:string, server_dom_ip:string, ti:float, d:int, packets:int, n_bot:int):
tf = ti + d #End time of the attack
new_packets_args = []
if n_bot == 1: #If dos attack
ips = randomIP(n_bot, Time.time(), False)
else: #If ddos attack
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_args(port, n, t, population, test=None, value=0, failure=None, tx_rate=0, loglevel=logging.INFO, output=None,\n broadcast=True, fan_out=10, profile=None, validate=False, ignore_promoter=False):\n res = [str(port), str(n), str(t), str(population)]\n\n if test is not None:\n res.ap... | [
"0.6156209",
"0.5899861",
"0.5849596",
"0.58321226",
"0.5789751",
"0.5764216",
"0.57535285",
"0.57535285",
"0.57303244",
"0.5728946",
"0.5726997",
"0.5719696",
"0.56849927",
"0.5654152",
"0.5565254",
"0.55376214",
"0.55330455",
"0.5521985",
"0.5521701",
"0.5485274",
"0.542656... | 0.62451375 | 0 |
Start the stopwatch if it is not running; stop it if it is running. | def start_stop( self ):
if self.stop_event.is_set():
# Stopwatch was stopped, so start it.
self.stop_event.clear()
self.timer_thread = Thread( target=self.run_stopwatch, args=( time(), ) )
self.timer_thread.start()
else:
# Stopwatch was ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_stopwatch( self, start_time ):\r\n self.start_time = start_time\r\n while not self.stop_event.is_set():\r\n sleep( 0.01 ) # Accurate to about 1/100th of a second.\r\n self.gui.time_label.setText( \"{:.2f}\".format( time() - self.start_time ) )",
"def start(self):\n ... | [
"0.7138144",
"0.7008591",
"0.67390275",
"0.66714877",
"0.66500926",
"0.6405324",
"0.6306759",
"0.626701",
"0.619082",
"0.6111843",
"0.60280937",
"0.60244936",
"0.59438825",
"0.59425366",
"0.5927466",
"0.59179336",
"0.5896777",
"0.5890608",
"0.58734024",
"0.5858474",
"0.585765... | 0.8451777 | 0 |
Runs a stopwatch loop showing the time elapsed at regular intervals. | def run_stopwatch( self, start_time ):
self.start_time = start_time
while not self.stop_event.is_set():
sleep( 0.01 ) # Accurate to about 1/100th of a second.
self.gui.time_label.setText( "{:.2f}".format( time() - self.start_time ) ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timer():\n start = time.time()\n\n yield\n\n end = time.time()\n\n print('Elapsed: {:.2f}s'.format(end - start))",
"def run(self):\n last_time = time.time()\n while self.running:\n now_time = time.time()\n interval = now_time - last_time\n last_time ... | [
"0.67962104",
"0.6714543",
"0.6504831",
"0.64995676",
"0.6336717",
"0.6330287",
"0.6256835",
"0.62167007",
"0.6187998",
"0.6170958",
"0.6117941",
"0.607546",
"0.60544944",
"0.6039015",
"0.60389596",
"0.6019436",
"0.6006544",
"0.5976301",
"0.5935193",
"0.5933771",
"0.59141564"... | 0.70103276 | 0 |
return True if |val| is an instance of list, False otherwise | def _is_list(val):
return isinstance(val, list) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_list(value):\n return isinstance(value, list)",
"def is_list(value):\n return isinstance(value, list) or None",
"def _is_list(item):\n return isinstance(item, list)",
"def is_list(obj):\n return type(obj) is list",
"def is_list ( self, s ):\r\n\t\treturn isinstance ( s, type( list () ) )... | [
"0.81332123",
"0.7750742",
"0.767848",
"0.7669833",
"0.76221544",
"0.7603478",
"0.75646144",
"0.7458807",
"0.7454284",
"0.7441061",
"0.7392627",
"0.73333895",
"0.7226106",
"0.7216461",
"0.7105663",
"0.70489925",
"0.7037061",
"0.7035671",
"0.7025254",
"0.6976099",
"0.6933247",... | 0.89659095 | 0 |
return True if |val| is an instance of dict, False otherwise | def _is_dict(val):
return isinstance(val, dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isdict(val: Any) -> bool:\n return isinstance(val, MutableMapping)",
"def is_dict(value):\n return isinstance(value, dict)",
"def isdictinstance(obj):\n return isinstance(obj, dict) or isinstance(obj, DotDict)",
"def is_dict(obj):\n return type(obj) == type({})",
"def _is_dict(item):\n r... | [
"0.81098014",
"0.7984968",
"0.78048414",
"0.7678112",
"0.7643852",
"0.7478924",
"0.7321905",
"0.7204761",
"0.71674895",
"0.6830731",
"0.68238515",
"0.6810352",
"0.67759424",
"0.66980416",
"0.6552115",
"0.65379673",
"0.6410042",
"0.63863635",
"0.6381625",
"0.6375066",
"0.63157... | 0.8864714 | 0 |
return True if |wildcard| string matches |s| string. A valid wildcard | def _is_wildcard_match(s, wildcard):
wildcard = wildcard.strip()
glob_pat = re.compile(r'\*(:(?P<type>\w+))?$')
m = glob_pat.match(wildcard)
if m:
if m.group('type'):
type_to_meth = globals()['__builtins__']
type_to_meth = {k:v for k,v in type_to_meth.items()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __reWildcard(self, regexp, string):\n regexp = re.sub(\"\\*+\", \"*\", regexp)\n match = True\n if regexp.count(\"*\") == 0:\n if regexp == string:\n return True\n else:\n return False\n blocks = regexp.split(\"*\")\n start ... | [
"0.715021",
"0.67261773",
"0.6713398",
"0.6707344",
"0.6571823",
"0.6482795",
"0.6318864",
"0.6266622",
"0.623342",
"0.6226286",
"0.6225357",
"0.61540484",
"0.61485624",
"0.6146087",
"0.61196405",
"0.59138566",
"0.59130514",
"0.5899484",
"0.58328605",
"0.5817263",
"0.5811018"... | 0.76775545 | 0 |
return True if regex pattern string |pat| matches string |s|. A valid | def _is_regex_match(s, pat):
pat = pat.rstrip()
m = re.search(Settings._REPAT, pat)
if m:
flags_combined = 0
if m.group('flag'):
char_to_flag = {
'A':re.A, 'I':re.I, 'L':re.L, 'M':re.M, 'S':re.S, 'X':re.X}
for flag in list(m.group('flag')):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isMatch(self, s: str, p: str) -> bool:\n def is_match(self, text, pattern):\n if not pattern:\n return not text\n\n first_match = bool(text) and pattern[0] in {text[0], '.'}\n\n if len(pattern) >= 2 and pattern[1] == '*':\n return (self.isMa... | [
"0.70966935",
"0.70157164",
"0.6960576",
"0.6815772",
"0.6807737",
"0.67286736",
"0.6649333",
"0.6632213",
"0.6626841",
"0.65312064",
"0.652153",
"0.65018463",
"0.6370927",
"0.63706475",
"0.63171095",
"0.6270721",
"0.6270025",
"0.6266336",
"0.6263732",
"0.6250111",
"0.6238221... | 0.8187956 | 0 |
return True if |v| is in |valid_v|. |v| should be a primitive of either int, float, str, or bool. |valid_v| should be a list of any possible legal primitive, wildcard, or regex values. |valid_v| can also be a single primitive value, which will implicitly be converted to a list containing one element. Return False other... | def _is_in_prim(v, valid_v):
if not isinstance(valid_v, list):
valid_v = [valid_v]
for pat in valid_v:
if isinstance(pat, str):
if '*' in pat:
if Settings._is_wildcard_match(v, pat):
return True
elif re.search(Settings._REPAT, pat)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has(self, v):\n return v in self.values",
"def _primitive_validity_check(v, valid_v):\n\n if not Settings._is_in_prim(v, valid_v):\n raise InvalidSettingError()",
"def is_valid_value(self, value):\n return value in self.values",
"def _is_in_list(l, valid_l):\n\n for elem i... | [
"0.65102774",
"0.65090954",
"0.62292314",
"0.62203526",
"0.62055993",
"0.6187271",
"0.60626274",
"0.5736672",
"0.5600317",
"0.55947465",
"0.55650556",
"0.55649483",
"0.5529547",
"0.55027205",
"0.54704666",
"0.54414445",
"0.5438185",
"0.54267836",
"0.54200864",
"0.5377313",
"0... | 0.7078393 | 0 |
return True if every element in list |sublist| is in one of the lists contained in |lists|, False otherwise. Legal elements in |sublist| or the lists in |lists| are any primitive (int, float, str, bool), list, or dict. If an illegal element exists in |sublist|, an InvalidSettingError is raised | def _is_sublist_in_one_of_lists(sublist, lists):
type_to_one_of = Settings._get_type_to_one_of()
for vl in lists:
next_vl = False
for e in sublist:
if Settings._is_primitive(e):
t = 'primitive'
elif Settings._is_list(e):
vl = [l for l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sublist_in(lst, sublst):\n for i in sublst:\n if i not in lst:\n return False\n return True",
"def contains(base, sub_list):\n\n return set(base) & set(sub_list) == set(sub_list)",
"def _is_in_list(l, valid_l):\n\n for elem in l:\n if Settings._is_pri... | [
"0.7168912",
"0.6911516",
"0.689753",
"0.6571266",
"0.6512159",
"0.6431463",
"0.64059114",
"0.63500553",
"0.6314237",
"0.6075374",
"0.6047245",
"0.59738773",
"0.5970836",
"0.5957095",
"0.5953869",
"0.59509546",
"0.58234435",
"0.57280076",
"0.5707694",
"0.5649077",
"0.56412464... | 0.8294943 | 0 |
return True if dict |d| is in one of the dicts in |dicts|, False otherwise. |dicts| is obviously just a list of dictionaries. Legal elements in the dictionaries are the typical primitives (int, float, bool, str), lists, and dicts. | def _is_dict_in_one_of_dicts(d, dicts):
for vd in dicts:
if Settings._is_in_dict(d, vd):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_in_dict(d, valid_d):\n\n for k, v in d.items():\n if k not in valid_d:\n return False\n else:\n if Settings._is_primitive(v):\n if not Settings._is_in_prim(v, valid_d[k]):\n return False\n elif Settings._is_list(v):\n ... | [
"0.64084905",
"0.60281664",
"0.5984001",
"0.5980985",
"0.59457546",
"0.5872692",
"0.57876366",
"0.57641065",
"0.5747921",
"0.57217395",
"0.5614708",
"0.5484641",
"0.54599655",
"0.53625906",
"0.5358206",
"0.5351264",
"0.533104",
"0.53166837",
"0.5306886",
"0.5287404",
"0.52817... | 0.8241347 | 0 |
return True if all elements in list |l| is in one of the lists contained in |valid_l|, False otherwise. Legal elements in the lists are the typical primitives (int, float, bool, str), lists, and dicts. | def _is_in_list(l, valid_l):
for elem in l:
if Settings._is_primitive(elem):
if not Settings._is_in_prim(elem, valid_l):
return False
elif Settings._is_list(elem):
valid_lists = [l for l in valid_l if isinstance(l, list)]
if not Settings._is_su... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _list_validity_check(l, valid_l):\n\n if not Settings._is_in_list(l, valid_l):\n raise InvalidSettingError()",
"def allIn(listA: Union[int, List[int]], listB: Union[int, List[int]]) -> bool:\n if isinstance(listA, int):\n listA = [listA]\n if isinstance(listB, int):\n ... | [
"0.7000915",
"0.6149883",
"0.61312413",
"0.6082698",
"0.59904224",
"0.5970148",
"0.5934717",
"0.5885762",
"0.5882798",
"0.5851436",
"0.5785513",
"0.5773051",
"0.57016706",
"0.5689442",
"0.56725544",
"0.5652237",
"0.5626126",
"0.56227636",
"0.5618623",
"0.56080157",
"0.5601694... | 0.7949676 | 0 |
return True if dict |d| has all keys in dict |valid_d|. False otherwise. | def _has_all_keys_from(d, valid_d):
for k, v in valid_d.items():
if k not in d:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_in_dict(d, valid_d):\n\n for k, v in d.items():\n if k not in valid_d:\n return False\n else:\n if Settings._is_primitive(v):\n if not Settings._is_in_prim(v, valid_d[k]):\n return False\n elif Settings._is_list(v):\n ... | [
"0.7827297",
"0.680757",
"0.66193026",
"0.6566625",
"0.6357033",
"0.62774754",
"0.6261642",
"0.6259637",
"0.6217635",
"0.62153924",
"0.6203975",
"0.6185486",
"0.6110884",
"0.6004363",
"0.5946864",
"0.58883274",
"0.57816666",
"0.5731112",
"0.5690174",
"0.56880385",
"0.56877536... | 0.87729234 | 0 |
return True if all dict |d| keys are in dict |valid_d|, values in |d| are legal values with respect to the valid values defined in |valid_d|, and all |valid_d| keys are in |d|. Values in |d| are determined legal based on Settings._is_in_prim(), Settings._is_list(), or recursively Settings._is_in_dict(). False otherwise... | def _is_in_dict(d, valid_d):
for k, v in d.items():
if k not in valid_d:
return False
else:
if Settings._is_primitive(v):
if not Settings._is_in_prim(v, valid_d[k]):
return False
elif Settings._is_list(v):
if no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dict_validity_check(d, valid_d):\n\n if not Settings._is_in_dict(d, valid_d):\n raise InvalidSettingError()",
"def _has_all_keys_from(d, valid_d):\n\n for k, v in valid_d.items():\n if k not in d:\n return False\n return True",
"def _is_dict_in_one_of_dicts(d, dic... | [
"0.80089605",
"0.79015756",
"0.68252265",
"0.66869044",
"0.6565693",
"0.6309288",
"0.6258104",
"0.60240465",
"0.5989314",
"0.5946436",
"0.5847185",
"0.577302",
"0.57671636",
"0.56919193",
"0.56556475",
"0.56521857",
"0.56458354",
"0.5585945",
"0.5582982",
"0.55797684",
"0.557... | 0.87256515 | 0 |
raise InvalidSettingError if primitive (int, float, bool, str) value |v| is not in list |valid_v| | def _primitive_validity_check(v, valid_v):
if not Settings._is_in_prim(v, valid_v):
raise InvalidSettingError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _list_validity_check(l, valid_l):\n\n if not Settings._is_in_list(l, valid_l):\n raise InvalidSettingError()",
"def _validate_value(self, val):\r\n if type(val) in (int, long, float, str, unicode, ):\r\n return val\r\n if isinstance(val, tuple) or isinstance(val, frozens... | [
"0.6487991",
"0.62959874",
"0.6258109",
"0.6215541",
"0.618264",
"0.61013937",
"0.6074505",
"0.60655147",
"0.60485035",
"0.6044406",
"0.6028974",
"0.6027474",
"0.6026257",
"0.60188854",
"0.59915787",
"0.59838104",
"0.59746593",
"0.59627825",
"0.5954613",
"0.5924983",
"0.59240... | 0.82608044 | 0 |
raise InvalidSettingError if list |l| is not in list |valid_l| where \"in\" semantics are aligned with Settings._is_in_list(), so see the doc for that | def _list_validity_check(l, valid_l):
if not Settings._is_in_list(l, valid_l):
raise InvalidSettingError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_in_list(l, valid_l):\n\n for elem in l:\n if Settings._is_primitive(elem):\n if not Settings._is_in_prim(elem, valid_l):\n return False\n elif Settings._is_list(elem):\n valid_lists = [l for l in valid_l if isinstance(l, list)]\n if not Se... | [
"0.719088",
"0.62734437",
"0.6226575",
"0.587397",
"0.58457685",
"0.57075506",
"0.56937474",
"0.5466414",
"0.5451235",
"0.5410411",
"0.54094964",
"0.54041463",
"0.5403871",
"0.53722614",
"0.5351291",
"0.5345841",
"0.5297422",
"0.5291149",
"0.52697456",
"0.5263931",
"0.5228808... | 0.87735647 | 0 |
raise InvalidSettingError if dict |d| is not in dict |valid_d| where \"in\" semantics are aligned with Settings._is_in_dict(), so see the doc for that | def _dict_validity_check(d, valid_d):
if not Settings._is_in_dict(d, valid_d):
raise InvalidSettingError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_in_dict(d, valid_d):\n\n for k, v in d.items():\n if k not in valid_d:\n return False\n else:\n if Settings._is_primitive(v):\n if not Settings._is_in_prim(v, valid_d[k]):\n return False\n elif Settings._is_list(v):\n ... | [
"0.7488277",
"0.6641955",
"0.6196617",
"0.59063935",
"0.5877175",
"0.57327497",
"0.57189006",
"0.5654708",
"0.5553554",
"0.53341234",
"0.5283865",
"0.5279843",
"0.5265277",
"0.5223105",
"0.52217144",
"0.5210006",
"0.5198275",
"0.51907164",
"0.5188572",
"0.51837295",
"0.517812... | 0.86825794 | 0 |
error check |settings| and |valid|. Both are dict types. |settings| represents the user settings where each pair is a setting name associated to a chosen setting value. |valid| represents all valid user settings where each pair is a setting name associated to legal valid setting values. | def _validity_check(settings, valid):
Settings._dict_validity_check(settings, valid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_settings(self, settings):\n pass",
"def validate_settings(_cfg, _ctx):\n pass",
"def _dict_validity_check(d, valid_d):\n\n if not Settings._is_in_dict(d, valid_d):\n raise InvalidSettingError()",
"def check_settings_syntax(settings_dict: dict, settings_metadata_dict: dict):\... | [
"0.76656973",
"0.68101305",
"0.6712639",
"0.6699112",
"0.6521201",
"0.6304268",
"0.62737554",
"0.62068",
"0.611062",
"0.5977708",
"0.595072",
"0.5796342",
"0.5790598",
"0.57904774",
"0.5786704",
"0.5760153",
"0.5697195",
"0.5671662",
"0.56589305",
"0.5599054",
"0.5580645",
... | 0.814493 | 0 |
inject any defaults specified in |defaults| into settings. Default values will only be applied if a key exists in |defaults| and doesn't exist in |settings|, or if a key in |settings| has an associating value of None. If |defaults| is None, |settings| is returned as is. | def _inject_defaults(settings, defaults):
new_settings = {}
if defaults is None:
return settings
elif settings is None or len(settings) == 0:
new_settings = defaults
else:
for k, v in settings.items():
if isinstance(v, dict) or v is None:
ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults(self, settings_dict=None, **settings):\n settings_dict = settings_dict or {}\n settings_dict.update(settings)\n return self.set_values(settings_dict, override=False)",
"def loadDefaults(self,defaults):\n for key in defaults.keys():\n if key not in self.data... | [
"0.65865844",
"0.64090306",
"0.6406142",
"0.6250104",
"0.62078786",
"0.61736166",
"0.61570066",
"0.61391175",
"0.6111803",
"0.6052231",
"0.60497946",
"0.60248345",
"0.6000381",
"0.5997895",
"0.5956305",
"0.5923101",
"0.5910845",
"0.5898228",
"0.5872198",
"0.58597386",
"0.5825... | 0.85035056 | 0 |
create a Settings object. |settings| can be a dict or path to json file. If a dict, then values in |settings| must be a primitive (int, float, bool, str), list, or dict. |valid| must be a dict. |settings| represents the user settings where each pair is a setting name associated to a chosen setting value. |valid| repres... | def __init__(self, settings, valid, defaults=None):
try:
with open(settings, 'r') as settings_file:
self._settings = json.load(settings_file)
except TypeError:
self._settings = dict(settings)
self._settings = Settings._inject_defaults(self._settings, defaults)
Sett... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validity_check(settings, valid):\n\n Settings._dict_validity_check(settings, valid)",
"def _read_settings_file(cls, settings_path=''):\n if not settings_path:\n return {}\n\n if os.path.isdir(settings_path):\n settings_path = os.path.join(settings_path, '.' + cls.__n... | [
"0.6769524",
"0.6685451",
"0.65674096",
"0.652653",
"0.6333047",
"0.62696064",
"0.6178105",
"0.6040261",
"0.59549224",
"0.591162",
"0.58818275",
"0.58598006",
"0.5854006",
"0.5809394",
"0.5806272",
"0.57916164",
"0.5766842",
"0.57582766",
"0.5749986",
"0.5732465",
"0.5693892"... | 0.7713784 | 0 |
return the number of settings | def __len__(self):
return len(self._settings) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_sections(self):\n #print (len(self.config.sections()))\n return len(self.config.sections())",
"def count(cls, client) :\n\t\ttry :\n\t\t\tobj = appfwlearningsettings()\n\t\t\toption_ = options()\n\t\t\toption_.count = True\n\t\t\tresponse = obj.get_resources(client, option_)\n\t\t\tif... | [
"0.73933834",
"0.73484594",
"0.7338341",
"0.7232637",
"0.69817024",
"0.6793652",
"0.6730186",
"0.66864556",
"0.6681215",
"0.66763896",
"0.66130507",
"0.6599068",
"0.65807015",
"0.65699047",
"0.65699047",
"0.65607816",
"0.6549674",
"0.65447354",
"0.651406",
"0.6512395",
"0.650... | 0.76182985 | 0 |
Push a single ElasticSearchObject to index. Assumes objects do NOT have an id. | def push(self, es_obj, doc_type=None, refresh=True):
doc_type, es_repr = self._validate_doc_and_get_type_and_repr(es_obj, doc_type)
response = self.conn.elastic_search_client.index(index=self.index_name, doc_type=doc_type,
body=es_repr, refresh=u'true' if refre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_object(self, content, object_id = None):\n if object_id is None:\n return AlgoliaUtils_request(self.client.headers, self.write_hosts, \"POST\", \"/1/indexes/%s\" % self.url_index_name, self.client.timeout, content)\n else:\n return AlgoliaUtils_request(self.client.header... | [
"0.70250475",
"0.66799045",
"0.6536268",
"0.6320226",
"0.62905204",
"0.6278442",
"0.6247867",
"0.62353545",
"0.6212382",
"0.6159699",
"0.60891485",
"0.60850763",
"0.6084126",
"0.6069489",
"0.6048055",
"0.601098",
"0.601018",
"0.59969294",
"0.59266204",
"0.5904166",
"0.5878974... | 0.72160566 | 0 |
Returns the text of a child node found by name. Only one such named child is expected. | def getSingleChildTextByName(rootNode, name):
try:
nodeList = [e.firstChild.data for e in rootNode.childNodes if e.localName == name]
if len(nodeList) > 0:
return nodeList[0]
else:
return None
except AttributeError:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_child(self, name):\n for n in self.children:\n if n.name == name:\n return n\n\n raise ChildError(\"Can't find child node '{name}'\".format(**locals()))",
"def get_child(node, name):\r\n for child in node.childNodes:\r\n if child.localName == name:\r\n ... | [
"0.73368084",
"0.727436",
"0.709972",
"0.69880795",
"0.6772942",
"0.66547203",
"0.6558581",
"0.6543391",
"0.63135356",
"0.6266445",
"0.61968386",
"0.6183661",
"0.6125282",
"0.610355",
"0.6097007",
"0.60358995",
"0.6027794",
"0.6010082",
"0.5985832",
"0.5980697",
"0.5976921",
... | 0.7597116 | 0 |
Returns the text of a child node found by name and namespaceURI. Only one such named child is expected. | def getSingleChildTextByNameNS(rootNode, ns, name):
try:
nodeList = [e.firstChild.data for e in rootNode.childNodes if e.localName == name and e.namespaceURI == ns]
if len(nodeList) > 0:
return nodeList[0]
else:
return None
except AttributeError:
return No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_child(node, name):\r\n for child in node.childNodes:\r\n if child.localName == name:\r\n return child",
"def getSingleChildTextByName(rootNode, name):\n try:\n nodeList = [e.firstChild.data for e in rootNode.childNodes if e.localName == name]\n if len(nodeList) > 0:\... | [
"0.70851547",
"0.70435005",
"0.6444718",
"0.6246965",
"0.6225065",
"0.61497194",
"0.60729676",
"0.59668297",
"0.5915806",
"0.58188534",
"0.5817289",
"0.58145833",
"0.5802411",
"0.57501686",
"0.5727612",
"0.57120925",
"0.5695159",
"0.5669567",
"0.5641456",
"0.5641404",
"0.5610... | 0.7306041 | 0 |
Returns a descendent node found by a list of names and namespaceURIs forming a path. The path is expected to define a unique node. | def getSingleChildByPathNS(rootNode, path):
parentNode = rootNode
for (ns, name) in path:
node = getSingleChildByNameNS(parentNode, ns, name)
if node == None:
return None
else:
parentNode = node
return node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ParsePath(p_names: Iterable[Text]) -> gnmi_pb2.Path:\n gnmi_elems = []\n for word in p_names:\n word_search = _RE_PATH_COMPONENT.search(word)\n if not word_search: # Invalid path specified.\n raise XpathError('xpath component parse error: %s' % word)\n if word_search.group('key') is not None: ... | [
"0.5617993",
"0.5379932",
"0.5344396",
"0.52256453",
"0.5165489",
"0.5163145",
"0.5140036",
"0.49797037",
"0.49483255",
"0.49193937",
"0.4904224",
"0.4882593",
"0.48682582",
"0.48599708",
"0.48452106",
"0.482554",
"0.47848898",
"0.4771717",
"0.47439066",
"0.47428063",
"0.4738... | 0.5693317 | 0 |
Returns all child nodes of a specified name. | def getChildrenByName(rootNode, name):
return [e for e in rootNode.childNodes if e.localName == name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findChildren(self, name):\n\n # Note: this returns a list of all the children of a given\n # name, irrespective of the depth of look-up.\n \n children = []\n \n for child in self.getAllChildren():\n if child.getName() == name:\n children.appen... | [
"0.78755844",
"0.76069707",
"0.70648605",
"0.6875181",
"0.686096",
"0.68549895",
"0.6836145",
"0.67805845",
"0.6676841",
"0.6539384",
"0.65334934",
"0.65248793",
"0.6507252",
"0.6486434",
"0.6399938",
"0.6362787",
"0.63362265",
"0.6320614",
"0.6318085",
"0.6318085",
"0.629610... | 0.79214627 | 0 |
Returns all child nodes of a specified name and namespaceURI. | def getChildrenByNameNS(rootNode, ns, name):
return [e for e in rootNode.childNodes if e.localName == name and e.namespaceURI == ns] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getChildrenByName(rootNode, name):\n return [e for e in rootNode.childNodes if e.localName == name]",
"def getElements(self, name=\"\"):\n\n if not name:\n return self.children\n else:\n elements = []\n for element in self.children:\n if elemen... | [
"0.7223935",
"0.6433308",
"0.6407375",
"0.6367358",
"0.63064814",
"0.6166133",
"0.6032213",
"0.59840125",
"0.59068906",
"0.5855462",
"0.5814537",
"0.58058417",
"0.577752",
"0.5765865",
"0.5721846",
"0.5721846",
"0.5707831",
"0.5676966",
"0.5676966",
"0.564972",
"0.5647398",
... | 0.77882755 | 0 |
Add new node to the Pipeline | def add_node(self, new_node: 'GraphNode'):
self.operator.add_node(new_node) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_node(self, node):",
"def add_node(self, node):\n self.nodes.append(node)",
"def add_node (self, node):\n raise NotImplementedError",
"def add_node(self, node):\n self.nodes.add(node)",
"def addNode(self, node: Node):\n self.nodes.append(node)",
"def add_node(self, node):\n... | [
"0.78037673",
"0.75197977",
"0.74303645",
"0.74014753",
"0.7204696",
"0.7202427",
"0.7178709",
"0.7173464",
"0.715541",
"0.7050441",
"0.7048333",
"0.70343333",
"0.703212",
"0.70309037",
"0.7029448",
"0.7029448",
"0.70204383",
"0.70176816",
"0.7000545",
"0.69609106",
"0.693755... | 0.7537602 | 1 |
Replace the subtrees with old and new nodes as subroots | def update_subtree(self, old_subroot: 'GraphNode', new_subroot: 'GraphNode'):
self.operator.update_subtree(old_subroot, new_subroot) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_replace(self,node):\r\n self.feature_index = node.feature_index\r\n self.threshold = node.threshold\r\n self.label = node.label\r\n self.left = node.left\r\n self.right = node.right\r\n self.substitute = node.substitute\r\n if node.left is not None and node... | [
"0.7107235",
"0.65856475",
"0.6365465",
"0.63301456",
"0.625012",
"0.6236693",
"0.61715674",
"0.61310095",
"0.6120327",
"0.60683495",
"0.6065253",
"0.6024953",
"0.6012735",
"0.5961078",
"0.5948224",
"0.5947182",
"0.59322995",
"0.5925321",
"0.5905774",
"0.5905076",
"0.58694637... | 0.6714457 | 1 |
Delete the subtree with node as subroot. | def delete_subtree(self, subroot: 'GraphNode'):
self.operator.delete_subtree(subroot) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_root(self, node):\n current = node\n successor = self.find_successor(current) \n temp_height = current.height\n current.height = successor.height\n successor.height = temp_height\n\n if successor != None:\n self.root = successor\n parent = ... | [
"0.75925773",
"0.7480435",
"0.7424216",
"0.71247655",
"0.70918965",
"0.70537895",
"0.6969854",
"0.6895656",
"0.68567795",
"0.682668",
"0.67609817",
"0.66893965",
"0.66813046",
"0.6672785",
"0.667115",
"0.66323125",
"0.6606388",
"0.6594874",
"0.6567626",
"0.6545911",
"0.652475... | 0.8428926 | 0 |
compute the hs300 and zz500 weekly exposure on style factors | def factor_exposure(self):
exp_hs_all = pd.DataFrame([])
exp_zz_all = pd.DataFrame([])
for i in range(len(self.weekly_date)):
date = self.weekly_date.iloc[i,0]
factor = get_barra_factor_from_sql(date)
factor['secID'] = factor.index.tolist()
stockli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exposure():\n def r(x):\n return x/6e4\n\n def w(x):\n return int(x*6e4)\n return r, w",
"def get_weight(ew1, ew2):\n dw = flu.delta_epiweeks(ew1, ew2)\n yr = 52.2\n hl1, hl2, bw = yr, 1, 4\n a = 0.05\n #b = (np.cos(2 * np.pi * (dw / yr)) + ... | [
"0.61604285",
"0.56509274",
"0.55025834",
"0.53923845",
"0.53762066",
"0.5370133",
"0.5294281",
"0.52752477",
"0.5265615",
"0.520303",
"0.5171824",
"0.51513815",
"0.5132893",
"0.5092595",
"0.5088409",
"0.5087371",
"0.50813",
"0.5065104",
"0.50638103",
"0.5060144",
"0.50426376... | 0.5779782 | 1 |
Read taxonomy nodes.dmp file into pandas DataFrame | def read_nodes_dmp(fname):
df = pd.read_csv(fname, sep="|", header=None, index_col=False,
names=['tax_id',
'parent_tax_id',
'rank',
'embl_code',
'division_id',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_node_file(self):\n self.node_df = gt.remove_colons(pd.read_csv(self.node_file, dtype=str))",
"def nodes_df_creation(self, path: str) -> pyspark.sql.dataframe.DataFrame:\n try:\n nodes_df = self.spark.read.parquet(path)\n except OSError:\n print('cannot open', ... | [
"0.6789381",
"0.6212274",
"0.615097",
"0.6114801",
"0.6108535",
"0.5889607",
"0.5821102",
"0.58102983",
"0.57548654",
"0.56308955",
"0.5610583",
"0.56097096",
"0.5609186",
"0.55935985",
"0.5593163",
"0.5582398",
"0.55768555",
"0.55726385",
"0.55648285",
"0.55583286",
"0.55448... | 0.78661364 | 0 |
Read taxonomy names.dmp file into pandas DataFrame | def read_names_dmp(fname):
df = pd.read_csv(fname, sep="|", header=None, index_col=False,
names=["tax_id",
"name_txt",
"unique_name",
"name_class"])
return df.assign(name_txt = lambda x: x['name_txt'].str.strip(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_nodes_dmp(fname):\n df = pd.read_csv(fname, sep=\"|\", header=None, index_col=False,\n names=['tax_id', \n 'parent_tax_id',\n 'rank', \n 'embl_code',\n 'division_id', \n ... | [
"0.68054324",
"0.5834878",
"0.5798597",
"0.5793068",
"0.57881135",
"0.57818484",
"0.5780603",
"0.5767426",
"0.5762671",
"0.5683659",
"0.5658958",
"0.5644294",
"0.56357336",
"0.557491",
"0.55712473",
"0.55641025",
"0.55571115",
"0.5556157",
"0.5546592",
"0.55335677",
"0.550611... | 0.7467837 | 0 |
Checks authorization of a rule against the target in this context. This function is not to be called directly. Calling the function with a target that evaluates to None may result in policy bypass. Use 'authorize_on_' calls instead. | def __authorize(context, rule, target=None):
target = target or {'tenant': context.tenant}
return get_enforcer().authorize(
rule, target, context.to_dict(), do_raise=True,
exc=trove_exceptions.PolicyNotAuthorized, action=rule) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_check_policy(func):\n @functools.wraps(func)\n def wrapped(self, context, target_obj, *args, **kwargs):\n check_policy(context, func.__name__, target_obj)\n return func(self, context, target_obj, *args, **kwargs)\n\n return wrapped",
"def authorization_rule(self) -> Optional[pulum... | [
"0.59729636",
"0.58791226",
"0.57168037",
"0.56584775",
"0.55937326",
"0.5568693",
"0.55458856",
"0.55406976",
"0.5506479",
"0.550026",
"0.5477174",
"0.5477174",
"0.5420243",
"0.53873324",
"0.5317387",
"0.5297428",
"0.5296398",
"0.52627957",
"0.52248955",
"0.5222644",
"0.5208... | 0.7202618 | 0 |
'To assume as true in the absence of proof to the contrary.' Returns a modified transaction with this value set if the value of the item is not already known. If a value has already been fetched or presumed, this will be a noop. If modified, the presumed value will be available via `get`, and will additionally check yo... | def presume(
transaction: VersionedTransaction,
table: TableNameOrResource,
item_key: ItemKey,
item_value: Optional[Item],
) -> VersionedTransaction:
if item_value is not None:
for key_attr, key_val in item_key.items():
assert item_value[key_attr] == key_val, "Item key must match... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_batch_get_lazy_load():\n t = VersionedTransaction(dict())\n table_a = ItemTable(\"a\")\n table_b = ItemTable(\"b\")\n\n a1_k = dict(id=\"a1\")\n a2_k = dict(id=\"a2\")\n b1_k = dict(id=\"b1\")\n\n a3_k = dict(id=\"a3\")\n\n def triple_get(t: VersionedTransaction) -> VersionedTransa... | [
"0.5932803",
"0.5802937",
"0.5779788",
"0.5756236",
"0.5724148",
"0.56774515",
"0.5541173",
"0.55110294",
"0.5491138",
"0.5489476",
"0.53459036",
"0.5339431",
"0.5324479",
"0.52662617",
"0.522534",
"0.5209724",
"0.520189",
"0.51962876",
"0.5192975",
"0.51924634",
"0.5159292",... | 0.6724734 | 0 |
Idempotent definition of key attribute schema for the given table without forcing any IO operations/effects up front. The main reason you might want to do this is if you need to do a `put`, because `put` cannot infer the shape of your key. If the table definition is already present, this is a noop. | def define_table(
transaction: VersionedTransaction, table: TableNameOrResource, *key_attributes: str,
) -> VersionedTransaction:
assert len(key_attributes) > 0 and len(key_attributes) <= 2
if _table_name(table) in transaction.tables:
return transaction
return VersionedTransaction(
table... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_table_schema(table_desc, table_name, schema):\n table_desc['TableName'] = table_name\n table_desc['AttributeDefinitions'] = [{\n 'AttributeName': item['name'],\n 'AttributeType': DynamoStubber._encode_type(item['type'])\n } for item in schema]\n ... | [
"0.60570586",
"0.5902038",
"0.5678898",
"0.5671591",
"0.5581425",
"0.55520034",
"0.5543876",
"0.55083936",
"0.53274363",
"0.53022087",
"0.52965194",
"0.5224999",
"0.52233547",
"0.5223007",
"0.5222796",
"0.52002573",
"0.51673585",
"0.5139907",
"0.5126423",
"0.51261",
"0.511605... | 0.6186573 | 0 |
Given a relpath like drake/pkg/res.txt or external/repo/pkg/res.txt, find the data file and return its path | def find_data(relpath):
# Because we are in a py_binary, Bazel's wrapper script sets up our
# $PYTHONPATH to have our resources somewhere on a sys.path entry.
for one_path in sys.path:
possible = os.path.join(one_path, relpath)
if os.path.exists(possible):
return possible
rai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_path(data_path):\n\treturn os.path.dirname(os.path.realpath(__file__)) + os.sep + data_path",
"def get_data_file(f):\n if os.path.isfile(f):\n path = f\n\n else:\n p = pkg_resources.resource_filename('PaSDqc', \"db/{}\".format(f))\n \n if os.path.isfile(p):\n ... | [
"0.71274626",
"0.6904814",
"0.6769969",
"0.6497312",
"0.6490332",
"0.6470966",
"0.64500815",
"0.64413446",
"0.64217675",
"0.6399083",
"0.63932604",
"0.63386345",
"0.6311808",
"0.62965494",
"0.62960714",
"0.6275206",
"0.62670004",
"0.62568855",
"0.62269145",
"0.62260854",
"0.6... | 0.7789457 | 0 |
Build a userinput_listener coroutine. | def user_input_listener(state: SharedState): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _listen(self):\n users = fileIO.load_json(\"users.json\")\n print(\"The list of users is: \")\n for i in users:\n print(users[i][\"name\"])\n name = False\n while not name: #Loop until valid user given\n name = input(\"Please enter the user that you woul... | [
"0.60229254",
"0.5902512",
"0.5665694",
"0.5660546",
"0.5540109",
"0.552596",
"0.55182016",
"0.5446837",
"0.54210794",
"0.53281254",
"0.53130955",
"0.5302447",
"0.52767766",
"0.52541715",
"0.5171928",
"0.51666707",
"0.5162627",
"0.51598024",
"0.51451725",
"0.5137769",
"0.5034... | 0.74263144 | 0 |
Returns length of longest increasing subsequence given an array of numbers. | def longestIncreasingSubsequence(nums):
if not nums:
return 0
dp = [None] * len(nums)
dp[0] = 1
maxans = 1
for i in range(1, len(dp)):
maxval = 0
for j in range(0, i):
if nums[i] > nums[j]:
maxval = max(maxval, dp[j])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_length_of_longest_sub_array(l):\n if len(l) < 1:\n return 0\n\n longest_seen_sequence = 0\n\n this_sequence_length = 1\n\n previous = l[0]\n\n for _, current in enumerate(l):\n\n if current > previous:\n this_sequence_length = this_seq... | [
"0.7756621",
"0.7332605",
"0.6925975",
"0.68926334",
"0.6865751",
"0.68350095",
"0.66415817",
"0.6594408",
"0.65523106",
"0.6539818",
"0.65185964",
"0.6484091",
"0.64561516",
"0.64262223",
"0.6355707",
"0.62699634",
"0.6269051",
"0.62369823",
"0.6226302",
"0.6150499",
"0.6116... | 0.7476641 | 1 |
Create an Action from this intent, filling missing data from state | def at(self, state):
self.complete_data(state)
self.check_duplicate(state)
action = entities.Action(
action_id=new_id(state),
type=self.get_type_name(),
data=pmap(self.data),
time=state.context.time,
randomness=state.context.randomness,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _formulate_action(Action, **kwargs):\n\n return Action(**kwargs)",
"def action(self, action_id):\r\n return Action(self, action_id)",
"def action(self, action_id):\r\n return Action(self, action_id)",
"def from_of_action(cls, of_action):\n return cls()",
"def create_action(insta... | [
"0.63214076",
"0.6280206",
"0.6280206",
"0.6092075",
"0.60566056",
"0.5983633",
"0.5972293",
"0.59379184",
"0.58593243",
"0.58537024",
"0.5842147",
"0.5834748",
"0.5764666",
"0.5716841",
"0.5701877",
"0.5692661",
"0.5685065",
"0.56532115",
"0.5642375",
"0.56263447",
"0.561336... | 0.72059274 | 0 |
Match the calibSources and sources, and propagate Interesting Flags (e.g. PSF star) to the sources | def propagateCalibFlags(keysToCopy, calibSources, sources, matchRadius=1):
if calibSources is None or sources is None:
return
closest = False # return all matched objects
matched = afwTable.matchRaDec(calibSources, sources, matchRadius*afwGeom.arcseconds, closest)
#
# Becaus... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sources_extraction(image,sextractor_pars):\n\n cat_name, detect_minarea, detect_thresh, analysis_thresh, phot_aperture, satur_level, ZP, gain, pixelScale,seeing,back_type,back_value,back_size,backphoto_type,backphoto_thick,back_filterthresh,checkimage_type,checkimage_name= sextractor_pars\n sp.run('sex %s.... | [
"0.56265473",
"0.55381423",
"0.55253875",
"0.5407288",
"0.53591067",
"0.53485554",
"0.53367805",
"0.5311908",
"0.5266865",
"0.52260643",
"0.5216051",
"0.5157914",
"0.5119476",
"0.507221",
"0.5060244",
"0.50464916",
"0.5040846",
"0.50221545",
"0.50190264",
"0.5007729",
"0.5004... | 0.69685996 | 0 |
Checks that the Drakecreated flavor of nlopt.cpp (via a patch file) is consistent with the upstreamgenerated flavor of same (via CMake). If this test fails during an NLopt version pin upgrade, you will need to update patches/gen_enums.patch with the reported differences. | def test_enum_cross_check(self):
# Load both input files.
# "actual" refers to the the Drake-created flavor (via a patch file).
# "expected" refers to the upstream-generated flavor (via CMake).
manifest = runfiles.Create()
actual_file = manifest.Rlocation(
"nlopt_inte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(self, expected):\n versions = ['3.0', '4.0', '5.0', '6.0', '7.0', '8.0']\n modes = ['strict', 'normal', 'ignore']\n\n for version in versions:\n for mode in modes:\n assert self.get(app_version=version, compat_mode=mode) == (\n expected['-... | [
"0.56607723",
"0.5562484",
"0.54389495",
"0.5402845",
"0.53964126",
"0.5389693",
"0.53053814",
"0.5245198",
"0.523824",
"0.5220819",
"0.5130013",
"0.50907856",
"0.5084268",
"0.507624",
"0.50242937",
"0.5022775",
"0.5013908",
"0.5011498",
"0.50096434",
"0.49897176",
"0.4972365... | 0.6848094 | 0 |
Evaluate the given distribution function in the point(s) (r, ppar, pperp). Use the vector 'v' to specify the parameters of this distribution function. | def Eval(self, r, ppar, pperp, v, gamma=None, p2=None, p=None, xi=None):
while False:
yield None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _p_v_at_r(self, v, r):\n if hasattr(self, \"_logfQ_interp\"):\n return (\n numpy.exp(\n self._logfQ_interp(\n -_evaluatePotentials(self._pot, r, 0) - 0.5 * v**2.0\n )\n )\n * v**2.0\n ... | [
"0.66941005",
"0.6040724",
"0.5935693",
"0.5931339",
"0.5931324",
"0.5880862",
"0.5767878",
"0.5735554",
"0.56684875",
"0.5650999",
"0.5604907",
"0.5558572",
"0.5557449",
"0.5551832",
"0.55289036",
"0.55191976",
"0.5493359",
"0.54931647",
"0.54723114",
"0.5459315",
"0.5458212... | 0.6704118 | 0 |
Calculate phase autocorrelation for each signal in seismic_stream | def acorr(seismic_signal, **kwargs):
# if seismic signal is a trace object, we pack it to a stream
if isinstance(seismic_signal, _tr.Trace):
sources = _st.Stream([seismic_signal])
else:
sources = seismic_signal
if not isinstance(sources, _st.Stream):
raise TypeError('seismic_str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step_autocorrelation(self):\n\n max_hops = max([len(x) for x in self.steps])\n\n self.acf = np.zeros([len(self.steps), max_hops])\n\n keep = [] # list to hold indices of trajectories with a non-zero amount of hops\n for i in range(len(self.steps)):\n hops = self.steps[i]... | [
"0.6106281",
"0.5915008",
"0.5743236",
"0.56838435",
"0.56832486",
"0.5655305",
"0.56056494",
"0.55680525",
"0.5545803",
"0.55240375",
"0.55095017",
"0.54883564",
"0.54883564",
"0.5412182",
"0.5382874",
"0.5338562",
"0.5338562",
"0.52966046",
"0.5273439",
"0.52382296",
"0.520... | 0.5928678 | 1 |
Calculate phase cross correlation (pcc) between signal1 and signal2 For this purpose signal2 is shifted in time and compared to corresponding portion in signal1 | def _xcorr_trace(signal1, signal2, **kwargs):
kwargs['mode'] = 'pcc'
kwargs['lags'] = __default_lags_if_not_set(signal1, signal2, **kwargs)
pcc_signal = phasecorr.xcorr(signal1.data, signal2.data, **kwargs)
trace = _tr.Trace(data=pcc_signal)
__writeheader(trace, signal1, **kwargs)
return tra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cphase(h1, h2):\n\n for h in (h1, h2):\n h.assert_ket_space()\n\n field = h1.base_field\n\n d = h1.dim()\n if h2.dim() != d:\n raise HilbertError('spaces must be of the same dimension')\n\n ret = (h1*h2).O.array()\n for (j, a) in enumerate(h1.index_iter()):\n for (k, b) i... | [
"0.66017336",
"0.6389433",
"0.61255634",
"0.6099715",
"0.6079657",
"0.6045117",
"0.59957165",
"0.5968298",
"0.5967114",
"0.59037614",
"0.5879406",
"0.5871049",
"0.5862538",
"0.585481",
"0.58367324",
"0.57887626",
"0.57637984",
"0.5761343",
"0.5755311",
"0.5738161",
"0.573262"... | 0.69613063 | 0 |
Calculate phase auto correlation (pac) of signal1 For this purpose a shifted copy in time of signal1 is compared to corresponding portion in signal1 | def _acorr_trace(signal1, **kwargs):
kwargs['mode'] = 'pac'
kwargs['lags'] = __default_lags_if_not_set(signal1, signal1, **kwargs)
pac_signal = phasecorr.acorr(signal1.data, **kwargs)
trace = _tr.Trace(data=pac_signal)
__writeheader(trace, signal1, **kwargs)
return trace | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def constract(phase, magnitude):\n new_spectrum = magnitude * np.exp(1j * phase)\n\n # reverse the shift and FFT\n f_ishift = np.fft.ifftshift(new_spectrum)\n img_back = np.fft.ifft2(f_ishift)\n \n return np.abs(img_back)",
"def test_lag1Cor_Estimation(self):\n P = PSignal.PSignal(np.arange(10... | [
"0.59478575",
"0.5942706",
"0.58623695",
"0.58456415",
"0.58392256",
"0.5771846",
"0.57513154",
"0.57069325",
"0.5691568",
"0.569096",
"0.5653918",
"0.5615717",
"0.55893755",
"0.55863965",
"0.55757755",
"0.5560512",
"0.55482876",
"0.55477715",
"0.55407035",
"0.55402577",
"0.5... | 0.6709351 | 0 |
get random proxy from proxypool | def get_random_proxy():
url=requests.get(proxypool_url).text.strip()
#logger.info("now url is",url)
return url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random(self):\n return random.choice(self.proxies)",
"def get_proxy_pool(self,proxy_pool,num):\n\n url='{url}/proxy/?num={num}'.format(url=config.SERVER_URL,num=num)\n\n try:\n res=request.urlopen(url,timeout=5).read()\n res=str(res,encoding='utf8')\n exc... | [
"0.7766926",
"0.7258919",
"0.72230166",
"0.70320004",
"0.6830322",
"0.67573696",
"0.6513024",
"0.64002264",
"0.63306606",
"0.6161731",
"0.60935825",
"0.6068532",
"0.59971714",
"0.5855311",
"0.584551",
"0.58218956",
"0.57690114",
"0.574567",
"0.5730094",
"0.5697484",
"0.569187... | 0.8399079 | 0 |
use proxy to crawl page | def crawl(url):
while True:
try:
proxy=get_random_proxy()
proxies = {'http': 'http://' + proxy}
logger.info(proxies)
resp = requests.get(url, proxies=proxies,timeout=3) # 设置代理,抓取每个公司的连接
resp.encoding = resp.apparent_encoding # 可以正确解码
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\n if self.is_full():\n return\n for crawler in self.crawlers:\n logger.info(f'crawler {crawler} to get proxy')\n proxies = crawler.run()\n if proxies:\n for proxy in proxies:\n self.redis.add(proxy)\n ... | [
"0.6656336",
"0.6540788",
"0.6506942",
"0.65062267",
"0.6483475",
"0.6374295",
"0.6259475",
"0.6233891",
"0.6208135",
"0.61101043",
"0.609967",
"0.60954505",
"0.6091064",
"0.605424",
"0.6050282",
"0.60383075",
"0.6023799",
"0.59682155",
"0.5963611",
"0.59390926",
"0.59319854"... | 0.69973946 | 0 |
Checks if given position is empty ("") in the board. | def _position_is_empty_in_board(position, board):
return board[position[0]][position[1]] == "-" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_empty_space(board, position1):\n return board[position1] == \" \"",
"def emptyAt(self, position):\n\n #check for any sprites at the position\n for key in self.sprites:\n s = self.sprites[key]\n if s.position == position and s.visible: #not visible means it isn't taking up t... | [
"0.79477996",
"0.788795",
"0.7743375",
"0.7719691",
"0.76447976",
"0.74391013",
"0.74310374",
"0.7350126",
"0.7295014",
"0.71880174",
"0.71601164",
"0.7151122",
"0.7118377",
"0.7117768",
"0.7107725",
"0.71016866",
"0.7068392",
"0.7039862",
"0.6971793",
"0.6948898",
"0.6942450... | 0.89006466 | 0 |
Checks if given position is a valid. To consider a position as valid, it must be a twoelements tuple, containing values from 0 to 2. | def _position_is_valid(position):
# Make sure that...
# position is a tuple
# position's length is 2
# every value in the tuple is an int
# every int in the tuple is either 0, 1 or 2
# if not, return False
if not isinstance(position, tuple) \
or len(position) != 2 \... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_valid_position_tuple(pos):\n try: chrom, start_pos, end_pos, strand = pos\n except (TypeError, ValueError): raise MutantError(\"Didn't get a correct position tuple! %s\"%pos)\n if strand not in SEQ_STRANDS: raise MutantError(\"Invalid strand %s!\"%strand)... | [
"0.76978976",
"0.7626505",
"0.7124657",
"0.70859355",
"0.6977404",
"0.69307876",
"0.685049",
"0.6840817",
"0.67205507",
"0.6672402",
"0.66398543",
"0.66194904",
"0.6600491",
"0.6599175",
"0.6573275",
"0.65055704",
"0.6466658",
"0.6444392",
"0.6436828",
"0.63908213",
"0.635216... | 0.84633476 | 0 |
Checks if all 3 positions in given combination are occupied by given player. | def _is_winning_combination(board, combination, player):
"""
### Code before refactoring into a comprehension list:
for a_tuple in combination:
# e.g. a_tuple = (0,0)
# if board[0][0] != "X"
if board[a_tuple[0]][a_tuple[1]] != player:
return False
"""
if any(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_winning_combinations(board, player):\n winning_combinations = (\n ((0, 0), (0, 1), (0, 2)),\n ((1, 0), (1, 1), (1, 2)),\n ((2, 0), (2, 1), (2, 2)),\n ((0, 0), (1, 0), (2, 0)),\n ((0, 1), (1, 1), (2, 1)),\n ((0, 2), (1, 2), (2, 2)),\n ((0, 0), (1, 1), (... | [
"0.7056445",
"0.6785087",
"0.6513575",
"0.6407896",
"0.63359",
"0.6332282",
"0.6314953",
"0.62546915",
"0.62414443",
"0.6239754",
"0.6238734",
"0.61814517",
"0.6174631",
"0.6169825",
"0.61628115",
"0.6144622",
"0.61050117",
"0.60615724",
"0.60549986",
"0.6050816",
"0.60260415... | 0.72803354 | 0 |
There are 8 posible combinations (3 horizontals, 3, verticals and 2 diagonals) to win the Tictactoe game. This helper loops through all these combinations and checks if any of them belongs to the given player. | def _check_winning_combinations(board, player):
winning_combinations = (
((0, 0), (0, 1), (0, 2)),
((1, 0), (1, 1), (1, 2)),
((2, 0), (2, 1), (2, 2)),
((0, 0), (1, 0), (2, 0)),
((0, 1), (1, 1), (2, 1)),
((0, 2), (1, 2), (2, 2)),
((0, 0), (1, 1), (2, 2)),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_winning_combination(board, combination, player):\n\n \"\"\"\n ### Code before refactoring into a comprehension list:\n\n for a_tuple in combination:\n\n # e.g. a_tuple = (0,0)\n # if board[0][0] != \"X\"\n if board[a_tuple[0]][a_tuple[1]] != player:\n\n return False... | [
"0.71583956",
"0.70575804",
"0.7002491",
"0.6714407",
"0.669649",
"0.66591203",
"0.66099006",
"0.6589296",
"0.6558027",
"0.6533149",
"0.6491051",
"0.6489824",
"0.644219",
"0.6395233",
"0.6353411",
"0.63451284",
"0.6342977",
"0.6325276",
"0.62973696",
"0.6287886",
"0.6280949",... | 0.76965 | 0 |
Used to build the gender branch of our face recognition network. This branch is composed of three Conv > BN > Pool > Dropout blocks, followed by the Dense output layer. | def build_gender_branch(self, inputs, num_genders=2):
x = Lambda(lambda c: tf.image.rgb_to_grayscale(c))(inputs)
x = self.make_default_hidden_layers(inputs)
x = Flatten()(x)
x = Dense(128)(x)
x = Activation("relu")(x)
x = BatchNormalization()(x)
x = Dropout(0.5)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_discriminator(self):\n img_shape = (self.img_size[0], self.img_size[1], self.channels)\n\n model = Sequential()\n ###############\n # Conv Stack 1:\n ###############\n model.add(\n Conv2D(128, kernel_size=5, strides=2, input_shape=img_shape, padding=\"... | [
"0.66957885",
"0.66077316",
"0.63622165",
"0.6342879",
"0.633063",
"0.6302211",
"0.6302211",
"0.62979877",
"0.6269781",
"0.62534744",
"0.623655",
"0.62052697",
"0.61675453",
"0.61575735",
"0.61488783",
"0.61291873",
"0.61201566",
"0.61011446",
"0.60958564",
"0.6083565",
"0.60... | 0.7864113 | 0 |
Used to build the age branch of our face recognition network. This branch is composed of three Conv > BN > Pool > Dropout blocks, followed by the Dense output layer. | def build_age_branch(self, inputs):
x = self.make_default_hidden_layers(inputs)
x = Flatten()(x)
x = Dense(128)(x)
x = Activation("relu")(x)
x = BatchNormalization()(x)
x = Dropout(0.5)(x)
x = Dense(1)(x)
x = Activation("linear", name="age_output")(x)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discriminator_block(in_filters, out_filters):\n layers = [ nn.Conv2d(in_filters, out_filters, 4, stride=2, padding=1),\n nn.LeakyReLU(0.01)]\n return layers",
"def build_bisenet(inputs, num_classes):\n\n ### The spatial path\n ### The number of feature maps for each... | [
"0.6322069",
"0.62509495",
"0.6210222",
"0.6205929",
"0.61850744",
"0.6165662",
"0.61332285",
"0.6119399",
"0.6096222",
"0.60777825",
"0.6053835",
"0.60508585",
"0.60431457",
"0.6030179",
"0.60178214",
"0.6007941",
"0.5995195",
"0.5962688",
"0.59607214",
"0.59575105",
"0.5951... | 0.7157092 | 0 |
raise WinproxyError if result is 0 | def fail_on_zero(func_name, result, func, args):
if not result:
raise WinproxyError(func_name)
return args | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winhttp_WinHttpFreeProxyResult(jitter):\n ret_ad, args = jitter.func_args_stdcall([\"pProxyResult\"])\n raise RuntimeError('API not implemented')\n jitter.func_ret_stdcall(ret_ad, ret_value)",
"def winhttp_WinHttpGetProxyResult(jitter):\n ret_ad, args = jitter.func_args_stdcall([\"hResolver\", \"... | [
"0.68406665",
"0.63366336",
"0.6020998",
"0.6016139",
"0.58826256",
"0.5877293",
"0.5857276",
"0.582949",
"0.57794017",
"0.5773708",
"0.57534397",
"0.56958175",
"0.5652606",
"0.5602097",
"0.5585624",
"0.5577021",
"0.55100924",
"0.5496161",
"0.54908186",
"0.5478192",
"0.542409... | 0.721989 | 0 |
LciaEngine.__getitem__ retrieves a canonical context by more intensively searching for matches from a given context. Adds foreign context's full name as synonym if one is affirmatively found. If one is not found, returns the NullContext. None is returned as None, to represent 'unspecified' (i.e. accept all) as opposed ... | def __getitem__(self, item):
if item is None:
return None
try:
return self._cm.__getitem__(item)
except KeyError:
if isinstance(item, Context):
return self._cm.find_matching_context(item)
elif isinstance(item, tuple) and len(item) >... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __dis_context__(self, context, word):\n senses = self.vs.get_senses(word, self.ignore_case)\n if self.verbose:\n print(\"Senses of a target word:\")\n print(senses)\n\n if len(senses) == 0: # means we don't know any sense for this word\n return None\n\n ... | [
"0.57803524",
"0.52267176",
"0.5220787",
"0.52120763",
"0.5174642",
"0.5164446",
"0.5149356",
"0.5041184",
"0.49859065",
"0.49716657",
"0.49243554",
"0.49187955",
"0.49112827",
"0.4855967",
"0.48273122",
"0.4817933",
"0.47763702",
"0.47615644",
"0.4757728",
"0.47567716",
"0.4... | 0.6447261 | 0 |
Given a quantity, import its CFs into the local database. Unfortunately this is still going to be slow because every part of the CF still needs to be canonicalized. The only thing that's saved is creating a new Characterization instance. | def import_cfs(self, quantity):
try:
qq = self._canonical_q(quantity)
except KeyError:
qq = self.add_quantity(quantity)
count = 0
for cf in quantity.factors():
count += 1
# print(cf)
try:
fb = self._fm[cf.flowab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_counties():\n\n query = 'INSERT INTO texas_counties(county, region) VALUES(%s,%s)'\n with persistence() as db:\n # create new cursor instance\n cursor = db.cursor(cursor_factory=psycopg2.extras.RealDictCursor)\n\n for council, counties in COUNCIL_DATA.items():\n for... | [
"0.54053676",
"0.5345252",
"0.5009659",
"0.49099687",
"0.47605696",
"0.4740605",
"0.4696015",
"0.46920276",
"0.46907184",
"0.46507764",
"0.46204922",
"0.46030006",
"0.45985758",
"0.45907193",
"0.45657995",
"0.4537645",
"0.45328835",
"0.45299235",
"0.45244938",
"0.45229474",
"... | 0.7534431 | 0 |
Return a str (one line for each function). | def text_for_funcs_in_script(filename, prefix):
funcs = funcs_in_script(filename)
###################################################
# FIND LENGTH OF LONGEST FUNCTION NAME #
###################################################
maxlen = 0
for func in funcs:
name, header = func... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self) -> str:\n return f\"<Function[{self.name}](line:{self.line})>\"",
"def __str__(self):\n header = [\n ' ObjectiveFunction:']\n header += [('Function: {}').format(self.func.__name__)]\n header += [('Objective: {}').format(self.objective)]\n return ('\\... | [
"0.67271453",
"0.6665395",
"0.6479111",
"0.6360932",
"0.6307341",
"0.6295157",
"0.6287792",
"0.62198514",
"0.62004966",
"0.6192446",
"0.61677325",
"0.6148869",
"0.6146638",
"0.61425155",
"0.6135748",
"0.61207575",
"0.6108479",
"0.6081794",
"0.6076851",
"0.6067959",
"0.6054603... | 0.7050024 | 0 |
Take the addressLocality field in each object, tokenize it by space and comma, lower case it and convert to set of words. use each token in that set as a 'key' for the cluster. We'll start by analyzing those. | def cluster_by_addressLocality(input_file, output_file=None):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assignment(self, addresses, centroids, k):\n newClusters = {}\n print centroids\n for (lat, long) in addresses:\n minDistance = float('Inf')\n minIndex = 0\n for i in range(k):\n if pow(self.euclideanDistance((lat, long), centroids[i]),2) < m... | [
"0.5454766",
"0.5336172",
"0.5156881",
"0.49238616",
"0.49154887",
"0.4913995",
"0.49080405",
"0.4892176",
"0.4884314",
"0.48810974",
"0.48677456",
"0.48650676",
"0.48480317",
"0.48207906",
"0.48084152",
"0.47848007",
"0.47784892",
"0.47779834",
"0.4769221",
"0.4753887",
"0.4... | 0.6299373 | 0 |
Access the fA Function object | def fA(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFunction(self) -> ghidra.program.model.listing.Function:\n ...",
"def fun_a(self):\n pass",
"def f(self):\n return self._f",
"def getFunction(self, name: unicode) -> ghidra.program.model.listing.Function:\n ...",
"def _function_class(self):\n return FriCASExpectFun... | [
"0.7123425",
"0.68525356",
"0.64563775",
"0.64336723",
"0.639151",
"0.63692874",
"0.62956244",
"0.61945254",
"0.61939263",
"0.6183318",
"0.6174362",
"0.6169994",
"0.6164318",
"0.61532414",
"0.61523753",
"0.61212516",
"0.61144304",
"0.6113079",
"0.6110896",
"0.6106164",
"0.610... | 0.7363549 | 0 |
Access the fAT Function object | def fAT(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFunction(self) -> ghidra.program.model.listing.Function:\n ...",
"def _function_class(self):\n return FriCASExpectFunction",
"def _func(self):\n return self._get_flint_func(self.domain)",
"def getFunction(self, name: unicode) -> ghidra.program.model.listing.Function:\n ..."... | [
"0.7442082",
"0.6662068",
"0.6623393",
"0.6567047",
"0.65216845",
"0.6444521",
"0.643786",
"0.64078254",
"0.63968444",
"0.6320934",
"0.62078595",
"0.62051314",
"0.6176589",
"0.6172265",
"0.6146051",
"0.6146051",
"0.6146051",
"0.61392206",
"0.61384785",
"0.61301565",
"0.612650... | 0.71219444 | 1 |
Access the fG Function object | def fG(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFunction(self) -> ghidra.program.model.listing.Function:\n ...",
"def get_function(self):\n return Gumtree.gumtree.getFunction()",
"def f(self):\n return self._f",
"def _func(self):\n return self._get_flint_func(self.domain)",
"def getFunction(self, name: unicode) -> ghid... | [
"0.76139027",
"0.6928935",
"0.6813307",
"0.6666093",
"0.6652074",
"0.6623601",
"0.6622213",
"0.6612022",
"0.6381208",
"0.6379428",
"0.6367264",
"0.6351534",
"0.6351534",
"0.6345019",
"0.6327853",
"0.6263485",
"0.62374866",
"0.62359047",
"0.62125313",
"0.6190691",
"0.6170642",... | 0.7354346 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.