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 |
|---|---|---|---|---|---|---|
Edit a word, given edit and seq2seq predictions. | def edit_word(word, pred, edit_id):
if edit_id == 1:
return word
elif edit_id == 2:
return word.lower()
elif edit_id == 0:
return pred
else:
raise Exception("Unrecognized edit ID: {}".format(edit_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, edit, text):\n\n self.view.replace(edit, sublime.Region(0, self.view.size()), text)",
"def edit_type(self, candidate, word):\n edit = [False] * 4\n correct = \"\"\n error = \"\"\n replaced = ''\n replacer = ''\n for i in range(min([len(word), len(can... | [
"0.6174945",
"0.60229707",
"0.5899469",
"0.57732034",
"0.5592264",
"0.55552644",
"0.5521997",
"0.5502276",
"0.5495809",
"0.5456979",
"0.54296225",
"0.5428467",
"0.54205805",
"0.541739",
"0.5410759",
"0.5397918",
"0.5367953",
"0.5361758",
"0.53517514",
"0.53470916",
"0.5306250... | 0.76849246 | 0 |
Lookup the name of the word vectors file, given a directory and the language shorthand. | def get_wordvec_file(w2v_name, wordvec_dir, shorthand, wordvec_type=None):
lcode, tcode = shorthand.split('_', 1)
# locate language folder
word2vec_dir = os.path.join('../..', wordvec_dir, 'word2vec', w2v_name)
fasttext_dir = os.path.join('../..', wordvec_dir, 'fasttext', w2v_name)
lang_dir =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vocabulary_file_by_name(working_dir, key):\n return os.path.join(\n working_dir,\n transform_fn_io.TRANSFORM_FN_DIR,\n 'assets',\n key)",
"def filename(lang):\n filename = lang.replace('-', '_')\n filename = filename.lower()\n return filename",
"def load_vector_dictionary():\n... | [
"0.627825",
"0.58727306",
"0.57929516",
"0.57597464",
"0.5721504",
"0.5699182",
"0.5691472",
"0.56372076",
"0.5623467",
"0.5562589",
"0.553958",
"0.55210835",
"0.54783404",
"0.5444172",
"0.54044497",
"0.5367935",
"0.5325492",
"0.5291947",
"0.52776533",
"0.52409035",
"0.522318... | 0.7659485 | 0 |
Adjust the evaluation interval adaptively. If cur_dev_size <= thres_dev_size, return base_interval; else, linearly increase the interval (round to integer times of base interval). | def get_adaptive_eval_interval(cur_dev_size, thres_dev_size, base_interval):
if cur_dev_size <= thres_dev_size:
return base_interval
else:
alpha = round(cur_dev_size / thres_dev_size)
return base_interval * alpha | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_warmup(base_value, max_warmup_iter, cur_step):\n if max_warmup_iter <= cur_step:\n return base_value\n return base_value * cur_step / max_warmup_iter",
"def adjust_learning_rate(self):\n out_base_lr = self.args.base_lr\n for param_group in self.optimizer.param_groups:\n ... | [
"0.5987227",
"0.55939424",
"0.55920815",
"0.55292815",
"0.5408765",
"0.5307269",
"0.5254599",
"0.52344215",
"0.52241945",
"0.5200749",
"0.5155124",
"0.5123047",
"0.510742",
"0.51069885",
"0.50952154",
"0.5083415",
"0.50747776",
"0.50701195",
"0.5066674",
"0.5030832",
"0.50222... | 0.82706976 | 0 |
Unmap a list of list of indices, by optionally copying from src_tokens. | def unmap_with_copy(indices, src_tokens, vocab):
result = []
for ind, tokens in zip(indices, src_tokens):
words = []
for idx in ind:
if idx >= 0:
words.append(vocab.id2word[idx])
else:
idx = -idx - 1 # flip and minus 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unmap_with_copy(indices, src_tokens, vocab):\n result = []\n for ind, tokens in zip(indices, src_tokens):\n words = []\n for idx in ind:\n if idx >= 0:\n words.append(vocab.id2word[idx])\n else:\n idx = -idx - 1 # flip and minus 1\n ... | [
"0.7765528",
"0.5826469",
"0.56363213",
"0.5448848",
"0.54444957",
"0.54444957",
"0.53067505",
"0.5268874",
"0.5207399",
"0.5205985",
"0.513523",
"0.51026183",
"0.50969505",
"0.509476",
"0.5070619",
"0.5054185",
"0.5043652",
"0.5039975",
"0.503132",
"0.50096864",
"0.49697897"... | 0.7732797 | 1 |
Prune decoded sequences after EOS token. | def prune_decoded_seqs(seqs):
out = []
for s in seqs:
if EOS in s:
idx = s.index(EOS)
out += [s[:idx]]
else:
out += [s]
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune_decoded_seqs(seqs):\n out = []\n for s in seqs:\n if constant.EOS in s:\n idx = s.index(constant.EOS_TOKEN)\n out += [s[:idx]]\n else:\n out += [s]\n return out",
"def found_terminator(self):\n self.signal_filter.send((self, \"\".join(self.... | [
"0.74231493",
"0.62839097",
"0.5691633",
"0.5682872",
"0.5561191",
"0.54388773",
"0.54305106",
"0.53349864",
"0.53183734",
"0.5312966",
"0.5307029",
"0.52506787",
"0.5249625",
"0.5239699",
"0.5222222",
"0.52097696",
"0.51980585",
"0.5112395",
"0.5086395",
"0.508561",
"0.50800... | 0.71789676 | 1 |
Prune a decoded hypothesis | def prune_hyp(hyp):
if EOS_ID in hyp:
idx = hyp.index(EOS_ID)
return hyp[:idx]
else:
return hyp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune_hyp(hyp):\n if constant.EOS_ID in hyp:\n idx = hyp.index(constant.EOS_ID)\n return hyp[:idx]\n else:\n return hyp",
"def prune(i):\n\n return {'return':1, 'error':'pruning is not yet supported in this scenario'}",
"def test_drop_punctuation():\n assert TextCleaner().t... | [
"0.62943685",
"0.5706342",
"0.5314634",
"0.53097963",
"0.52454674",
"0.5243653",
"0.5196532",
"0.5147109",
"0.5140047",
"0.5127488",
"0.5127022",
"0.51262003",
"0.51261955",
"0.51068044",
"0.5106163",
"0.51031095",
"0.50984734",
"0.50973874",
"0.509119",
"0.5082139",
"0.50821... | 0.62629044 | 1 |
Sort a series of packed list, according to a ref list. Also return the original index before the sort. | def sort(packed, ref, reverse=True):
assert (isinstance(packed, tuple) or isinstance(packed, list)) and isinstance(ref, list)
packed = [ref] + [range(len(ref))] + list(packed)
sorted_packed = [list(t) for t in zip(*sorted(zip(*packed), reverse=reverse))]
return tuple(sorted_packed[1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort(packed, ref, reverse=True):\n assert (isinstance(packed, tuple) or isinstance(packed, list)) and isinstance(ref, list)\n packed = [ref] + [range(len(ref))] + list(packed)\n sorted_packed = [list(t) for t in zip(*sorted(zip(*packed), reverse=reverse))]\n return tuple(sorted_packed[1:])",
"def... | [
"0.73943746",
"0.6155156",
"0.6151719",
"0.6074487",
"0.60657084",
"0.6034968",
"0.6033133",
"0.60295117",
"0.6020848",
"0.6013301",
"0.59684956",
"0.59672886",
"0.591804",
"0.588727",
"0.5882449",
"0.5874141",
"0.5864995",
"0.5862819",
"0.58597136",
"0.58595324",
"0.58583176... | 0.7393999 | 1 |
Unsort a sorted list, based on the original idx. | def unsort(sorted_list, oidx):
assert len(sorted_list) == len(oidx), "Number of list elements must match with original indices."
_, unsorted = [list(t) for t in zip(*sorted(zip(oidx, sorted_list)))]
return unsorted | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsort(sorted_list, oidx):\n assert len(sorted_list) == len(oidx), \"Number of list elements must match with original indices.\"\n _, unsorted = [list(t) for t in zip(*sorted(zip(oidx, sorted_list)))]\n return unsorted",
"def tensor_unsort(sorted_tensor, oidx):\r\n assert sorted_tensor.size(0) ==... | [
"0.7783596",
"0.6818733",
"0.61065817",
"0.5962937",
"0.5943554",
"0.5820587",
"0.57404554",
"0.563811",
"0.563416",
"0.56334376",
"0.55671626",
"0.5566264",
"0.5473869",
"0.54344684",
"0.54342955",
"0.5432338",
"0.5411742",
"0.5395193",
"0.53906775",
"0.53750867",
"0.5373845... | 0.7812045 | 0 |
Unsort a sorted tensor on its 0th dimension, based on the original idx. | def tensor_unsort(sorted_tensor, oidx):
assert sorted_tensor.size(0) == len(oidx), "Number of list elements must match with original indices."
backidx = [x[0] for x in sorted(enumerate(oidx), key=lambda x: x[1])]
return sorted_tensor[backidx] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsort_sequence(tensor, indices, batch_first=False):\n if batch_first:\n idx = 0\n else:\n idx = 1 \n unsorted_tensor = torch.index_select(tensor, idx, indices)\n return unsorted_tensor",
"def sort(tensor, axis):\n raise NotImplementedError",
"def argsort(tensor, axis):\n ... | [
"0.7019405",
"0.61988467",
"0.60928017",
"0.6072815",
"0.58630306",
"0.5860643",
"0.5847685",
"0.5809627",
"0.5711877",
"0.56874275",
"0.567761",
"0.55958784",
"0.55441666",
"0.5526464",
"0.5520309",
"0.550939",
"0.5493226",
"0.54318625",
"0.54222506",
"0.54066485",
"0.535638... | 0.8392014 | 0 |
Return element effective area and system temperauture at given frequency. Effective area and temperature values for SKA1LOW provided by Eloy de Lera Acedo (eloy at mrao dot cam dot ac dot uk). | def element_area_and_temperature(freq_hz):
# Element noise data.
noise_data = {
'freqs': [0.05e9, 0.07e9, 0.11e9, 0.17e9, 0.25e9, 0.35e9,
0.45e9, 0.55e9, 0.65e9],
'a_eff': [1.8791, 1.8791, 1.8694, 1.3193, 0.6080, 0.2956,
0.2046, 0.1384, 0.0792],
't_sys... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_effective_area(freq_hz):\n freqs = np.array([0.05e9, 0.07e9, 0.11e9, 0.17e9, 0.25e9, 0.35e9, 0.45e9,\n 0.55e9, 0.65e9])\n a_eff = np.array([1.8791, 1.8791, 1.8694, 1.3193, 0.6080, 0.2956, 0.2046,\n 0.1384, 0.0792])\n f_cut = 2\n f1 = interp1d(np.log... | [
"0.63082397",
"0.6119127",
"0.59817386",
"0.57220274",
"0.56170285",
"0.56122315",
"0.5604102",
"0.5583277",
"0.5569435",
"0.551391",
"0.5499524",
"0.54950035",
"0.5493523",
"0.54560786",
"0.54074943",
"0.5355427",
"0.53410304",
"0.5318276",
"0.5307733",
"0.527758",
"0.525897... | 0.7509381 | 0 |
Evaluate the station StokesI noise RMS, in Jy, for the given observation length sampled with the specified number of times. | def evaluate_scaled_noise_rms(freq_hz, num_times, bandwidth_hz=100e3, eta=1.0,
obs_length_h=1000.0, num_antennas=256):
k_B = 1.38064852e-23
t_acc = (obs_length_h * 3600.0) / num_times
a_eff, t_sys = element_area_and_temperature(freq_hz)
# Single receiver polarisation SEFD.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def noise(self):\n # Extract parameters\n pzs = self.params[0]\n # retrieve number of galaxies in each bins\n ngals = np.array([pz.gals_per_steradian for pz in pzs])\n if isinstance(self.config[\"sigma_e\"], list):\n sigma_e = np.array([s for s in self.config[\"sigma_e... | [
"0.53228945",
"0.52257186",
"0.51912713",
"0.5190851",
"0.5190654",
"0.51324785",
"0.51320785",
"0.51125735",
"0.5097798",
"0.5073216",
"0.50730926",
"0.5067569",
"0.50560105",
"0.5049428",
"0.50481635",
"0.5047616",
"0.5032398",
"0.502538",
"0.50104713",
"0.50014496",
"0.499... | 0.612295 | 0 |
Run with atomic (synchronous) I/O. | def atomic_io(cmd, in_file, out_file, err_file, prog=None):
with open(in_file, 'r') as inp, open(out_file, 'w') as out, open(err_file, 'w') as err:
p = subprocess.Popen(
cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=err)
while True:
line = inp.readline()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync():\n while read():\n pause()\n while not read():\n pass",
"def sync() -> None:",
"def do_sync(self):\n raise NotImplementedError() # pragma: no cover",
"async def run(self) -> None:",
"async def run(self) -> None:",
"def run(self):\n\n if (self.action == 're... | [
"0.6179125",
"0.6020461",
"0.58325493",
"0.5815653",
"0.5815653",
"0.58032286",
"0.572875",
"0.5709031",
"0.5575473",
"0.5538008",
"0.55006826",
"0.5500573",
"0.54680437",
"0.5465855",
"0.5463989",
"0.5452345",
"0.5451186",
"0.5441583",
"0.5426505",
"0.5414212",
"0.54075414",... | 0.6220305 | 0 |
Write lines to gzipped file. | def write_gzfile(lines, f):
out = gzip.open(f, 'wb')
for line in lines:
out.write('{}\n'.format(line))
out.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_body_in_gz_file(self):\r\n if self.arguments['--out']:\r\n self.file = gzip.open(self.arguments['--out'] + '.gz', \"a+b\")\r\n for list_item in self.list_of_body_objects:\r\n self.file.write(list_item.line.encode('utf-8'))\r\n self.file.close()\r\n ... | [
"0.7393402",
"0.68930703",
"0.65364593",
"0.6371733",
"0.6351013",
"0.63242877",
"0.6177164",
"0.5866167",
"0.58031136",
"0.5798468",
"0.57628024",
"0.57125217",
"0.57054317",
"0.5695627",
"0.5643752",
"0.5627625",
"0.5539969",
"0.5519983",
"0.5517884",
"0.5516543",
"0.551551... | 0.83401835 | 0 |
Gets original base image from GCP disk labels | def get_base_image_from_labels(user_disk):
labels = ['cf_version', 'branch', 'target', 'build_id']
disk_labels = user_disk.extra['labels']
if all(label in disk_labels for label in labels):
cf_version = disk_labels['cf_version']
branch = disk_labels['branch']
target = disk_labels['t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_imagebase(self):\n pass",
"def get_label(client, label):\n image_name = get_image_name()\n image = client.images.get(image_name)\n try:\n return image.labels[label]\n except KeyError:\n raise Exception(f\"Image should have a label '{label}'\")",
"def set_base_image_labe... | [
"0.62623155",
"0.6212518",
"0.60614246",
"0.5939277",
"0.5862923",
"0.586117",
"0.58254945",
"0.5726188",
"0.57218724",
"0.57203144",
"0.5708236",
"0.5703373",
"0.56474024",
"0.56433713",
"0.5559755",
"0.54991823",
"0.5469733",
"0.5429551",
"0.5411337",
"0.5406208",
"0.538375... | 0.71238923 | 0 |
Sets disk labels with base image version data | def set_base_image_labels(driver, user_disk, img_name, branch, target):
dashes = [i for i, c in enumerate(img_name) if c=='-']
cf_version = img_name[dashes[0]+1:dashes[3]]
build_id = img_name[dashes[-1]+1:]
driver.ex_set_volume_labels(user_disk,
{'cf_version': cf_version, 'branch': branch,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LabelDisks(self):\n pass",
"def get_base_image_from_labels(user_disk):\n\n labels = ['cf_version', 'branch', 'target', 'build_id']\n disk_labels = user_disk.extra['labels']\n\n if all(label in disk_labels for label in labels):\n cf_version = disk_labels['cf_version']\n branch = disk... | [
"0.6180871",
"0.607537",
"0.5954446",
"0.5875167",
"0.56598586",
"0.5625165",
"0.562511",
"0.55189824",
"0.5503701",
"0.54577065",
"0.5441069",
"0.5421237",
"0.5354223",
"0.5348385",
"0.5344549",
"0.532693",
"0.5318588",
"0.52759075",
"0.52595526",
"0.52081156",
"0.5206245",
... | 0.806748 | 0 |
Restores instance with existing user disk and original base image. Creates a new instance with latest image if user disk doesn't exist. Stores runtime data in external GCP disk. Launches Cuttlefish if creation is successful. | def create_or_restore_instance(driver,
user_id, sig_server_addr, sig_server_port, zone='us-central1-b',
tags=[], branch='aosp-master', target='aosp_cf_x86_phone-userdebug'):
# SETUP
target = target.replace('_','-')
instance_name = f'halyard-{user_id}'
disk_name = f'halyard-user-{user_id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n logging.basicConfig(level=logging.INFO)\n\n # Load GCE settings.\n settings = json.loads(open(gce.SETTINGS_FILE, 'r').read())\n\n # Perform OAuth 2.0 authorization flow.\n flow = flow_from_clientsecrets(\n settings['client_secrets'], scope=settings['compute_scope'])\n storage = Storage(s... | [
"0.650147",
"0.6286748",
"0.5891288",
"0.580195",
"0.5792303",
"0.57869005",
"0.5755676",
"0.570606",
"0.56912977",
"0.5580849",
"0.55682856",
"0.55541366",
"0.55115134",
"0.55076903",
"0.5507624",
"0.54733646",
"0.54676104",
"0.5429465",
"0.54149663",
"0.5410179",
"0.5408384... | 0.65199435 | 0 |
Launch cvd on given instance and connect to operator on given address. If use_user_disk is True it uses existing user data disk. | def launch_cvd(instance_name, zone, sig_server_addr, sig_server_port, use_user_disk=True):
cuttlefish_dir = '/usr/local/share/cuttlefish'
user_data_dir = '/mnt/user_data'
launch_command = f'gcloud compute ssh --zone={zone} {instance_name} -- '
if use_user_disk:
launch_command += f'HOME={user_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli(ctx, host, user, no_ask):\n from ._ssh import open_ssh\n from .vdi import vdi_ctl\n\n try:\n ssh, ssh_cfg = open_ssh(host, user, no_ask=no_ask)\n except:\n click.echo('Failed to connect to \"{}{}\"'.format(user+'@' if user else '', host))\n ctx.exit()\n\n ctl = vdi_ctl(s... | [
"0.5244429",
"0.5210779",
"0.5150519",
"0.5033519",
"0.4963774",
"0.4939614",
"0.49388123",
"0.49304688",
"0.48421752",
"0.48179963",
"0.4735537",
"0.47300255",
"0.47249347",
"0.47242877",
"0.47227377",
"0.4713746",
"0.4678872",
"0.46747953",
"0.46596444",
"0.46247965",
"0.46... | 0.6554882 | 0 |
Outputs a pass message. | def success():
sys.stdout.write('%s[ pass ]%s\n' % (colors.GREEN, colors.RESET)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_pass():\n return passlocker.display_passlocker()",
"def pass_cmd(self, password):\n print_debug(\"Executing PASS\")\n command = \"PASS %s\\r\\n\" % password\n msg_rec = self.send_and_log(self.s, command)\n return msg_rec",
"def pass_cmd(var, wrapper, message):\n d... | [
"0.6533709",
"0.6387375",
"0.63657904",
"0.60835224",
"0.58880526",
"0.5854719",
"0.56878513",
"0.5518864",
"0.549284",
"0.54444295",
"0.5432577",
"0.5409539",
"0.540342",
"0.53760237",
"0.5374364",
"0.5370972",
"0.53020775",
"0.52986443",
"0.5289995",
"0.5280903",
"0.5241709... | 0.6475748 | 1 |
Outputs an fail message. | def fail():
sys.stdout.write('%s[ fail ]%s\n' % (colors.RED, colors.RESET)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_failure(msg):\n\n tf.print(BColors.FAIL + msg + BColors.ENDC, output_stream=sys.stderr)\n sys.exit(1)",
"def format_fail(self, *args):\n if self._pretty:\n return self.format_multiline_message(*args, color='red', start='[FAIL] ', multiline=' ~~ ')\n return self.forma... | [
"0.7514068",
"0.74072546",
"0.7397076",
"0.73031294",
"0.7269235",
"0.7154893",
"0.7136196",
"0.7082024",
"0.6982687",
"0.6929366",
"0.69052637",
"0.6873672",
"0.6737351",
"0.6726525",
"0.6694967",
"0.6685421",
"0.66659385",
"0.6665027",
"0.6637748",
"0.6593092",
"0.65906334"... | 0.77564895 | 0 |
Displays a pinwheel animation. | def pin_wheel(self):
spinner = '|/-\\'
sys.stdout.write('%s \r' % spinner[self.last_spin])
sys.stdout.flush()
self.last_spin += 1
if self.last_spin > len(spinner) - 1:
self.last_spin = 0
time.sleep(.2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showWheel(self):\n\n self._movie.start()\n self.show()",
"def wheel(ticks):\n m = PyMouse()\n m.scroll(ticks)",
"def draw_wheel():\r\n\touter_radius = 1\r\n\tthickness = .4\r\n\tif wireframe:\r\n\t\tglutWireTorus(thickness,outer_radius - thickness,8,8)\r\n\telse:\r\n\t\tglutSolidTorus(t... | [
"0.61911505",
"0.6170605",
"0.5993172",
"0.5982682",
"0.5976809",
"0.59570134",
"0.5858709",
"0.56583893",
"0.5499651",
"0.5490826",
"0.54692054",
"0.54301286",
"0.5411563",
"0.5363805",
"0.5338731",
"0.5228539",
"0.51571614",
"0.51553303",
"0.51543134",
"0.51374495",
"0.5130... | 0.64760447 | 0 |
Displays a moving bar animation. | def moving_bar(self, color='reset'):
progress_pill = ('%s%s%s' % (colors.GREEN, '==', colors.RESET))
sys.stdout.write(' [ %-*s%s%*s ]\r' %
(self.left_pad,'', progress_pill, self.right_pad, ''))
sys.stdout.flush()
if self.left_pad == 10:
self.direction = 'left'
elif self.right_pad == 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showBar(self):\n track = 0\n dot_symbols = [\" \" for i in range(self.width)]\n sys.stdout.write(\"{}\".format(''.join(dot_symbols)) + \"\\r\")\n while self.spin_on == True:\n dot_symbols[track] = \".\"\n sys.stdout.write(\"{}\".format(self.c.colorText(''.join(... | [
"0.68874234",
"0.65785116",
"0.6487448",
"0.6467881",
"0.6446335",
"0.6423943",
"0.6403058",
"0.6329227",
"0.62340575",
"0.60879815",
"0.6084871",
"0.6059303",
"0.6004077",
"0.5986167",
"0.5986084",
"0.5953788",
"0.59535575",
"0.5952374",
"0.59334844",
"0.58886915",
"0.588869... | 0.71905917 | 0 |
extractsms extract SMS messages from BeautifulSoup tree of Google Voice SMS HTML. Output is a list of dictionaries, one per message. | def extractsms(htmlsms) :
msgitems = [] # accum message items here
# Extract all conversations by searching for a DIV with an ID at top level.
tree = BeautifulSoup.BeautifulSoup(htmlsms) # parse HTML into tree
conversations = tree.findAll("div",attrs={"id" : True},recursive=False)
for con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extractsms(htmlsms) :\r\n msgitems = []\t\t\t\t\t\t\t\t\t\t# accum message items here\r\n #\tExtract all conversations by searching for a DIV with an ID at top level.\r\n tree = BeautifulSoup.BeautifulSoup(htmlsms)\t\t\t# parse HTML into tree\r\n conversations = tree.findAll(\"div\",attrs={\"id\" :... | [
"0.85631365",
"0.80607885",
"0.67401177",
"0.57369083",
"0.5466644",
"0.5270877",
"0.5243815",
"0.5176082",
"0.51244897",
"0.5115617",
"0.51058173",
"0.5049693",
"0.5028105",
"0.49668315",
"0.49312085",
"0.492002",
"0.48814866",
"0.48814815",
"0.48098814",
"0.4764823",
"0.476... | 0.8557089 | 1 |
Get mysql connection from connection pool. | def __get_connection():
# 根据配置文件创建连接池
if not Mysql.__mysql_pool:
Mysql.__mysql_pool = PooledDB(
creator=MySQLdb,
use_unicode=False,
cursorclass=DictCursor,
db=sqlconf.MysqlConfig['db'],
host=sqlconf.MysqlConfig['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_conn(cls):\n\n if not cls.conn or not cls.conn.open:\n cls.connect()\n\n try:\n cls.conn.ping() # ping to test if the current conn is working\n except MySQLdb.OperationalError:\n cls.connect()\n\n return cls.conn",
"def get_connection(self, se... | [
"0.7218872",
"0.71847075",
"0.7169159",
"0.7164174",
"0.7110116",
"0.7051639",
"0.6995694",
"0.6995694",
"0.696456",
"0.6915348",
"0.68909955",
"0.6877921",
"0.68593645",
"0.68583244",
"0.68493176",
"0.6820597",
"0.6819578",
"0.68025225",
"0.6796151",
"0.6777738",
"0.67665327... | 0.8464691 | 0 |
Get all sql command execute result. | def get_all(self, sql_command, cmd_param=None):
if cmd_param:
count = self._mysql_cursor.execute(sql_command, cmd_param)
else:
count = self._mysql_cursor.execute(sql_command)
if count:
sql_result = self._mysql_cursor.fetchall()
else:
sql_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(self,sql):\n # self.results = self.execute_silent(sql)\n # return self.results\n # sql = self.format_sql(sql, **kwargs)\n sql_list = sql.split(';')\n for stmt in sql_list:\n if stmt:\n stmt = stmt.strip()\n if len(stmt) < 10:\n... | [
"0.7270337",
"0.718886",
"0.7173971",
"0.6977881",
"0.6850584",
"0.682636",
"0.6797712",
"0.6719062",
"0.67161405",
"0.6702842",
"0.66651267",
"0.6656862",
"0.6580391",
"0.6572462",
"0.65271133",
"0.6501797",
"0.64878494",
"0.6472822",
"0.64689815",
"0.64672655",
"0.6453113",... | 0.7348025 | 0 |
Opens the csv file containing GitHub issue data and loads it into a row based table where the keys are the date of the data. | def load_issues(issues_path):
issues_dict = {}
with open(issues_path) as issues:
issue_rdr = csv.DictReader(issues)
for row in issue_rdr:
issues_dict[row["Date"]] = row
return issues_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_from_csv(self) -> None:\n logging.info('import_from_csv')\n if self.target_table and str(self.target_table).lower() in [\"issue\", \"version\"]:\n if self.file_path and exists(self.file_path):\n # Read CSV file\n csv_data = pd.read_csv(self.file_pat... | [
"0.6934556",
"0.57575256",
"0.5747945",
"0.5690625",
"0.56827134",
"0.56786096",
"0.5624858",
"0.5555852",
"0.5554984",
"0.55543363",
"0.55271506",
"0.55268043",
"0.5511146",
"0.549549",
"0.54830617",
"0.5474493",
"0.5450139",
"0.5442186",
"0.5433848",
"0.543026",
"0.5428193"... | 0.70110345 | 0 |
Primary function of the script. Loads both the entropy data and the issues data. Next, using keys from the Date field of the entropy file, pulls out the fields of interest from the issues table and merges the new data into the row data from the entropy file. Finally, the merged row is written to the specified output cs... | def github_merge(config_data):
issues = load_issues(config_data.issues_path)
with open(config_data.entropy_path) as entropy:
entropy_rdr = csv.reader(entropy)
with open(config_data.merged_path, 'w', newline='') as merge:
merge_wrtr = csv.writer(merge)
entropy_hdrs = next(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_data_main(data1,data2,lookup,foutput):\n\n # Get the maximum number of ortholog probesets we'll have to append\n max_orthologs = 0\n for probe_set_id in data1.keys():\n max_orthologs = max(max_orthologs,len(lookup(probe_set_id)))\n logging.debug(\"Max_orthologs = %d\" % max_orthologs... | [
"0.62435937",
"0.59672475",
"0.5966962",
"0.5862723",
"0.5792813",
"0.5754222",
"0.5714863",
"0.5609327",
"0.5606977",
"0.5558606",
"0.54883033",
"0.546936",
"0.54607743",
"0.54476184",
"0.5399827",
"0.53947705",
"0.5368525",
"0.5364413",
"0.53116685",
"0.5294304",
"0.5289653... | 0.6462662 | 0 |
Return a copy of the expression, but with a new name. | def with_name(self, name):
return self.func(name, self.expr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n\t\t# Will not copy the name\n\t\treturn LpAffineExpression(self)",
"def use_named_expression(self, name):\n return self.named_expression[name]",
"def declare_named_expression(self, name):\n self.named_expression[name] = NamedCalcObject(name, self.setup)",
"def setResultsNameIn... | [
"0.6828989",
"0.61215144",
"0.6063665",
"0.60496444",
"0.6018465",
"0.5864303",
"0.58027977",
"0.575386",
"0.573768",
"0.56396246",
"0.56071043",
"0.5576536",
"0.5576347",
"0.5536932",
"0.5527453",
"0.55168205",
"0.54969007",
"0.54864925",
"0.5459957",
"0.5445358",
"0.5416862... | 0.6406098 | 1 |
NamedMatrix(name, n, m) NamedMatrix(name, n, m, expr) NamedMatrix(name) if name is already a matrix NamedMatrix(name, expr) if name or expr is already a matrix | def __new__(cls, *args, **kwargs):
self = object.__new__(cls)
if not (1 <= len(args) <= 4):
TypeError('1 to 4 positional arguments are required')
args = list(args)
name = args.pop(0)
if isinstance(name, (sp.MatrixBase, sp.MatrixExpr)):
if len(args) >= 2:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_matrix(self, name, mat):\n self._matrices[name] = mat",
"def isMatrix(M):\r\n if type(M) == matrix:\r\n return M\r\n elif type(M) == np.ndarray:\r\n return matrix(M)\r\n else:\r\n raise Exception('Unknown input format. Should be matrix or numpy array')",
"def matrix... | [
"0.6082356",
"0.595766",
"0.59328157",
"0.58405846",
"0.58405846",
"0.57949865",
"0.57935476",
"0.5749493",
"0.5568579",
"0.5521704",
"0.5518138",
"0.55165595",
"0.5430711",
"0.5400214",
"0.5329109",
"0.53207344",
"0.5312372",
"0.52925265",
"0.52826506",
"0.52763253",
"0.5270... | 0.70667183 | 0 |
This function takes the last slice from a input wav file | def getlastslice(inputtaken):
output = inputtaken.split('.')[0] + 'last.wav'
with contextlib.closing(wave.open(inputtaken, 'r')) as framesget:
frames = framesget.getnframes()
rate = framesget.getframerate()
duration = frames / float(rate)#duration of the input file
duration1 = durati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_sample(self) -> InternalSample:",
"def getLastWaveIdentifier(self): \n return self.lastWaveIdentifier",
"def slice_signal(file, window_size, stride, sample_rate):\n wav, sr = librosa.load(file, sr=sample_rate)\n hop = int(window_size * stride)\n slices = []\n for end_idx in range(wi... | [
"0.6490543",
"0.6421529",
"0.60857016",
"0.6024156",
"0.58576757",
"0.5755279",
"0.57196957",
"0.5696692",
"0.5644231",
"0.56284064",
"0.56062734",
"0.557685",
"0.55589366",
"0.55497855",
"0.5503969",
"0.5492631",
"0.5453783",
"0.5431531",
"0.54260755",
"0.53964686",
"0.53728... | 0.83162165 | 0 |
This function checks for the endsilence of an input wav file | def checkendsilence(inputgiven):
output = getlastslice(inputgiven)
wave_file = wave.open(output, "r")
for i in range(wave_file.getnframes()):
current_frame = wave_file.readframes(1)
unpacked_signed_value = struct.unpack("<h", current_frame)
if abs(unpacked_signed_value[0]) > 500:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_silence_audio() -> None:\n # Read the wav file and get rate and list of data\n rate, data = scipy.io.wavfile.read('Test.wav')\n\n # Create list for data of amended wav file\n data2 = []\n\n # Loop through data of original file and add data that doesn't meed condition: values >= -10 and <=... | [
"0.6899039",
"0.6475046",
"0.62194455",
"0.61648184",
"0.61068875",
"0.60590583",
"0.601274",
"0.5995834",
"0.5858971",
"0.5791947",
"0.57443935",
"0.56995565",
"0.56875277",
"0.56869966",
"0.5658695",
"0.5636305",
"0.5635189",
"0.5624359",
"0.55889165",
"0.55424464",
"0.5529... | 0.7193475 | 0 |
This function returns the maximum frequency of a wav file | def checkfrequency(inputgiven):
data_size = 40000
wav_file = wave.open(inputgiven, 'r')
data = wav_file.readframes(data_size)
wav_file.close()
data = struct.unpack('{n}h'.format(n=data_size), data)
print max(data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_frequency(sig, FS):\n\n f, fs = plotfft(sig, FS)\n t = np.cumsum(fs)\n\n try:\n ind_mag = np.where(t > t[-1]*0.95)[0][0]\n except:\n ind_mag = np.argmax(t)\n f_max = f[ind_mag]\n\n return f_max",
"def calculateMaxAmplitude(sampleWidth: int) -> int:\n return 2 ** (sample... | [
"0.6912686",
"0.672116",
"0.67035365",
"0.6643082",
"0.6489778",
"0.64281195",
"0.63209593",
"0.631521",
"0.63116014",
"0.63099647",
"0.6278965",
"0.6268677",
"0.6262186",
"0.6220878",
"0.6216497",
"0.61629194",
"0.61583596",
"0.61480504",
"0.6135885",
"0.61169475",
"0.609151... | 0.8120812 | 0 |
Return the Voigt line shape at x with Lorentzian component FWHM l_fwhm and Gaussian component FWHM g_fwhm. | def _Voigt(self, x, g_fwhm, l_fwhm, semi_amp=1, center=0.0):
sigma = g_fwhm / np.sqrt(2.0 * np.log(2.0))
return semi_amp * np.real(wofz(((x-center) + 1j*l_fwhm)/(sigma*np.sqrt(2.0)))) / (sigma * np.sqrt(2.0*np.pi)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _width_v_l_l(model: SingleRhNeutrinoModel, genl: Generation):\n\n sw = parameters.sin_theta_weak\n if model.gen == genl:\n c1f = 0.25 * (1 + 4 * sw**2 + 8 * sw**4)\n c2f = 0.5 * sw**2 * (2 * sw**2 + 1)\n else:\n c1f = 0.25 * (1 - 4 * sw**2 + 8 * sw**4)\n c2f = 0.5 * sw**2 *... | [
"0.5555841",
"0.5474631",
"0.5346495",
"0.5342706",
"0.53148866",
"0.5204533",
"0.5180128",
"0.51459664",
"0.50538915",
"0.50438",
"0.49874166",
"0.49584156",
"0.4931214",
"0.49311644",
"0.49124017",
"0.4910904",
"0.49030274",
"0.48639503",
"0.4838028",
"0.48015752",
"0.48009... | 0.6708908 | 1 |
Sets for a flow identified by an 5tuple (IP header) the transmit power to be used. | def set_per_flow_tx_power(flowId, txPower):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_power(self, power):\n print('Setting santec power to %.4f mW' % power)\n self.santec1.write(\"LP %.2f\" % power)\n self.santec2.write(\"LP %.2f\" % power)\n self.santec3.write(\"LP %.2f\" % power)\n self.santec4.write(\"LP %.2f\" % power)",
"def set_power(self, value):\... | [
"0.6299827",
"0.6219891",
"0.5942382",
"0.5842887",
"0.5838942",
"0.581138",
"0.56288433",
"0.5573606",
"0.554147",
"0.5520319",
"0.54832435",
"0.54381996",
"0.5430382",
"0.54296136",
"0.5398984",
"0.5375935",
"0.5370444",
"0.53645325",
"0.53645325",
"0.536407",
"0.5359443",
... | 0.68173486 | 0 |
Remove any entries in the transmit power table. | def clean_per_flow_tx_power_table():
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_table(self):\n for ss in self.spectrae:\n ss.tau[('H',1,1215)] = np.array([0])",
"def forget(self):\n self.ingress_tbl.clear()\n self.rootsw_tbl.clear()",
"def removeAll(self):\n self.pDict.clear()",
"def removeall(self):\n\n # If there used to be a key,... | [
"0.6556452",
"0.6478911",
"0.61770225",
"0.6140857",
"0.61184597",
"0.59511065",
"0.59249556",
"0.5917613",
"0.58931273",
"0.58559555",
"0.58552325",
"0.5847262",
"0.5804831",
"0.57946503",
"0.5782803",
"0.57689965",
"0.5762728",
"0.5752183",
"0.57491875",
"0.5719127",
"0.569... | 0.7215524 | 0 |
Return the transmit power level used for the given flow. | def get_per_flow_tx_power(flowId):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tx_power(self) -> int:\n # Follow table 10 truth table from the datasheet for determining power\n # level from the individual PA level bits and output power register.\n pa0 = self.pa_0_on\n pa1 = self.pa_1_on\n pa2 = self.pa_2_on\n current_output_power = self.output_po... | [
"0.6838552",
"0.6698188",
"0.66946507",
"0.6537564",
"0.64869475",
"0.64515215",
"0.643437",
"0.6391349",
"0.63744056",
"0.63702273",
"0.63190705",
"0.6302437",
"0.6285097",
"0.62271345",
"0.6217965",
"0.617573",
"0.6145806",
"0.6098625",
"0.6094632",
"0.607096",
"0.60708654"... | 0.77277094 | 0 |
Return the whole transmit power table. | def get_per_flow_tx_power_table():
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weighted_transmissionData(self, port='Substrate'):\n\n base = self.sims[0].conf['General']['results_dir']\n self.log.info('Computing spectrally weighted transmission data for group at %s' % base)\n abs_vals = np.zeros(self.num_sims)\n ref_vals = np.zeros(self.num_sims)\n tran... | [
"0.5725576",
"0.5693832",
"0.56852573",
"0.5606632",
"0.55089325",
"0.548737",
"0.5486363",
"0.5467853",
"0.54589367",
"0.54225653",
"0.5411871",
"0.53868026",
"0.5354112",
"0.52954817",
"0.52800566",
"0.5270804",
"0.5247777",
"0.52197194",
"0.5214796",
"0.5194893",
"0.519429... | 0.76034933 | 0 |
Install new WiFi MAC Processor | def install_mac_processor(interface, mac_profile):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_mac_processor(interface, mac_profile):\n pass",
"def install_firmware(self, image_path):\n \"\"\"Not Implement\"\"\"\n return False",
"def setup_wifi(self, ssid: str, password: str) -> str:\n return self._req_post(self._URLS['SetupWIFI'], data={\"wrlEn\": 1, \"wrlEn_5g\": 1, ... | [
"0.65002745",
"0.59423065",
"0.59059274",
"0.5870018",
"0.57082283",
"0.5684837",
"0.568396",
"0.5671544",
"0.5653979",
"0.55288523",
"0.55197555",
"0.5474424",
"0.54575396",
"0.5414608",
"0.540458",
"0.5381368",
"0.53735024",
"0.53688365",
"0.53684163",
"0.5343969",
"0.53109... | 0.74022746 | 0 |
Update WiFi MAC Processor | def update_mac_processor(interface, mac_profile):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_firmware(self) -> str:",
"def command_update_hw(self, cmd):\n # TODO\n pass",
"def change_mac(interface, mac):\r\n print(\"Changing MAC-address for \" + interface + \" to \" + mac)\r\n subprocess.call([\"sudo\", \"ifconfig\", interface, \"down\"])\r\n subprocess.call([\"sudo\"... | [
"0.6479097",
"0.6172109",
"0.6101384",
"0.60551757",
"0.5869172",
"0.5736733",
"0.57205206",
"0.57199544",
"0.56876427",
"0.5599858",
"0.5545798",
"0.5520598",
"0.5476568",
"0.5462841",
"0.54626304",
"0.54598135",
"0.54418397",
"0.54009503",
"0.5385496",
"0.5336746",
"0.53325... | 0.78946596 | 0 |
Uninstall WiFi MAC Processor | def uninstall_mac_processor(interface, mac_profile):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_device(hass: HomeAssistant, mac: str):\n registry = dr.async_get(hass)\n device = registry.async_get_device({(DOMAIN, mac)}, None)\n if device:\n registry.async_remove_device(device.id)",
"def uninstall_platform(self):\n if self.status: self.status.Warning(\"Uninstall Function N... | [
"0.64639676",
"0.62972814",
"0.6150645",
"0.6081423",
"0.60591906",
"0.6056301",
"0.6036048",
"0.6027187",
"0.5933446",
"0.5876429",
"0.5855578",
"0.5849019",
"0.58379954",
"0.5818854",
"0.5770058",
"0.5757176",
"0.57087994",
"0.56876934",
"0.56856394",
"0.56761456",
"0.56694... | 0.79712313 | 0 |
`data_consumer(queue, interval)` This is an EXAMPLE of the multiprocessing data consumer. You may write your own one and replace `data_consumer` in the following "main function". | def data_consumer(queue, interval, space):
while True:
data = queue.get()
logging.info("Data consumer: get data with timestamp {}.")
# print("get data: ")#,end=''
# print(data)
# print("LeftMost:",space._leftMost)
timeStamp = list(data.keys())
timeStamp = timeStamp[0]
planes = list(data.values())
pla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_consumer(q):\n while True:\n data = q.get()\n print('data found to be processed: {}'.format(data))\n processed = data * 2\n print(processed)\n\n if data is sentinel:\n break",
"def run(self) -> None:\n while self.data_incoming or len(self._queue):\n ... | [
"0.6742312",
"0.6236904",
"0.6202471",
"0.61269015",
"0.61054933",
"0.60954714",
"0.5978878",
"0.59483486",
"0.5935992",
"0.5925589",
"0.5825456",
"0.5780268",
"0.576735",
"0.5646639",
"0.56045735",
"0.55901444",
"0.55463755",
"0.55392283",
"0.5530998",
"0.55176204",
"0.55034... | 0.6376914 | 1 |
initialize the sedov problem | def init_data(my_data, rp):
msg.bold("initializing the sedov problem...")
# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
print("ERROR: patch invalid in sedov.py")
print(my_data.__class__)
sys.exit()
# get the density, mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_data(my_data, rp):\n\n msg.bold(\"initializing the sedov problem...\")\n\n # make sure that we are passed a valid patch object\n if not isinstance(my_data, patch.CellCenterData2d):\n print(my_data.__class__)\n msg.fail(\"ERROR: patch invalid in sedov.py\")\n\n\n # get the density... | [
"0.6577841",
"0.6535991",
"0.6237426",
"0.61905926",
"0.6085157",
"0.6078634",
"0.60436195",
"0.59910685",
"0.59836274",
"0.59588236",
"0.5931771",
"0.58982146",
"0.5844608",
"0.58389455",
"0.5811354",
"0.58078504",
"0.5773121",
"0.57591444",
"0.5724652",
"0.57124305",
"0.569... | 0.66379344 | 0 |
examples of how to get basic data from bbg | def examples():
# get some data for a single name
x = blp.bdp('BDEV LN Equity', 'px_last')
print(x)
print('the type of x', type(x))
print('the value of x:', x.iloc[0]['px_last'])
# get multiple data for a single name
y = blp.bdp('BDEV LN Equity', flds=['px_bid', 'px_ask'])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data():\n pass",
"def NCBIreadGBK(accession):\r\n net_handle = Entrez.efetch(db=\"nuccore\",id=str(accession),\r\n rettype='gbwithparts', retmode=\"txt\")\r\n gnome_record=SeqIO.read(net_handle, \"genbank\")\r\n net_handle.close()\r\n return gnome_reco... | [
"0.60213",
"0.6003053",
"0.58756196",
"0.58412343",
"0.5793331",
"0.5793331",
"0.5793331",
"0.56792367",
"0.56378543",
"0.5629926",
"0.56241393",
"0.5610849",
"0.5593044",
"0.5535149",
"0.5498652",
"0.54757947",
"0.5472642",
"0.5462802",
"0.5459633",
"0.5446893",
"0.5446893",... | 0.604926 | 0 |
function to get bond data from bloomberg using tickers in an excel sheet. | def get_bonds():
print('getting bond data...')
# securtiyList = ['US29265WAA62 Corp', 'XS1713463559 Corp', 'XS2000719992 Corp', 'XS0954675129 Corp', 'XS0954675129 Corp']
fieldList = ['ticker', 'coupon', 'nxt_call_dt', 'final_maturity',
'mty_typ', 'px_mid', 'z_sprd_mid', 'yas_ispread',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_trade_data(back_days=20, candle_interval=\"H1\", bb_period=50):\n\n NY_time = datetime.datetime.utcnow() - datetime.timedelta(hours=5)\n back_days = datetime.timedelta(days=back_days)\n start_date = (NY_time - back_days).isoformat(\"T\") + \"Z\"\n cr = ot.CandleRequest()\n res = cr.get_list(... | [
"0.67297024",
"0.63793516",
"0.6141215",
"0.60692215",
"0.6057437",
"0.6052368",
"0.6017047",
"0.5958853",
"0.58501637",
"0.58350307",
"0.57695097",
"0.5734463",
"0.57212734",
"0.571132",
"0.568195",
"0.5649128",
"0.56342345",
"0.5605751",
"0.5593089",
"0.5590062",
"0.5567499... | 0.76498026 | 0 |
Scores snippets given a scorer. | def score_snippets(snippets, scorer):
snippet_expressions = [snippet.embedding for snippet in snippets]
all_snippet_embeddings = torch.stack(snippet_expressions, dim=1)
scores = torch.t(torch.mm(torch.t(scorer), all_snippet_embeddings))
if scores.size()[0] != len(snippets):
raise ValueError("G... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_scores(self, *scorers):\n if self.nodes[0]:\n list_ = self.nodes\n else:\n list_ = self.reaction_trees\n\n for idx, item in enumerate(list_):\n scores = {repr(scorer): scorer(item) for scorer in scorers}\n self.all_scores[idx].update(scor... | [
"0.64099026",
"0.6057886",
"0.58227915",
"0.5741622",
"0.57009935",
"0.5684053",
"0.56781566",
"0.56548613",
"0.5542643",
"0.5518692",
"0.5513631",
"0.55130446",
"0.5473554",
"0.54706085",
"0.5453164",
"0.54478663",
"0.54078543",
"0.5395537",
"0.53408027",
"0.5319549",
"0.531... | 0.75195915 | 0 |
Constructs a token predictor given the parameters. | def construct_token_predictor(params,
vocabulary,
utterance_attention_key_size,
schema_attention_key_size,
snippet_size,
anonymizer=None):
if not anonymizer and not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_tokens(self, tokens):\n return",
"def __init__(self, tokens):\n self.mdl = self.train(tokens)",
"def __init__(self, tokens):\n self.mdl = self.train(tokens)",
"def create() -> 'Tokenizer':\n token_op_table = [\n EOS,\n op.Concat,\n op.C... | [
"0.648854",
"0.64276665",
"0.64276665",
"0.61235726",
"0.60195225",
"0.59540266",
"0.591449",
"0.5831747",
"0.57970756",
"0.579542",
"0.57842773",
"0.576753",
"0.57559925",
"0.57378376",
"0.5734016",
"0.5715496",
"0.5709239",
"0.5709239",
"0.5709239",
"0.56923544",
"0.5691303... | 0.74667805 | 0 |
Load building data into the database from the processed shapefile. | def from_shapefile(strict=False, progress=True, verbose=False, **kwargs):
building_shp = get_processed_data_file(os.path.join('buildings',
'buildings.shp'))
mapping = LayerMapping(Building, building_shp, building_mapping,
transfo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(self):\n \n # create db with empty tables\n dbpath, config = self.setup()\n \n # avoid work if setup decided db exists and build can be skipped\n if dbpath is None:\n return \n \n # check prerequisite files \... | [
"0.64657485",
"0.63184285",
"0.62166226",
"0.6114319",
"0.601293",
"0.59681946",
"0.59058803",
"0.5826819",
"0.58155465",
"0.57623595",
"0.57554144",
"0.5744754",
"0.5733472",
"0.57146865",
"0.5693177",
"0.5692895",
"0.5669933",
"0.56547725",
"0.56285757",
"0.56207395",
"0.55... | 0.6375167 | 1 |
List all usage details of the subscription | def cli_consumption_list_usage(client, invoice_name=None, billing_period_name=None, top=None, include_additional_properties=False, include_meter_details=False, start_date=None, end_date=None):
if include_additional_properties and include_meter_details:
expand = 'additionalProperties,meterDetails'
elif i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUsageInfo(self):\n return self.jsonRequest(\"/api/v1/usage\", { \"apiKey\": self._apiKey })",
"def list(cls, **kwargs):\n response = Yola().list_subscriptions(**kwargs)\n return [cls(**sub) for sub in response['results']]",
"def getAllSubscriptions(self):\n return self.reques... | [
"0.6745734",
"0.64215827",
"0.6382752",
"0.63634324",
"0.6341067",
"0.62802404",
"0.62371355",
"0.6210107",
"0.62015396",
"0.6195449",
"0.61619675",
"0.61604875",
"0.6100262",
"0.60542333",
"0.60002846",
"0.5973317",
"0.5973151",
"0.593546",
"0.5905405",
"0.5887627",
"0.58875... | 0.64977574 | 1 |
Return the date of last SACPI entry day + 5 months | def _get_first_end_date(self):
ins = acm.FInstrument['SACPI']
market = "internal"
start_year = acm.Time.DateAddDelta(acm.Time.FirstDayOfYear(self.start_date), 0, 0, -1)
this_year_prices = acm.FPrice.Select("instrument='%s' and market='%s' and day>'%s' and day<'%s'"
% (in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_month_day():\r\n return (datetime.now().replace(day=1) + relativedelta(months=1) + timedelta(days=-1)).strftime(\r\n '%d-%m-%Y')",
"def last_month():\n return datetime.now() + relativedelta(months=-1)",
"def max_drawdown_date(self) -> dt.date:\n mdd_date = (self.tsdf / self.tsdf.ex... | [
"0.6461281",
"0.60802233",
"0.5939588",
"0.59278756",
"0.5841653",
"0.58129823",
"0.5812028",
"0.57855666",
"0.5779908",
"0.57398164",
"0.5734636",
"0.57267845",
"0.57267845",
"0.57261086",
"0.55936295",
"0.5569988",
"0.55674237",
"0.55626094",
"0.55486155",
"0.5507776",
"0.5... | 0.6318057 | 1 |
cppstd must be a number | def test_check_cppstd_type():
conanfile = ConanFileMock(MockSettings({}))
with pytest.raises(ConanException) as exc:
check_min_cppstd(conanfile, "gnu17", False)
assert "cppstd parameter must be a number", str(exc) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_min_cppstd_from_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", \"17\", \"libstdc++\")\n assert valid_min_cppstd(conanfile, cppstd, False)",
"def test_valid_min_cppstd_from_outdated_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", c... | [
"0.606535",
"0.6040464",
"0.6037657",
"0.5879055",
"0.5879055",
"0.5840026",
"0.5797774",
"0.5737386",
"0.5648177",
"0.5636739",
"0.5618907",
"0.55640125",
"0.55526966",
"0.5537477",
"0.54891264",
"0.5458158",
"0.5363105",
"0.5344947",
"0.5328625",
"0.53243154",
"0.53105736",... | 0.7304677 | 0 |
check_min_cppstd must accept cppstd less/equal than cppstd in settings | def test_check_min_cppstd_from_settings(cppstd):
conanfile = _create_conanfile("gcc", "9", "Linux", "17", "libstdc++")
check_min_cppstd(conanfile, cppstd, False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_min_cppstd_from_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", \"17\", \"libstdc++\")\n assert valid_min_cppstd(conanfile, cppstd, False)",
"def test_valid_min_cppstd_from_outdated_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", c... | [
"0.83790123",
"0.828919",
"0.8263532",
"0.7857218",
"0.7746421",
"0.7687734",
"0.7656595",
"0.56181246",
"0.56181246",
"0.53554183",
"0.53473574",
"0.5338393",
"0.52888554",
"0.52425236",
"0.5232316",
"0.52196693",
"0.52190524",
"0.5215625",
"0.52024746",
"0.51602256",
"0.513... | 0.8610532 | 0 |
check_min_cppstd must raise when cppstd is greater when supported on settings | def test_check_min_cppstd_from_outdated_settings(cppstd):
conanfile = _create_conanfile("gcc", "9", "Linux", cppstd, "libstdc++")
with pytest.raises(ConanInvalidConfiguration) as exc:
check_min_cppstd(conanfile, "17", False)
assert "Current cppstd ({}) is lower than the required C++ standard (17)." ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_min_cppstd_from_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", \"17\", \"libstdc++\")\n check_min_cppstd(conanfile, cppstd, False)",
"def test_valid_min_cppstd_from_outdated_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", cppstd, ... | [
"0.8534895",
"0.8361236",
"0.8359717",
"0.80610454",
"0.7926917",
"0.78573936",
"0.78523266",
"0.5774294",
"0.5774294",
"0.5490091",
"0.54063976",
"0.5378053",
"0.5374565",
"0.537211",
"0.53720254",
"0.5358018",
"0.5312948",
"0.52775615",
"0.52739",
"0.527349",
"0.5265609",
... | 0.84044707 | 1 |
current cppstd in settings must has GNU extension when extensions is enabled | def test_check_min_cppstd_from_settings_with_extension(cppstd):
conanfile = _create_conanfile("gcc", "9", "Linux", "gnu17", "libstdc++")
check_min_cppstd(conanfile, cppstd, True)
conanfile.settings.values["compiler.cppstd"] = "17"
with pytest.raises(ConanException) as raises:
check_min_cppstd(c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_min_cppstd_from_settings_with_extension(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", \"gnu17\", \"libstdc++\")\n assert valid_min_cppstd(conanfile, cppstd, True)\n\n conanfile.settings.values[\"compiler.cppstd\"] = \"17\"\n assert not valid_min_cppstd(conanfile, cp... | [
"0.7459949",
"0.6938823",
"0.688496",
"0.6713248",
"0.64949465",
"0.6366114",
"0.6186687",
"0.60135245",
"0.55841583",
"0.55797786",
"0.5557202",
"0.5535696",
"0.55279285",
"0.5433433",
"0.54291785",
"0.541971",
"0.52319616",
"0.5206695",
"0.5200531",
"0.51930785",
"0.5193078... | 0.73684585 | 1 |
valid_min_cppstd must accept cppstd less/equal than cppstd in settings | def test_valid_min_cppstd_from_settings(cppstd):
conanfile = _create_conanfile("gcc", "9", "Linux", "17", "libstdc++")
assert valid_min_cppstd(conanfile, cppstd, False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_min_cppstd_from_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", \"17\", \"libstdc++\")\n check_min_cppstd(conanfile, cppstd, False)",
"def test_valid_min_cppstd_from_outdated_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", cppstd, ... | [
"0.8432451",
"0.84312165",
"0.82355624",
"0.8026598",
"0.7823204",
"0.76396435",
"0.76155615",
"0.5750717",
"0.56954056",
"0.56954056",
"0.54980093",
"0.5486995",
"0.53468484",
"0.5334285",
"0.5245057",
"0.51650894",
"0.5161656",
"0.5138168",
"0.4994576",
"0.49561718",
"0.493... | 0.8435113 | 0 |
valid_min_cppstd returns False when cppstd is greater when supported on settings | def test_valid_min_cppstd_from_outdated_settings(cppstd):
conanfile = _create_conanfile("gcc", "9", "Linux", cppstd, "libstdc++")
assert not valid_min_cppstd(conanfile, "17", False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_min_cppstd_from_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", \"17\", \"libstdc++\")\n assert valid_min_cppstd(conanfile, cppstd, False)",
"def test_check_min_cppstd_from_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", \"17\", \"... | [
"0.82856977",
"0.8284472",
"0.81791043",
"0.79015714",
"0.7806536",
"0.77142555",
"0.75506115",
"0.60548735",
"0.60548735",
"0.5678936",
"0.5661268",
"0.5642414",
"0.55867887",
"0.554774",
"0.5360949",
"0.5317744",
"0.5304097",
"0.52879226",
"0.52788186",
"0.52660334",
"0.525... | 0.8331274 | 0 |
valid_min_cppstd must returns True when current cppstd in settings has GNU extension and extensions is enabled | def test_valid_min_cppstd_from_settings_with_extension(cppstd):
conanfile = _create_conanfile("gcc", "9", "Linux", "gnu17", "libstdc++")
assert valid_min_cppstd(conanfile, cppstd, True)
conanfile.settings.values["compiler.cppstd"] = "17"
assert not valid_min_cppstd(conanfile, cppstd, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_min_cppstd_from_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", \"17\", \"libstdc++\")\n assert valid_min_cppstd(conanfile, cppstd, False)",
"def test_valid_min_cppstd_from_outdated_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", c... | [
"0.8383212",
"0.8344042",
"0.8325712",
"0.8254919",
"0.8238365",
"0.7998004",
"0.75515246",
"0.62131083",
"0.62131083",
"0.6079385",
"0.60109764",
"0.59059393",
"0.58837014",
"0.58221537",
"0.57356864",
"0.5719557",
"0.5440298",
"0.5378785",
"0.53732544",
"0.5338421",
"0.5303... | 0.8465978 | 0 |
valid_min_cppstd must returns False when the compiler does not support a standard | def test_valid_min_cppstd_unsupported_standard():
conanfile = _create_conanfile("gcc", "9", "Linux", None, "libstdc++")
assert not valid_min_cppstd(conanfile, "42", False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_min_cppstd_from_outdated_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\", \"Linux\", cppstd, \"libstdc++\")\n assert not valid_min_cppstd(conanfile, \"17\", False)",
"def test_check_min_cppstd_from_outdated_settings(cppstd):\n conanfile = _create_conanfile(\"gcc\", \"9\",... | [
"0.80719686",
"0.7828799",
"0.7827251",
"0.76881784",
"0.7671556",
"0.7335252",
"0.7077219",
"0.65876174",
"0.65876174",
"0.61894965",
"0.6149451",
"0.6146761",
"0.6146346",
"0.60984683",
"0.6089835",
"0.6030474",
"0.5946799",
"0.5711369",
"0.5695732",
"0.562218",
"0.56012154... | 0.8641858 | 0 |
Creates the output directory (if needed) for a given test filename. | def _make_output_directory(self):
fs = self._filesystem
output_filename = fs.join(self._root_output_dir, self._test_name)
fs.maybe_make_directory(fs.dirname(output_filename)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_test_dir(path, test_name):\n LOG.info('In make_test_dir')\n OutputWrite.change_to_script_directory(__file__)\n path_with_test_name = os.path.join(path, test_name)\n LOG.debug('Path with Test name = {0}'.format(path_with_test_name))\n os.makedirs(path_with_test_name, exis... | [
"0.75760484",
"0.7541676",
"0.7530527",
"0.7460458",
"0.7438704",
"0.7432384",
"0.7328338",
"0.71599495",
"0.7151884",
"0.7125183",
"0.71230537",
"0.712015",
"0.7097461",
"0.7074497",
"0.7053761",
"0.69745195",
"0.69452363",
"0.6907157",
"0.6822044",
"0.6817444",
"0.67721057"... | 0.8688169 | 0 |
Returns a filename inside the output dir that contains modifier. For example, if test name is "fast/dom/foo.html" and modifier is "expected.txt", the return value is "//fast/dom/fooexpected.txt". | def output_filename(self, modifier):
fs = self._filesystem
output_filename = fs.join(self._root_output_dir, self._test_name)
return fs.splitext(output_filename)[0] + modifier | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def out_filename(self, filetype, dir, format='old'):\n filename = self.filename(filetype=filetype, format=format)\n return Path(dir) / filename",
"def modifier(self) -> str:\n match = RE_MODIFIER.match(self.string.split(\".\")[-1])\n return match.group(1) if match else None",
"def n... | [
"0.58207613",
"0.5751061",
"0.56657475",
"0.56599396",
"0.5654314",
"0.55837417",
"0.55719894",
"0.5552638",
"0.55237275",
"0.5506235",
"0.54401886",
"0.5409135",
"0.53879833",
"0.5328823",
"0.5316454",
"0.5291592",
"0.5287656",
"0.5282221",
"0.5279094",
"0.5277583",
"0.52505... | 0.8293363 | 0 |
This loop method can be run periodically to read messages out of the incoming message buffer. It also deals with replying to ping requests from other devices. Note that it is not necessary to handle reconnection to the broker in this function; that task is done by the pahomqtt loop function. | def loop(self):
# dump all incoming messages into a list and empty the string
incoming_messages = self.receiver.getDataFromCallback()
# empty the buffer
self.receiver.emptyDataFromCallback()
parsed_messages = []
pingacks = []
for message in incoming_messages:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_loop(self):\n msg_buffer = bytes() # The message input buffer\n while not self._shutdown.is_set():\n if msg_buffer:\n try:\n msg_length = self.determine_length_of_json_msg(msg_buffer)\n except InvalidLengthHeader:\n ... | [
"0.6787638",
"0.67483264",
"0.6733461",
"0.668043",
"0.66479534",
"0.66192263",
"0.65365195",
"0.6519447",
"0.65160984",
"0.64964384",
"0.649278",
"0.6487754",
"0.6443011",
"0.6421026",
"0.6397668",
"0.6382806",
"0.63817954",
"0.6367425",
"0.63415164",
"0.632488",
"0.632381",... | 0.71868086 | 0 |
Called when a message that was to be sent using the publish() call has completed transmission to the broker. For messages with QoS levels 1 and 2, this means that the appropriate handshakes have completed. For QoS 0, this simply means that the message has left the client. The mid variable matches the mid variable retur... | def on_publish(self, mqtt_client, userdata, mid):
logging.debug("DEBUG - publish ack received") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_publish(client: mqtt.Client, userdata: Any, mid: int) -> None:\n logging.info(f\"Successfully published a message: mid={mid}\")",
"def on_publish(mqttc, obj, mid):\n logger.debug(\"MQTT PUBLISH: mid: \" + str(mid))",
"def _on_received(self):\n self._call_subscribers(on_level=0xFF)\n ... | [
"0.6719796",
"0.63540304",
"0.6348619",
"0.6348619",
"0.61428654",
"0.61008364",
"0.6099687",
"0.60711056",
"0.6054444",
"0.60187227",
"0.5955626",
"0.5910268",
"0.5905536",
"0.5824548",
"0.5812667",
"0.5788648",
"0.5740093",
"0.57357466",
"0.57073987",
"0.56752867",
"0.56465... | 0.7296903 | 0 |
Called when the broker responds to a subscribe request. The mid variable matches the mid variable returned from the corresponding subscribe() call. The granted_qos variable is a list of integers that give the QoS level the broker has granted for each of the different subscription requests. | def on_subscribe(self, mqtt_client, userdata, mid, granted_qos):
logging.debug("DEBUG - subscribe ack received") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_subscribe( client, userdata, mid, granted_qos ):\n logging.info( \"Topic successfully subcribed with QoS: %s\" %granted_qos )",
"def on_subscribe(\n client: mqtt.Client,\n userdata: Any,\n mid: int,\n granted_qos: int,\n properties: Properties = None,\n ) -> None:\... | [
"0.78606457",
"0.73526573",
"0.73511815",
"0.73411936",
"0.6243929",
"0.6154017",
"0.6003614",
"0.58606964",
"0.5699538",
"0.5607465",
"0.55689776",
"0.5533125",
"0.5532634",
"0.5532259",
"0.55218977",
"0.54990625",
"0.54990625",
"0.54990625",
"0.5481366",
"0.54635054",
"0.54... | 0.7684058 | 1 |
Called when the broker responds to an unsubscribe request. The mid variable matches the mid variable returned from the corresponding unsubscribe() call. | def on_unsubscribe(self, mqtt_client, userdata, mid ):
logging.debug("DEBUG - unsubscribe ack received") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _onUnsubscribe(self, client:mqtt.Client, userdata:Any, mid:int) -> None:\n\t\t# TODO doc, error check when not connected, not subscribed\n\t\tfor t in self.subscribedTopics.values():\n\t\t\tif t.mid == mid:\n\t\t\t\tdel self.subscribedTopics[t.topic]\n\t\t\t\tself.messageHandler and self.messageHandler.onUnsub... | [
"0.7673036",
"0.71898264",
"0.71898264",
"0.71898264",
"0.71898264",
"0.71898264",
"0.6841545",
"0.6836344",
"0.66947705",
"0.6439168",
"0.63896066",
"0.63896066",
"0.6375074",
"0.6370575",
"0.6313172",
"0.6242574",
"0.6138637",
"0.6128106",
"0.61084366",
"0.60223824",
"0.601... | 0.81462276 | 0 |
Called when the client has log information. Define to allow debugging. The level variable gives the severity of the message and will be one of MQTT_LOG_INFO, MQTT_LOG_NOTICE, MQTT_LOG_WARNING, MQTT_LOG_ERR, and MQTT_LOG_DEBUG. The message itself is in buf. This may be used at the same time as the standard Python loggin... | def on_log(self, mqtt_client, userdata, level, buf):
logging.debug("DEBUG - on_log received") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _onLog(self, client:mqtt.Client, userdata:Any, level:int, buf:str) -> None:\n\t\tself.lowLevelLogging and self.messageHandler and self.messageHandler.logging(self, mqtt.LOGGING_LEVEL[level], f'MQTT: {buf}')",
"def on_log( client, userdata, level, buf ):\n print( \"MQTTClient log: \", buf )",
"def log(se... | [
"0.722783",
"0.7200979",
"0.6938204",
"0.6802061",
"0.6786618",
"0.6770143",
"0.67585814",
"0.67537093",
"0.6730563",
"0.6723531",
"0.66956717",
"0.6655029",
"0.6559967",
"0.6549606",
"0.65251434",
"0.65159553",
"0.6508616",
"0.64965546",
"0.6476269",
"0.64737624",
"0.6467095... | 0.776755 | 0 |
Checks to make sure that the OSG_APP directory exists and the VO directories have the proper permissions. Returns True if everything is okay, False otherwise. APP_DIR must exist and have a etc directory with 1777 permissions for success. If APP_DIR begins with /cvmfs/oasis.opensciencegrid.org, skip tests If APP_DIR is ... | def _check_app_dir(self, app_dir):
try:
if self._app_dir_in_oasis(app_dir):
self.log('OSG_APP is an OASIS repository, skipping tests',
level=logging.DEBUG)
return True
# Added for SOFTWARE-1567
if utilities.blank(app_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_app_dir():\n if not os.path.exists(os.path.expanduser('~/.config/scheduler')):\n os.mkdir(os.path.expanduser('~/.config/scheduler'))",
"def _is_fluxcd_app_compliant(path):\n mandatory_components = (\"base\", constants.APP_ROOT_KUSTOMIZE_FILE)\n check_mandatory = all(comp in os.... | [
"0.6326567",
"0.6206003",
"0.5989269",
"0.59077847",
"0.58891314",
"0.57839966",
"0.5724023",
"0.56984824",
"0.56959385",
"0.56879663",
"0.5665498",
"0.56507283",
"0.5624213",
"0.5600026",
"0.55384475",
"0.55363727",
"0.55267036",
"0.55253416",
"0.54842967",
"0.54662365",
"0.... | 0.8807894 | 0 |
Check if the checkpoint directory exists. | def checkpoint_directory(checkpoint):
if os.path.isdir(checkpoint):
pass
else:
os.mkdir(checkpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_checkpoint(checkpoint_path, rb_path):\n if not (os.path.exists(checkpoint_path) and os.path.exists(rb_path)):\n return False\n if \"model.pyth\" not in os.listdir(checkpoint_path):\n return False\n if len(os.listdir(rb_path)) == 0:\n return False\n return True",
"def __ch... | [
"0.707472",
"0.68333393",
"0.6796365",
"0.6653455",
"0.66517746",
"0.6584179",
"0.65725064",
"0.65433574",
"0.6506466",
"0.64921796",
"0.6423578",
"0.64093035",
"0.63485706",
"0.6332552",
"0.63043517",
"0.62980425",
"0.62911516",
"0.6287191",
"0.62745476",
"0.6248313",
"0.624... | 0.7586222 | 0 |
Check if the history directory exists. Save the training history using pickle | def save_training_history(hist):
if os.path.exists("history/history") != True:
os.mknod("history/history")
with open("history/history", "wb") as file_pi:
pickle.dump(hist.history, file_pi)
print("Training History saved") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_history_filepath(config: configs.Config) -> str:\n return os.path.join(config.model_training.dir_out, histories.DEFAULT_FILENAME_HISTORY)",
"def save_history():\n\n mid = get_mid()\n back_file = contact_name + \"_\" + today\n\n if not os.path.isdir(back_path):\n print('WARNING: o {} d... | [
"0.6603627",
"0.64930785",
"0.6321043",
"0.62986016",
"0.6275199",
"0.6257157",
"0.62345636",
"0.6191526",
"0.6145273",
"0.61407536",
"0.6140146",
"0.61068493",
"0.6106079",
"0.60848814",
"0.6069463",
"0.606762",
"0.605813",
"0.60200083",
"0.601926",
"0.5964243",
"0.5934849",... | 0.8098023 | 0 |
Extract flag from "memory dump." | def extractFlag(str):
flag = ""
lines = str.split("\n")
for line in lines:
m = r2.search(line)
if m:
#print "DEBUG: matched %s %s %s %s" % \
# (m.group(4), m.group(3), m.group(2), m.group(1))
byte0 = int("0x" + m.group(4), 16)
byte1 = int("0x" + m.group(3), 16)
byte2 = int("0x" + m.gro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_debug_flag(self):\n flag_end = self.code.find('}', self.instruction_pointer)\n flag = self.code[self.instruction_pointer + 1: flag_end]\n self.instruction_pointer = flag_end + 1\n return flag",
"def info(dump_alloc_table: bytes, /) -> None:",
"def read_flags():\n return fl... | [
"0.59816873",
"0.57567346",
"0.5572509",
"0.55154014",
"0.54914933",
"0.5424141",
"0.5424141",
"0.5424141",
"0.5424141",
"0.5424141",
"0.5424141",
"0.5424141",
"0.53049755",
"0.5283544",
"0.525357",
"0.52435714",
"0.5163303",
"0.51580286",
"0.50818187",
"0.5076767",
"0.506786... | 0.6035833 | 0 |
Create a new DXF drawing. | def new(dxfversion='AC1009'):
dwg = Drawing.new(dxfversion)
if dwg.dxfversion > 'AC1009':
dwg.reset_fingerprintguid()
dwg.reset_versionguid()
return dwg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_design(self, dxfversion=None):\n\n if self.file == None:\n raise Exception(\"No file name given. Use design.file to set name.\")\n \n if dxfversion is None:\n self.drawing = ezdxf.new()\n else:\n self.drawing = ezdxf.new(dxfversion=dxfversio... | [
"0.62602437",
"0.61130667",
"0.6105475",
"0.6009673",
"0.58618027",
"0.5830883",
"0.5812108",
"0.5783543",
"0.5741492",
"0.5642588",
"0.55565625",
"0.5505152",
"0.54500544",
"0.54429936",
"0.54170465",
"0.5338738",
"0.5336918",
"0.533193",
"0.5323914",
"0.5311172",
"0.5311172... | 0.7004339 | 0 |
Read DXF drawing from a text stream, which only needs a readline() method. | def read(stream, legacy_mode=True, dxfversion=None):
return Drawing.read(stream, legacy_mode=legacy_mode, dxfversion=dxfversion) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self):\n word = self.ser.readline()\n\n # strip carriage return and newline\n word = word[:-2]\n\n if word == b'start':\n self.current_position = 1\n elif word == b'end':\n self.current_position = 0\n elif self.current_position == 1:\n ... | [
"0.548991",
"0.52534527",
"0.51849645",
"0.5176815",
"0.5169114",
"0.51572025",
"0.5129534",
"0.5127991",
"0.5127991",
"0.51028264",
"0.5101739",
"0.507993",
"0.50563097",
"0.50294536",
"0.50111526",
"0.5001363",
"0.49800867",
"0.49705264",
"0.49453765",
"0.493349",
"0.492218... | 0.7279433 | 0 |
Read DXF drawing specified by filename from file system. | def readfile(filename, encoding=None, legacy_mode=False):
if not is_dxf_file(filename):
raise IOError("File '{}' is not a DXF file.".format(filename))
info = dxf_file_info(filename)
with io.open(filename, mode='rt', encoding=info.encoding, errors='ignore') as fp:
dwg = read(fp, legacy_mode=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_dxf(filename, name=\"import\"):\n\n import_options = app().importManager.createDXF2DImportOptions(filename, root().xYConstructionPlane)\n\n result = app().importManager.importToTarget2(import_options, root())\n sketch = result[0] # type: adsk.fusion.Sketch\n\n curves = []\n for profile_c... | [
"0.62365913",
"0.6056679",
"0.59398216",
"0.5771581",
"0.56552833",
"0.55508983",
"0.553926",
"0.5536307",
"0.5536307",
"0.5504197",
"0.5469989",
"0.5448618",
"0.54413754",
"0.53550106",
"0.53503054",
"0.528772",
"0.5280682",
"0.5279569",
"0.526726",
"0.5261324",
"0.5259586",... | 0.63520026 | 0 |
Read DXF drawing specified by filename from a zip archive, or if filename is None the first DXF file in the zip archive. | def readzip(zipfile, filename=None):
with ctxZipReader(zipfile, filename) as zipstream:
dwg = read(zipstream, dxfversion=zipstream.dxfversion)
dwg.filename = zipstream.dxf_file_name
return dwg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_gdf_from_zip(zip_fp):\r\n with ZipFile(zip_fp) as z:\r\n # Lists all files inside the ZipFile, here assumes that there is only a single file inside\r\n layer = z.namelist()[0]\r\n data = gpd.read_file(io.BytesIO(z.read(layer)))\r\n return data",
"def load_zipped_image(zipfilen... | [
"0.65380305",
"0.59887093",
"0.5633095",
"0.5633095",
"0.5579948",
"0.55555505",
"0.5418056",
"0.5369647",
"0.53689545",
"0.5251003",
"0.52193046",
"0.52098596",
"0.52047473",
"0.5200924",
"0.5167083",
"0.5124786",
"0.5124591",
"0.5107453",
"0.5107453",
"0.51072335",
"0.51019... | 0.752579 | 0 |
Checks if the provided email/username is allowed to register. | def check_registration_allowed(self, email, username, password):
message = ''
status = 'done'
for provider, options in self.active_authenticators(email, username, password):
allow_reg = _get_tri_state(options, 'allow-register', True)
if allow_reg is None: # i.e. challeng... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_register_email():\n email = request.args.get('email')\n if not email:\n return jsonify({'valid': False, 'error': 'Please provide an email address'})\n user = User.query.filter_by(email=email).first()\n if user:\n # The email already exists\n return jsonify({'valid': Fa... | [
"0.7208078",
"0.6688415",
"0.66716623",
"0.6671243",
"0.6654609",
"0.66388154",
"0.6634287",
"0.6578736",
"0.6561765",
"0.65397495",
"0.6518941",
"0.65126413",
"0.6511321",
"0.64964926",
"0.6479779",
"0.643631",
"0.6433575",
"0.639774",
"0.6395784",
"0.63802123",
"0.63802123"... | 0.74985576 | 0 |
Checks the username/email & password using auth providers in order. If a match is found, returns the 'autoregister' option for that provider. | def check_auto_registration(self, trans, login, password):
if '@' in login:
email = login
username = None
else:
email = None
username = login
for provider, options in self.active_authenticators(email, username, password):
if provider is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_provider_credentials(provider):\n logging.info('Getting provider credentials for {}'.format(provider))\n uppercase_provider = provider.upper()\n username_variable = '{}_USERNAME'.format(uppercase_provider)\n authentication_variable = '{}_AUTHENTICATION'.format(uppercase_provider)\n username ... | [
"0.5743347",
"0.5479232",
"0.5479232",
"0.5457973",
"0.54499906",
"0.5414201",
"0.538813",
"0.53708375",
"0.53423876",
"0.5317309",
"0.5317309",
"0.5266163",
"0.5259146",
"0.521853",
"0.5212739",
"0.5209004",
"0.51957333",
"0.517681",
"0.516306",
"0.5161628",
"0.51289415",
... | 0.570605 | 1 |
Checks that auth provider allows password changes and current_password matches. | def check_change_password(self, user, current_password):
for provider, options in self.active_authenticators(user.email, user.username, current_password):
if provider is None:
log.debug( "Unable to find module: %s" % options )
else:
auth_result = provider.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def old_password_check(form, field):\n old_password = field.data\n password = current_user.password\n r = pwd_context.verify(old_password, current_user.password)\n if not r:\n raise validators.ValidationError('old password is wrong')",
"def clean_current_password(self):\n if not self.us... | [
"0.7481303",
"0.73336846",
"0.7174981",
"0.7134431",
"0.7075722",
"0.70290816",
"0.6981715",
"0.6932496",
"0.6923515",
"0.6892524",
"0.6880183",
"0.6819773",
"0.6771059",
"0.6756742",
"0.669096",
"0.668823",
"0.6686865",
"0.6674609",
"0.66698617",
"0.66646445",
"0.6656603",
... | 0.77227116 | 0 |
Yields AuthProvider instances for the provided configfile that match the filters. | def active_authenticators(self, email, username, password):
try:
for authenticator in self.authenticators:
filter_template = authenticator.filter_template
if filter_template:
filter_str = filter_template.format(email=email, username=username, passw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_config(self, filename):\n \n self.log_message(\"processing config file: \"+filename)\n parser = SafeConfigParser()\n parser.optionxform = str\n parser.read(filename)\n self.source_files[filename] = parser\n \n sections = parser.sections()\n ... | [
"0.55165887",
"0.54740477",
"0.5456033",
"0.5204814",
"0.51817036",
"0.51779187",
"0.5145235",
"0.5094792",
"0.50625825",
"0.5043274",
"0.503296",
"0.50300777",
"0.4997937",
"0.49973503",
"0.49099335",
"0.48673862",
"0.48410338",
"0.48296568",
"0.4815884",
"0.48079547",
"0.48... | 0.6293995 | 0 |
Create a certificate request. | def createCertRequest(pkey, digest="sha256", **name):
req = crypto.X509Req()
subj = req.get_subject()
for key, value in name.items():
setattr(subj, key, value)
req.set_pubkey(pkey)
req.sign(pkey, digest)
return req | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateCertificate(self, request):\n try:\n params = request._serialize()\n headers = request.headers\n body = self.call(\"CreateCertificate\", params, headers=headers)\n response = json.loads(body)\n model = models.CreateCertificateResponse()\n ... | [
"0.7752741",
"0.7448376",
"0.7436426",
"0.72078025",
"0.71352416",
"0.6908512",
"0.676043",
"0.65656626",
"0.6320206",
"0.6207726",
"0.6201753",
"0.6124546",
"0.6044697",
"0.6016312",
"0.59935606",
"0.5993553",
"0.59654945",
"0.59640634",
"0.59588635",
"0.59478587",
"0.591667... | 0.7768472 | 0 |
Returns a boolean based on user input. "question" is a string that is presented to the user. "default" is the presumed answer if the user just hits . It must be True (the default), False or None (meaning an answer is required of the user). The "answer" return value is one of True or False. | def query_user_bool(question, default=True):
valid_yes_ans = ["yes", "y"]
valid_no_ans = ["no", "n"]
if default is None:
prompt = " [y/n] "
elif default:
prompt = " [Y/n] "
else:
prompt = " [y/N] "
while True:
sys.stdout.write(question + prompt)
choice ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def question(text, default):\n\n while 1:\n if isinstance(default, bool):\n if default:\n default_str = \"yes\"\n else:\n default_str = \"no\"\n else:\n default_str = str(default)\n report(text + \" [\" + default_str + \"] :\")\... | [
"0.8029658",
"0.80168086",
"0.79112357",
"0.7726895",
"0.7714002",
"0.77059233",
"0.767332",
"0.76708376",
"0.7660196",
"0.76162916",
"0.75739324",
"0.7573774",
"0.7568591",
"0.7564388",
"0.75593865",
"0.7558544",
"0.7558544",
"0.7558544",
"0.7558544",
"0.7558544",
"0.7555339... | 0.8495907 | 0 |
Computes the mount hole offset for the panels pcb based on | def get_panels_pcb_offset():
mount_hole_offset = arena_assembly['panels_to_hallway_gap']
mount_hole_offset -= arena_assembly['panels_assembly_offset']
mount_hole_offset += 0.5*hallway_bottom_plate['width']
mount_hole_offset += 0.5*panels_pcb['width']
return mount_hole_offset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setHolesCoordinates(self):\r\n # productive\r\n profprint()\r\n self.p = [[0 for j in range(63)] for j in range(3)]\r\n self.p[0][0] = 35\r\n self.p[1][0] = 34\r\n self.p[0][1] = 25\r\n self.p[1][1] = 36.679\r\n self.p[0][2] = 17.679\r\n self.p[1][2] = 44\r\n self.p[0][3] = 15\r\n... | [
"0.6010487",
"0.58476526",
"0.5843411",
"0.56217253",
"0.5531397",
"0.5517719",
"0.5478429",
"0.54766285",
"0.54637754",
"0.54327357",
"0.5389044",
"0.53337836",
"0.5286592",
"0.52859104",
"0.5279347",
"0.5272972",
"0.527268",
"0.5269894",
"0.5243816",
"0.5243478",
"0.5240646... | 0.80080986 | 0 |
Hace un click al elemento o va al link donde apunta | def click(self, wait_load_page = True):
if self.__element.tag == 'a':
self.__browser.load_page(self.get_property('href')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click(cls, user, link):\r\n pass",
"def click(cls, user, link):\n pass",
"def click(self, element):\n element.click()",
"def link_click(_):\r\n\r\n tag_name = about_content.tag_names(tkinter.CURRENT)[0]\r\n about_content.tag_config(tag_name, foreground=\"#551A8B... | [
"0.72976923",
"0.7155621",
"0.68906116",
"0.68564624",
"0.6742048",
"0.63932997",
"0.6340398",
"0.6305026",
"0.624218",
"0.6230243",
"0.62148166",
"0.61823386",
"0.61687547",
"0.6152135",
"0.6085141",
"0.60437405",
"0.60321695",
"0.60215217",
"0.60210913",
"0.59464127",
"0.59... | 0.71556246 | 1 |
Change the security groups assigned to an EC2 instance This method assigns the security groups to each elastic network interface attached to the EC2 instance. | def change_instance_security_groups(instance_id, security_group_ids):
# Retrieve the IDs of the network interfaces attached to the EC2 instance
ec2_client = boto3.client('ec2')
try:
response = ec2_client.describe_instances(InstanceIds=[instance_id])
except ClientError as e:
logging.erro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_security_group(client, instance_id_list, security_groups):\n logging.info('Setting the security group of instances.')\n for instance_id in instance_id_list:\n client.modify_instance_attribute(InstanceId=instance_id, Groups=security_groups)",
"def update_instance_security_group(self, instanc... | [
"0.7466415",
"0.68783253",
"0.63511324",
"0.6288194",
"0.62148553",
"0.62140536",
"0.59726936",
"0.59685683",
"0.59363985",
"0.5889181",
"0.5865004",
"0.58355063",
"0.57841384",
"0.57209706",
"0.5659686",
"0.5639387",
"0.55679",
"0.5537946",
"0.5481926",
"0.5434512",
"0.54299... | 0.77742124 | 0 |
Si se busca un APE por sigla, se encuentra | def test_buscar_por_sigla(self):
ape1 = APE.objects.get(sigla="APX1")
ape2 = APE.buscar_por_sigla("APX1")
self.assertIsNotNone(ape1, "El APE encontrado con GET no debería ser None")
self.assertIsNotNone(ape1, "El APE encontrado con buscar_por_sigla no debería ser None")
self.asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_buscar_por_sigla_inexistente(self):\n ape = APE.buscar_por_sigla(\"AAA\")\n self.assertIsNone(ape, \"El APE retornado debería ser None\")",
"def test_buscar_por_programa(self):\n ap2 = APE.objects.create(sigla=\"AP2\", nombre_corto=\"nc2\", nombre_largo=\"nl2\", descripcion=\"d2\")\... | [
"0.7213077",
"0.564221",
"0.55900633",
"0.5550136",
"0.55284816",
"0.5469141",
"0.5460059",
"0.5413104",
"0.53391176",
"0.53257245",
"0.53249794",
"0.53166217",
"0.52668005",
"0.52529263",
"0.52413946",
"0.5225084",
"0.52028143",
"0.51834315",
"0.5182827",
"0.5180375",
"0.516... | 0.642871 | 1 |
Si se busca un APE usando una sigla que no existe, retorna None | def test_buscar_por_sigla_inexistente(self):
ape = APE.buscar_por_sigla("AAA")
self.assertIsNone(ape, "El APE retornado debería ser None") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_buscar_por_sigla(self):\n ape1 = APE.objects.get(sigla=\"APX1\")\n ape2 = APE.buscar_por_sigla(\"APX1\")\n self.assertIsNotNone(ape1, \"El APE encontrado con GET no debería ser None\")\n self.assertIsNotNone(ape1, \"El APE encontrado con buscar_por_sigla no debería ser None\")\... | [
"0.5378839",
"0.534888",
"0.52558875",
"0.5200967",
"0.5192694",
"0.51911825",
"0.51340187",
"0.50421256",
"0.5028997",
"0.50050575",
"0.49994007",
"0.4978943",
"0.4962192",
"0.49476516",
"0.4939575",
"0.49372724",
"0.49153602",
"0.49018776",
"0.48987395",
"0.4847884",
"0.484... | 0.6852539 | 0 |
buscar_por_programa encuentra los apes correctos | def test_buscar_por_programa(self):
ap2 = APE.objects.create(sigla="AP2", nombre_corto="nc2", nombre_largo="nl2", descripcion="d2")
ap3 = APE.objects.create(sigla="AP3", nombre_corto="nc3", nombre_largo="nl3", descripcion="d3")
ap4 = APE.objects.create(sigla="AP4", nombre_corto="nc4", nombre_lar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archivos_de_texto():\n palabra = \"\" \n palabras_candidatas = [] #lista donde se guardara las palabras candidatas de cada linea\n palabra_cantidad = {} #diccionario con la palabra candidata de clave y las veces que esta repetida en cada texto de valor\n with open(\"Cuentos.txt\",\"r\") as Cuentos:... | [
"0.6187858",
"0.61709726",
"0.61543345",
"0.6150697",
"0.6149649",
"0.6036586",
"0.60221237",
"0.6020292",
"0.5974358",
"0.5955349",
"0.5946274",
"0.59303606",
"0.5879646",
"0.5878696",
"0.5862712",
"0.58470386",
"0.58375126",
"0.5834236",
"0.5774023",
"0.5743066",
"0.5730024... | 0.70472276 | 0 |
Scan the DynamoDB table to get all tasks in a service. Input region, ECS ClusterARN and ECS ServiceName | def get(table, region, cluster, service):
resp = table.scan(
FilterExpression=Attr('group').eq('service') &
Attr('groupName').eq(service) &
Attr('region').eq(region) &
Attr('clusterArn').eq(cluster)
)
return(resp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_get_all_tasks():\n sql = \"SELECT * FROM {};\".format(TABLE_NAME)\n return db_query(sql)",
"def query_all_users():\n ddb = boto3.resource(\"dynamodb\")\n tb = ddb.Table(os.environ.get(\"TABLE_NAME\"))\n return tb.scan()",
"def get_arns(profile, cluster, started_by=None):\n result = Non... | [
"0.5580493",
"0.5540637",
"0.5355417",
"0.5336787",
"0.53079015",
"0.52426785",
"0.523011",
"0.51910186",
"0.51609755",
"0.5050047",
"0.5045494",
"0.50210595",
"0.50142294",
"0.5012105",
"0.5007664",
"0.49887577",
"0.4981404",
"0.4975304",
"0.4964391",
"0.49512783",
"0.494442... | 0.6657853 | 0 |
Given the ECS cluster name and the region, get the ECS ClusterARN. | def ecs_getClusterArn(region, cluster):
client = boto3.client('ecs', region_name=region)
response = client.describe_clusters(clusters=[cluster])
logging.debug("ECS Cluster Details: %s", response)
if len(response['clusters']) == 1:
return (response['clusters'][0]['clusterArn'])
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster_name(self) -> str:\n return pulumi.get(self, \"cluster_name\")",
"def cluster_name(self) -> str:\n return pulumi.get(self, \"cluster_name\")",
"def cluster_name(self):\n return self._data['cluster_name']",
"def cluster_name(self):\n return self.name",
"def cluster_na... | [
"0.60887766",
"0.60887766",
"0.5989389",
"0.596026",
"0.59062946",
"0.5844373",
"0.58062553",
"0.5748585",
"0.5748585",
"0.5662371",
"0.5662371",
"0.5662371",
"0.5662371",
"0.5662371",
"0.554368",
"0.55225235",
"0.55225235",
"0.54336554",
"0.54336554",
"0.5412958",
"0.5392277... | 0.8022224 | 0 |
Query AWS Pricing APIs to find cost of EC2 instance in the region. Given the paramters we use at input, we should get a UNIQUE result. | def ec2_pricing(region, instance_type, tenancy, ostype):
svc_code = 'AmazonEC2'
region_n = str(aws_region_prices[region])
client = boto3.client('pricing', region_name="us-east-1")
response = client.get_products(ServiceCode=svc_code,
Filters=[
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ecs_pricing(region):\n svc_code = 'AmazonECS'\n client = boto3.client('pricing', region_name=\"us-east-1\")\n response = client.get_products(ServiceCode=svc_code,\n Filters=[\n {'Type': 'TERM_MATCH', 'Field': 'location',\n ... | [
"0.70097023",
"0.6594603",
"0.620166",
"0.61980754",
"0.58786225",
"0.5761805",
"0.5571281",
"0.55421925",
"0.5451462",
"0.5433348",
"0.5400637",
"0.53285736",
"0.52825105",
"0.52427495",
"0.5230864",
"0.5205572",
"0.51916975",
"0.5185981",
"0.51813626",
"0.5178688",
"0.51677... | 0.7237766 | 0 |
Get Cost in USD to run a ECS task where launchMode==EC2. The AWS Pricing API returns all costs in hours. runTime is in seconds. | def cost_of_ec2task(region, cpu, memory, ostype, instanceType, runTime):
global pricing_dict
global region_table
pricing_key = '_'.join(['ec2', region, instanceType, ostype])
if pricing_key not in pricing_dict:
# Workaround for DUBLIN, Shared Tenancy and Linux
(ec2_cpu, ec2_mem, ec2_cos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execution_cost(self):\n #TODO: Compute execution cost\n total_cost = 0\n for res_cfg in self.resource_configurations:\n mapped_tasks = list(filter(lambda x: x.resource_schedule.config == res_cfg, self.schedule_mapping_list))\n makespan_res = SchedulePlan._makespan(map... | [
"0.65248597",
"0.6194399",
"0.6054471",
"0.582784",
"0.57680744",
"0.5763002",
"0.56483334",
"0.56362474",
"0.560381",
"0.5510438",
"0.5510438",
"0.55060226",
"0.54979825",
"0.5488023",
"0.5475495",
"0.54749274",
"0.54435223",
"0.543028",
"0.54272366",
"0.54262346",
"0.541813... | 0.74523664 | 0 |
Ensure fit predict works on classification with multi inputs Ensure saving + loading does not cause errors Ensure saving + loading does not change predictions | def test_multifield_classify(self):
self.model.fit(self.text_data_train, self.train_targets)
self.assertTrue(self.model.is_classification)
predictions = self.model.predict(self.text_data_valid)
self.model.save(self.save_file)
model = LanguageModelGeneralAPI.load(self.save_file)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, test_batch_size=64, device='cuda', load=False, model_path=None, dataloader_num_workers=4, save_prediction=True):\n self.model.eval()\n self.device = device\n self.test_batch_size = test_batch_size\n if load:\n if model_path:\n self.load(model_... | [
"0.6947557",
"0.67904294",
"0.67709404",
"0.6735939",
"0.6697395",
"0.66614807",
"0.66268146",
"0.6605029",
"0.65289164",
"0.6522035",
"0.6510766",
"0.6481014",
"0.6447066",
"0.64214534",
"0.64203876",
"0.6406581",
"0.6400262",
"0.6376405",
"0.63612926",
"0.63573503",
"0.6348... | 0.68652046 | 1 |
pro myscale,factor tmp_data = getdata() tmp_data = tmp_data factor setdata, tmp_data if !g.frozen eq 0 then show end | def myscale(g, factor=1.0):
g.setdata(factor * g.getdata())
# if !g.frozen eq 0 then show | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_scale():\n data = io.create_sample_Dataset()\n tmp = data.piv.set_scale(1.0)\n assert np.allclose(tmp[\"x\"], data[\"x\"])\n\n tmp = data.copy()\n tmp.piv.set_scale(2.0)\n tmp_mean = tmp[\"u\"].mean(dim=(\"t\", \"x\", \"y\")).values\n data_mean = data[\"u\"].mean(dim=(\"t\", \"x\"... | [
"0.5705444",
"0.56058943",
"0.5510125",
"0.54592836",
"0.5318711",
"0.53174037",
"0.5289812",
"0.52873486",
"0.5271754",
"0.5234019",
"0.5164533",
"0.51556236",
"0.5153493",
"0.51323706",
"0.5110996",
"0.5109685",
"0.5108163",
"0.5102299",
"0.50993526",
"0.507901",
"0.507268"... | 0.7320631 | 0 |
Set user for Leave and Overtime requests. This is the default strategy of autosetting the user for a review object. It simply sets the user using a field on the model object that is under review. | def set_staff_request_review_user(review_obj: models.Model):
if not review_obj.user:
object_under_review = review_obj.content_object
staff_profile = getattr(object_under_review, STAFF, None)
if staff_profile:
review_obj.user = staff_profile.user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_user(self, user):\r\n self.user = user",
"def set_user(self, user):\n self._user = user",
"def set_staff_request_reviewer(review_obj: models.Model):\n if review_obj.user:\n staff_member = review_obj.user.staffprofile\n manager = staff_member.supervisor\n if (\n ... | [
"0.6519611",
"0.6511619",
"0.634106",
"0.62562037",
"0.61008215",
"0.6099459",
"0.6030702",
"0.600736",
"0.59290713",
"0.59290713",
"0.59290713",
"0.59290713",
"0.59290713",
"0.59290713",
"0.59290713",
"0.59290713",
"0.59290713",
"0.5920816",
"0.58341074",
"0.5779852",
"0.572... | 0.73902786 | 0 |
Set reviewer for Leave and Overtime requests. | def set_staff_request_reviewer(review_obj: models.Model):
if review_obj.user:
staff_member = review_obj.user.staffprofile
manager = staff_member.supervisor
if (
manager
and not Reviewer.objects.filter(
review=review_obj, user=manager.user
)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reviewer(self, reviewer):\n if not reviewer:\n return\n\n from stalker import User\n\n if not isinstance(reviewer, User):\n raise TypeError(\n \"%s.reviewer should be a stalker.User instance, not %s\"\n % (self.__class__.__name__, reviewe... | [
"0.65693897",
"0.6200585",
"0.5879445",
"0.58166504",
"0.5783531",
"0.55110025",
"0.5478101",
"0.5452702",
"0.5379255",
"0.5333653",
"0.51952916",
"0.5192294",
"0.5182945",
"0.5182716",
"0.5041088",
"0.50179064",
"0.5016005",
"0.5002016",
"0.49931967",
"0.4948242",
"0.4933138... | 0.63525194 | 1 |
Get an existing App resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
app_name: Optional[pulumi.Input[str]] = None,
bundle_id: Optional[pulumi.Input[str]] = None,
encoded_icon: Optional[pulumi.Input[str]] = None,
industr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def a_state(id):\n state = storage.get(State, id)\n if state is not None:\n return jsonify(state.to_dict())\n abort(404)",
"def get_state_by_id(state_id):\n for key, value in storage.all(\"State\").items():\n if state_id == value.id:\n return jsonify(value.to_dict())\n abo... | [
"0.61080384",
"0.60962945",
"0.6086946",
"0.60233724",
"0.601088",
"0.5983915",
"0.5979712",
"0.58301634",
"0.57650995",
"0.5743062",
"0.5649459",
"0.56280476",
"0.56177074",
"0.5602301",
"0.5584664",
"0.55736",
"0.55704504",
"0.55493164",
"0.55110854",
"0.551043",
"0.545657"... | 0.6481312 | 0 |
Set operator linking filters | def set_operator(self, operator):
self['dimensionFilterClauses']['operator'] = operator.upper()
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_operator(self):\n\t\tfor op in self.ops:\n\t\t\tself.filter.set_operator(op)\n\t\t\tself.assertEqual(self.filter.operator.value, op)",
"def filter(self, filters):",
"def __or__(self, other):\n intersection = proto.FilterExpression()\n domains = [self.filter, other.filter]\n inters... | [
"0.62495285",
"0.61907583",
"0.6115839",
"0.59326077",
"0.58976483",
"0.57748044",
"0.5749264",
"0.57192856",
"0.5704232",
"0.5643084",
"0.56227225",
"0.56223404",
"0.56202877",
"0.56149524",
"0.55813307",
"0.556425",
"0.5493761",
"0.5470821",
"0.5457344",
"0.5457344",
"0.544... | 0.6222453 | 1 |
Attempt to decrypt encrypted_check_phrase and check it against the check phrase to see if the password is the same. This is to avoid user inputting wrong password and accidentally corrupting the data by decrypting it with the wrong key | def check_correct_password(status, pwd):
# generate key from raw password
key = generate_key_from_password(
pwd, salt=status.get("salt")
)
f = Fernet(key)
try:
decrypt_output = f.decrypt(status["encrypted_check_phrase"])
except InvalidToken:
return False
return decryp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_password(raw_password, enc_password):\n algo, salt, hsh = enc_password.split('$')\n return constant_time_compare(hsh, get_hexdigest(algo, salt, raw_password))",
"def check_password(raw_password, enc_password):\n algo, salt, hsh = enc_password.split('$')\n return hsh == get_hexdigest(algo, s... | [
"0.67238396",
"0.66614103",
"0.66614103",
"0.6470299",
"0.6412389",
"0.6303472",
"0.6292164",
"0.6272676",
"0.6174417",
"0.6121176",
"0.6114352",
"0.60808206",
"0.60797423",
"0.6073421",
"0.6055158",
"0.6046815",
"0.60347134",
"0.6021273",
"0.6021273",
"0.6021273",
"0.6010428... | 0.71464044 | 0 |
Recursively run function fx on all files within path including all files in subdirectories recursively. The file path will be passed to fx along with args and kwargs | def recursive_file_action(path, fx, *args, **kwargs):
# generate list of files to encrypt and encrypt separately
# to make a pretty progress bar
file_paths = []
print("Collecting files...")
for (dirpath, dirnames, filenames) in os.walk(path):
for filename in filenames:
# construc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CallF_DirFile(dir_path,function,file_filter_=None,regular=False,**kw):\n file_list = Get_dir_file_list(dir_path=dir_path,file_filter_=file_filter_,regular=regular,distinguish=True)\n file_list = file_list[0]\n save_list = []\n for file_name in file_list:\n file_path = os.path.join(dir_path,f... | [
"0.6095678",
"0.60617954",
"0.60478085",
"0.5922309",
"0.58679616",
"0.56151664",
"0.5543206",
"0.55319065",
"0.5496381",
"0.54811466",
"0.54378754",
"0.54351944",
"0.54205066",
"0.541789",
"0.54034185",
"0.5401404",
"0.5392826",
"0.5392809",
"0.5387636",
"0.53658503",
"0.530... | 0.7544743 | 0 |
Go through all files in the given path and check if they're all decrypted (does not have encrypted file extension) | def check_folder_fully_decrypted(path):
for (dirpath, dirnames, filenames) in os.walk(path):
for filename in filenames:
if os.path.splitext(filename)[1] == settings.ENCRYPTED_FILE_EXTENSION:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt_dir(path, key):\n # get ext\n ext = p.splitext(path)[-1]\n # check is it a dir or a file\n if p.isdir(path):\n for file in scandir(path):\n # if file is a directory\n if p.isdir(file):\n # define root\n root = p.join(path, file.name... | [
"0.63554716",
"0.62483704",
"0.6135396",
"0.5758847",
"0.5727549",
"0.56996435",
"0.5642444",
"0.5638791",
"0.556205",
"0.55501103",
"0.5475046",
"0.54605985",
"0.541962",
"0.5417539",
"0.5396371",
"0.5374782",
"0.53746283",
"0.533626",
"0.5328153",
"0.52798045",
"0.5272402",... | 0.7889202 | 0 |
Activates or Deactivates the verification process. Default is `False`, to activate type `[p]verifyset activate True`. | async def active(self, ctx: commands.Context, toggle: bool = None):
guild = ctx.guild
tog = self.config.guild(guild)
role_config = [
await tog.temprole(),
await tog.autoroles(),
]
if not role_config[1]:
role_config[1] = None
if toggle i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active(self, activate):\n self.is_active = activate",
"def activate(self):\n self._is_active = True",
"def activateButtonClicked(self):\n print(\"trying to start process...\")\n subprocess.Popen(\"/usr/local/bin/g13d --config /usr/local/bin/defaults.bind\", shell=True)\n ... | [
"0.59819365",
"0.5893277",
"0.5834735",
"0.5833182",
"0.5813749",
"0.57869273",
"0.5743448",
"0.5743448",
"0.56668186",
"0.5642425",
"0.55306464",
"0.54420525",
"0.54404557",
"0.5435516",
"0.54344827",
"0.54283065",
"0.5396675",
"0.53793395",
"0.53632975",
"0.5354677",
"0.533... | 0.5948151 | 1 |
Set the mask using the numpy image mask. In addition to reading the mask, the 1D indicies into the 3D image are generate and stored | def setMask(self, mask):
try:
self.mask = mask
self.inds = na.nonzero(self.mask.flat)[0]
#print "length of self.inds",len(self.inds)
#print self.inds
self.dim = self.mask.shape[::-1]
#print self.mask.shape
return True
ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_05_01_mask_of3D(self):\n x=cpi.Image()\n x.image = np.ones((10,10,3))\n self.assertTrue(x.mask.ndim==2)",
"def set_mask(self, mask):\n self.mask = self._image_to_vector(mask)\n\n # PCA needs to be rerun\n self._mark_cache_invalid()",
"def _initial_set_mask(sel... | [
"0.74392325",
"0.7171469",
"0.69552106",
"0.68409544",
"0.6710002",
"0.6697239",
"0.6661768",
"0.6630858",
"0.6607959",
"0.65818256",
"0.657234",
"0.6537507",
"0.6537507",
"0.651929",
"0.6473842",
"0.64140224",
"0.6391874",
"0.6371153",
"0.63483524",
"0.6347311",
"0.63288754"... | 0.74058545 | 1 |
Determines if the path points to something Arguments path path to test the existence of, relative to base_dir Return True if the path exists, False, otherwise | def exists(self, path: PathLike): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists(path: str) -> bool:\n pass",
"def isPath(self,pin,head=\"check path exist\",exit_on_error=False,logmsg=False):\n p = os.path.abspath(self.expandvars(pin))\n if os.path.isdir(p):\n if logmsg:\n logger.info(head + \"\\n --> dir exist: {}\\n -> abs dir{:>18} {}\"... | [
"0.76789075",
"0.76009566",
"0.76007146",
"0.7570302",
"0.7548932",
"0.732443",
"0.73033184",
"0.7273316",
"0.7199226",
"0.71630126",
"0.7131916",
"0.7128128",
"0.71134526",
"0.7095323",
"0.70263815",
"0.6996621",
"0.69869936",
"0.6929987",
"0.6925032",
"0.69235873",
"0.69019... | 0.76383543 | 1 |
Tests if a path is a file. Returns false if the path doesn't exists Arguments path path from base_dir to test Returns True if the relative path exists and is a file, false otherwise | def is_file(self, path: PathLike): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isfile(path: str) -> bool:\n result = Stat._result(path, throw=False)\n return not isinstance(result, BaseException) and not S_ISDIR(result.st_mode)",
"def is_file(path: str) -> bool:\n return _fs().is_file(path)",
"def check_path(path, isfile=False, isdir=False):\n \n return os.path... | [
"0.74908406",
"0.7190465",
"0.7173597",
"0.7135862",
"0.7115111",
"0.708127",
"0.70513433",
"0.7046352",
"0.7030736",
"0.7026997",
"0.7026997",
"0.7026997",
"0.7026997",
"0.7026997",
"0.7026997",
"0.7026997",
"0.7026997",
"0.7026997",
"0.7026997",
"0.7026997",
"0.6917993",
... | 0.760532 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.