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 |
|---|---|---|---|---|---|---|
Concatenate train set and test set, So our filling data won't overfit on the train set. | def ConcatDF(train_set, test_set):
return pd.concat([train_set, test_set], sort=True).reset_index(drop=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_training_and_testing_sets(data, Y):\r\n data = pd.concat([data, Y], axis=1)\r\n x,y=data.shape\r\n train_X_sub1=data[0:x//6]\r\n dev_X_sub1 = data[x//6:x//6 + x//12]\r\n test_X_sub1 = data[x//6 + x//12:x//3]\r\n\r\n train_X_sub2 = data[x//3:x//3+x//6]\r\n dev_X_sub2 = data[x//6 + x//3:... | [
"0.73496187",
"0.7224804",
"0.65727186",
"0.654394",
"0.6478421",
"0.64367497",
"0.6360613",
"0.6349956",
"0.6343068",
"0.6336615",
"0.63026404",
"0.62977755",
"0.62607616",
"0.61374307",
"0.61365265",
"0.6113406",
"0.61098444",
"0.60983783",
"0.60931194",
"0.6065454",
"0.606... | 0.72472507 | 1 |
Gets all binary entries for a given Keepass database entry. | def get_binaries(kdb,entry):
xml = objectify.fromstring(entry.dump_xml())
binaries = list(xml.xpath('./Binary'))
for binary in binaries:
yield (binary.Key.text, Binary(kdb,binary)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_binaries(name_only=False):\n\n bins = list()\n\n dtf_db = sqlite3.connect(DTF_DB)\n cur = dtf_db.cursor()\n\n # This just returns the name\n if name_only:\n\n sql = ('SELECT name '\n 'FROM binaries ')\n\n for binary in cur.execute(sql):\n bins.append(bi... | [
"0.6717193",
"0.6395717",
"0.6036679",
"0.6013244",
"0.5961055",
"0.5801163",
"0.5788147",
"0.56636417",
"0.5656254",
"0.5552676",
"0.5549219",
"0.5496913",
"0.54446685",
"0.5436322",
"0.54299235",
"0.5419369",
"0.5414017",
"0.5394177",
"0.535307",
"0.53367394",
"0.53030056",... | 0.7077578 | 0 |
Extracts, decodes and decompresses the binary data for this block. Returns the data as bytes. | def content(self):
if self._content is not None:
return self._content
binaries = self._kdb.kdb.obj_root.Meta.Binaries
xpath = './Binary[@ID="{}"]'.format(self.ref)
binary = binaries.xpath(xpath)[0]
result = b64decode(binary.text)
if (binary.attrib['Compresse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_binary(self):\n length = self.read_uint32()\n bytes = self.data[:length]\n self.data = self.data[length:]\n return bytes",
"def get_data_block_contents_bytes(self):\n bb = self.volume.blkdev.block_bytes\n if self.volume.is_ffs:\n return bb\n else:\n return ... | [
"0.67371094",
"0.6383952",
"0.6359461",
"0.6287681",
"0.6122764",
"0.61174524",
"0.61125195",
"0.6038299",
"0.59979355",
"0.59773207",
"0.59676695",
"0.59675443",
"0.59668946",
"0.59567606",
"0.59340024",
"0.58919317",
"0.58896726",
"0.58458877",
"0.5815826",
"0.5805911",
"0.... | 0.6506396 | 1 |
Retrieves the SSH entry's passphrase (from the Keepass password field) >>> entry = KP_DB.find_entries_by_path('embedded_keys/id_rsa')[0] >>> ssh_entry = SshEntry(KP_DB,entry) >>> ssh_entry.passphrase.decode() == entry.password True | def passphrase(self):
password = self.entry.password
if password:
return self.entry.password.encode('UTF-8')
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_key_from_keyring(self):\n private_key = keyring.get_password(self.keyring_service_name, \"private_key\")\n\n if private_key is not None:\n return base64.b64decode(private_key)\n else:\n return None",
"def passphrase(password):\n\tnow = int(time.time())\n\tkey = ... | [
"0.6186439",
"0.580254",
"0.5719748",
"0.57165724",
"0.5687516",
"0.5640266",
"0.55456614",
"0.5474176",
"0.5474158",
"0.5451181",
"0.5404241",
"0.54017514",
"0.5397471",
"0.5372742",
"0.5372742",
"0.537041",
"0.5367618",
"0.5357364",
"0.5343646",
"0.5339588",
"0.53367853",
... | 0.731931 | 0 |
Parses the KeeAgent settings for the provided entry. >>> entry = KP_DB.find_entries_by_path('embedded_keys/id_rsa')[0] >>> ssh_entry = SshEntry(KP_DB,entry) >>> ssh_entry.settings | def settings(self):
if self._settings is not None:
return self._settings
settings = self.binaries['KeeAgent.settings'].content
self._settings = objectify.fromstring(settings)
return self._settings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_settings() -> Dict[str, Any]:\n settings = dict()\n with open(\"config,ini\") as file_config:\n for line in file_config:\n try:\n key = line.split(\":\")[0]\n value = line.split(\":\")[1].strip().split() if key == 'invisible_manes' else line.split(\":\"... | [
"0.5546932",
"0.53139675",
"0.5293759",
"0.5165881",
"0.51479965",
"0.51145625",
"0.50411206",
"0.5008838",
"0.4938931",
"0.4936226",
"0.49296352",
"0.49288568",
"0.49022695",
"0.48895726",
"0.4882038",
"0.48787072",
"0.48775393",
"0.4863503",
"0.48420894",
"0.48408088",
"0.4... | 0.57558864 | 0 |
Returns the serialized variant of the stored private key for this entry. SSH keys can both be stored as attachments or references to keyfiles on disk. This property supports both and will automatically read the data from the right place. Returns the respective private key file as bytes. >>> entry = KP_DB.find_entries_b... | def serialized_private_key(self):
if self._serialized_private_key is not None:
return self._serialized_private_key
location = self.settings.Location
if location.AttachmentName:
self._serialized_private_key = self.binaries[location.AttachmentName.text].content
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_private_key_in_der(self):\n serialized_private = self.private_key_obj.private_bytes(\n encoding=serialization.Encoding.DER,\n format=serialization.PrivateFormat.TraditionalOpenSSL,\n encryption_algorithm=serialization.NoEncryption()\n )\n return seriali... | [
"0.7089883",
"0.7009223",
"0.69112986",
"0.6858685",
"0.64298254",
"0.63974696",
"0.6390561",
"0.63333625",
"0.6255549",
"0.6255549",
"0.62499315",
"0.62322474",
"0.61910164",
"0.61403877",
"0.61403877",
"0.6104574",
"0.60905373",
"0.6054348",
"0.6047586",
"0.59691155",
"0.59... | 0.7920088 | 0 |
Returns the path for the private key file associated with the SSH entry. If the private key file is stored as an attachment in the Keepass database, | def private_key_path(self):
if self._private_key_path is not None:
return self._private_key_path
location = self.settings.Location
if location.AttachmentName:
self._private_key_path = 'kdbx-attachment:///{}/{}'.format(
self.entry.path, location.Attachment... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_path_to_key_file():\n\n if 'private_key_path' not in ctx.node.properties:\n raise NonRecoverableError(\n 'Unable to get key file path, private_key_path not set.')\n\n return os.path.expanduser(ctx.node.properties['private_key_path'])",
"def PRIVATE_RSA_KEYFILE_PATH() :\n retur... | [
"0.7557831",
"0.75441337",
"0.7296165",
"0.7130421",
"0.7130421",
"0.6899545",
"0.67883974",
"0.6745132",
"0.67365414",
"0.66425455",
"0.6623382",
"0.6521915",
"0.64749527",
"0.63988084",
"0.6377845",
"0.6377845",
"0.63119304",
"0.63106614",
"0.6268237",
"0.6268237",
"0.61999... | 0.81234384 | 0 |
Attempts to wrap a Keepass entry with the `SshEntry` class. Returns the `SshEntry` instance if successful and `None` otherwise. | def try_parse_ssh_entry(kdb,entry):
try:
return SshEntry(kdb,entry)
except:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_sftp_config(cls, entry: Entry):\n # parse url\n parsed = urlparse(entry['url'])\n host: str = parsed.hostname\n username: str = parsed.username\n password: str = parsed.password\n port: int = parsed.port or DEFAULT_SFTP_PORT\n\n # get private key info if it... | [
"0.49446183",
"0.49134016",
"0.4838572",
"0.47650325",
"0.47643816",
"0.47172263",
"0.46717143",
"0.4544288",
"0.45227647",
"0.45134276",
"0.44612974",
"0.44435745",
"0.44380474",
"0.4422858",
"0.44197652",
"0.44181973",
"0.4392723",
"0.43927157",
"0.4390919",
"0.43838602",
"... | 0.6858242 | 0 |
Iterates over all entries in a Keepass database and filters out the entries containing KeeAgent settings. >>> get_ssh_entries(KP_DB) [, ...] | def get_ssh_entries(kdb):
entries = kdb.entries
entries = [try_parse_ssh_entry(kdb,e) for e in entries]
entries = [e for e in entries if e]
return entries | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_entries_all(self):\n if self.database is None:\n raise DatabaseNotOpened('No KeePass Database Opened.')\n else:\n return self.database.find_entries_by_title('.*', \n regex=True)",
"def GetSSHKeys():\n keydict = {... | [
"0.63077664",
"0.59141475",
"0.5772629",
"0.5723269",
"0.54638463",
"0.53971255",
"0.5370203",
"0.53014195",
"0.52838165",
"0.51979524",
"0.5167056",
"0.5166374",
"0.51619893",
"0.51327246",
"0.5125212",
"0.51061887",
"0.50975007",
"0.50789243",
"0.5063901",
"0.502756",
"0.50... | 0.78091073 | 0 |
Inits message queue by a user choice, zmq (Default) or rabbitmq | def __init__(self, mq_choice="zmq"):
self.mq = mq_choice
func = getattr(self, "_init_{}".format(self.mq))
func() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_email_queue():\n g.setdefault('email_queue', [])",
"def on_init(self, queue=None, **kwargs):\n self.queue = queue if queue else Queue()",
"def __init__(self, address, queue_name):\n self.connection = pika.BlockingConnection(\n pika.ConnectionParameters(address))\n se... | [
"0.69520867",
"0.6691533",
"0.6441849",
"0.63638926",
"0.63620484",
"0.63039374",
"0.6296402",
"0.6273781",
"0.6147966",
"0.6147966",
"0.6147966",
"0.6134453",
"0.6087962",
"0.60812384",
"0.6079611",
"0.603834",
"0.603834",
"0.60343426",
"0.60171574",
"0.5870343",
"0.58562565... | 0.7284444 | 0 |
Update ESGF slcs token. | def generate_esgf_slcs_token(self):
client = ESGFSLCSClient(self.request)
if client.get_token():
try:
client.refresh_token()
except Exception as err:
self.session.flash('Could not refresh token: {}'.format(escape(err.message)), queue="danger")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_token(token):\n session.token = token",
"def update(self):\n token = request_token(self.client_id, self.client_secret)\n self.request_time = datetime.now()\n self._initialized = True\n self.token = token",
"def update_cloud_token(self):\n self._cloud_token = re... | [
"0.637459",
"0.5720527",
"0.57121843",
"0.5614682",
"0.55534583",
"0.54942715",
"0.5491389",
"0.53698987",
"0.5318541",
"0.5290018",
"0.52841055",
"0.5265981",
"0.5220092",
"0.5216296",
"0.52154887",
"0.51749265",
"0.51682895",
"0.5163536",
"0.5147349",
"0.51034975",
"0.50814... | 0.6638531 | 0 |
Forget ESGF slcs token. | def forget_esgf_slcs_token(self):
client = ESGFSLCSClient(self.request)
client.delete_token()
self.session.flash("ESGF token removed.", queue='info')
return HTTPFound(location=self.request.route_path('profile', userid=self.userid, tab='esgf_slcs')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke_token(token):\n token.delete_instance()",
"def unfetch(self, token):\n\n self._token = token\n return",
"def __del__(self):\n self.token_revoke()",
"def delete_token(self):\n config.update(outlook_token=None)",
"def invalidateSyncToken(self):\n self._cachedS... | [
"0.6220367",
"0.62018794",
"0.6077641",
"0.5832691",
"0.5752881",
"0.5749907",
"0.57359105",
"0.56649905",
"0.5649498",
"0.5644481",
"0.56320244",
"0.558962",
"0.5478687",
"0.54679763",
"0.5448393",
"0.5416185",
"0.53862184",
"0.5349465",
"0.52755475",
"0.52732354",
"0.524009... | 0.7006974 | 0 |
print message if package not found in repository | def pkg_not_found_mess(pkgname: str, reponame: str) -> None:
meta = MainData()
print(('{0}Package {1}{2} {0}not found in \'{3}\' '
'repository.{4}').format(meta.clrs['red'],
meta.clrs['lcyan'],
pkgname,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_info(self, package, repo):\n\n cmd_output = admin_tasks.yum_info(package, repo)\n if cmd_output:\n self.log.info(\"%s package exists\" % package)\n print(\"Command output: \\n\" + cmd_output)\n else:\n self.log.error(\"%s package was not found\" % p... | [
"0.69587296",
"0.6549966",
"0.65376604",
"0.6391485",
"0.6359235",
"0.63099056",
"0.61865646",
"0.6125522",
"0.6084877",
"0.6035341",
"0.6022625",
"0.6022625",
"0.6022625",
"0.60137427",
"0.60116285",
"0.60014516",
"0.60005105",
"0.5989728",
"0.5980288",
"0.5926141",
"0.59143... | 0.74416703 | 0 |
return list of packages in the current directory | def get_packages_in_current_dir() -> list:
from os import listdir
pkgs = []
ext = ('.tgz', '.txz')
for file_in_current_dir in sorted(listdir()):
if file_in_current_dir.endswith(ext):
pkgs.append(file_in_current_dir)
return pkgs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_packages():\n\n shelf_dir = settings.shelf_dir\n\n package_list = os.listdir(shelf_dir)\n\n package_list.sort()\n\n return package_list",
"def packages(self):\n return []",
"def get_packages(package):\n return [\n dirpath\n for dirpath, dirnames, filenames in os.wal... | [
"0.77534187",
"0.770658",
"0.76226324",
"0.7619127",
"0.7619127",
"0.7619127",
"0.75383526",
"0.75368935",
"0.7454178",
"0.738317",
"0.73001754",
"0.71758336",
"0.7129305",
"0.712208",
"0.71175563",
"0.7054623",
"0.70003355",
"0.69973624",
"0.6979044",
"0.69747645",
"0.696974... | 0.8072811 | 0 |
Get the size of the remote file | def get_remote_file_size(url: str = '', httpresponse: object = False) -> int:
need_to_close = False
if not httpresponse:
httpresponse = url_is_alive(url)
if not httpresponse:
error_open_mess(url)
return 0
need_to_close = True
content_length = httpresponse.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_size(url: str):\n header = requests.head(url).headers\n if \"Content-Length\" in header and header[\"Content-Length\"] != 0:\n return int(header[\"Content-Length\"])\n elif \"Location\" in header:\n h = requests.head(header[\"Location\"]).headers\n return int(h.get(\"Cont... | [
"0.758814",
"0.7333418",
"0.73246276",
"0.7305222",
"0.72909725",
"0.7271828",
"0.7233082",
"0.71817094",
"0.7140134",
"0.7140134",
"0.7100435",
"0.70998996",
"0.7093384",
"0.7069803",
"0.7066487",
"0.70585775",
"0.7030291",
"0.7018734",
"0.6991961",
"0.69666433",
"0.6960497"... | 0.8357053 | 0 |
get md5sum of remote or local file | def get_md5_hash(file_path: str) -> str:
from hashlib import md5
# local file
if file_path.startswith('/'):
return md5(open(file_path, 'rb').read()).hexdigest()
# remote file
httpresponse = url_is_alive(file_path)
if not httpresponse:
error_open_mess(file_path)
return '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_remote_md5(self):\n E = action_element_maker()\n top = E.top(\n E.FileSystem(\n E.Files(\n E.File(\n E.SrcName(self.src),\n E.Operations(\n E.md5sum()\n ... | [
"0.79094136",
"0.7866285",
"0.7696837",
"0.7590059",
"0.75882936",
"0.75156426",
"0.7503798",
"0.7437231",
"0.7426028",
"0.7385944",
"0.73829806",
"0.73817605",
"0.7344087",
"0.73372847",
"0.73297226",
"0.7321175",
"0.73094076",
"0.7299891",
"0.7289331",
"0.7272034",
"0.72614... | 0.79310167 | 0 |
check md5sum of two files | def check_md5sum(file1: str, file2: str) -> bool:
return get_md5_hash(file1) == get_md5_hash(file2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_md5(file1, file2):\r\n with open(file1, \"rb\") as f1:\r\n h1 = hashlib.md5(f1.read()).digest()\r\n with open(file2, \"rb\") as f2:\r\n h2 = hashlib.md5(f2.read()).digest()\r\n return h1 == h2",
"def equal_file_sum(file1_paht, file2_paht):\n md5_sum1 = generate_sum(file1_path)... | [
"0.8655619",
"0.81953096",
"0.75696427",
"0.7422941",
"0.73577124",
"0.7291288",
"0.72639024",
"0.71650517",
"0.714502",
"0.6992843",
"0.6956816",
"0.6924982",
"0.68845403",
"0.68717086",
"0.68108",
"0.68018496",
"0.6792291",
"0.67812496",
"0.6757795",
"0.67240214",
"0.671672... | 0.87421346 | 0 |
Helper function to extract ground truth communities from LFR Benchmar | def detect_ground_truth_communities(self, G):
print("Detecting Ground - Truth communities")
gt_communities = {frozenset(G.nodes[v]['community']) for v in G}
return [list(fs) for fs in gt_communities] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ground_truth():\n\n true_ps, obs_xs = util.io.load(os.path.join(get_root(), 'observed_data'))\n return true_ps, obs_xs",
"def fetchChannelMapping(verbose=False):\n\n # Check (from pbworks):\n #High freq. 305 473 360 170.312 \n #Medium freq. 154 424 209 140.820 \n #Low freq. 079 400 ... | [
"0.55977696",
"0.52905",
"0.5226053",
"0.52051973",
"0.5124833",
"0.50913644",
"0.49951893",
"0.49718392",
"0.49665216",
"0.49590883",
"0.49517453",
"0.49391073",
"0.4916794",
"0.4913647",
"0.49049315",
"0.48985282",
"0.48870233",
"0.48777327",
"0.4859775",
"0.48231226",
"0.4... | 0.5451886 | 1 |
Calculate the concentration of the input pollutant at point (x, y). | def concentration(rFile, eFile, x, y, pollutant):
sheets = pd.read_excel(eFile, sheet_name = None)
if pollutant in ['NO2', 'PM10', 'PM25', 'EC']:
c_traffic = traffic_concentration(rFile, sheets, x, y, pollutant)
if c_traffic == 'e1':
print("The calculation point is more than 60 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __calc_concentration(self, diam, data, dmin, dmax):\n\n dp = np.log10(diam*1e-9)\n conc = data # smoothed\n dmin = np.max((np.log10(dmin),dp[0]))\n dmax = np.min((np.log10(dmax),dp[-1]))\n dpi = np.arange(dmin,dmax,0.001)\n conci = np.sum(interp1d(dp,conc,kind='nearest... | [
"0.6304987",
"0.6212258",
"0.6192664",
"0.6185161",
"0.61454153",
"0.6080291",
"0.6044118",
"0.5986667",
"0.5929356",
"0.5894591",
"0.58592665",
"0.5858337",
"0.58366704",
"0.5809042",
"0.57952833",
"0.5746893",
"0.5744297",
"0.57334715",
"0.5693117",
"0.5643129",
"0.5623406"... | 0.6773205 | 0 |
Given a point p, find the nearest road that p belongs to. Return the road type and the distance from p to this road. | def nearest_road(p, file):
with fiona.open(roadFile, 'r') as roads:
nearestRoad = roads[0]
minDis = p.distance(shape(roads[0]['geometry']))
for road in roads:
dis = p.distance(shape(road['geometry']))
if dis < minDis:
nearestRoad = road
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nearest_to_point(self, point):\n ptvertex = point.get_vertex(crs=self.crs)\n segments = zip(self.vertices.slice(0, -1), self.vertices.slice(1, 0))\n\n if isinstance(self.crs, CartesianCRS):\n func = _cvectorgeo.pt_nearest_planar\n def func(seg):\n retu... | [
"0.6380749",
"0.6323016",
"0.6234743",
"0.6233291",
"0.62017536",
"0.61731505",
"0.610106",
"0.605958",
"0.6042641",
"0.6024658",
"0.601331",
"0.59856397",
"0.5979267",
"0.59519076",
"0.5893517",
"0.588874",
"0.58503014",
"0.5850296",
"0.58121365",
"0.5811686",
"0.57973415",
... | 0.673218 | 0 |
Get the background concentration value at point (x, y) from the template file. | def background_concentration(sheets, x, y, pollutant):
i, j = coor2idx(x, y)
# get bc from excel. The year is hard coded to 2015
f = sheets["Backgroundconc"]
idx = f[f['XiYI'] == str(i) + "-" + str(j)].index
if len(idx) == 0:
print("BCError: No location found. 0 returned.")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_background_concentration(self) -> _VectorisedFloat:\n return self.CO2_atmosphere_concentration",
"def GetBackgroundValue(self) -> \"short\":\n return _itkBinaryContourImageFilterPython.itkBinaryContourImageFilterISS3ISS3_GetBackgroundValue(self)",
"def GetBackgroundValue(self) -> \"short\... | [
"0.5851373",
"0.57091177",
"0.569069",
"0.56186575",
"0.55539846",
"0.5522965",
"0.5509472",
"0.5504668",
"0.54553366",
"0.5387881",
"0.53565407",
"0.5343399",
"0.5340344",
"0.5300976",
"0.5293775",
"0.5271966",
"0.52227193",
"0.5221222",
"0.5219034",
"0.52049077",
"0.5195402... | 0.6470138 | 0 |
get wind speed at point (x, y) from excel. | def wind_speed(sheets, x, y):
i, j = coor2idx(x, y)
# get ws from excel. The year is hard coded to 2012
f = sheets["Meteo CAR-VL3.0"]
idx = f[f['Search key'] == int(str(i) + str(j) + "2012")].index
if len(idx) == 0:
print("WSError: No location found.")
return 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wind_speed(self):\n names = ['anc_mean_wind_speed']\n return self.sensor.get_with_fallback('wind_speed', names)",
"def wind_speed(self):\r\n return self._yesterdays_weather.get_average_wind_speed()",
"def get_windtspeed(self):\n return self.read_register(4111, 0, 3)",
"def nat... | [
"0.659362",
"0.6417548",
"0.63081926",
"0.62631917",
"0.6230827",
"0.61567974",
"0.60879445",
"0.60721374",
"0.605982",
"0.59834135",
"0.5885346",
"0.57687396",
"0.5756765",
"0.5713098",
"0.57006425",
"0.56810087",
"0.5661978",
"0.5649398",
"0.563927",
"0.55981606",
"0.559717... | 0.7899671 | 0 |
Translate coordinates into indices (as being used in CAR VL3.0). In fact, I dont know in which CRS the coordinates are. I just followed what has been done in excel. | def coor2idx(x, y):
a = round(x/4000,0)*4000
b = (round_down(y/4000,0)+0.5)*4000
i = int((a - 24000)/4000) + 1
j = int((b - 22000)/4000) + 1
return i, j | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Indexes(self, latitudes, longitudes):\n res = self._transform.TransformPoints(\n np.column_stack((longitudes, latitudes)))\n res = list(zip(*res))\n x, y = np.array(res[0]), np.array(res[1])\n idx_col = self._inv_txf[0] + self._inv_txf[1] * x + self._inv_txf[2] * y\n idx_row = self._inv_t... | [
"0.7147023",
"0.70279527",
"0.69961184",
"0.6830627",
"0.67562884",
"0.66991967",
"0.6639779",
"0.663841",
"0.66000515",
"0.65586907",
"0.65067756",
"0.65027595",
"0.64892167",
"0.6450959",
"0.64251804",
"0.642326",
"0.63962543",
"0.62964547",
"0.62945944",
"0.627512",
"0.625... | 0.71679586 | 0 |
Round a number to n decimal places (same as 'rounddown' in excel). | def round_down(n, decimals=0):
multiplier = 10 ** decimals
return int(n * multiplier) / multiplier | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def round_to(n, precision):\n correction = 0.5 if n >= 0 else -0.5\n return int(n / precision + correction) * precision",
"def float_round(num, n):\n num = float(num)\n num = round(num, n)\n return num",
"def round_to_n(x, n=8):\n n = 1 + n - int(np.floor(np.log10(abs(x) + .1)))\n\n return... | [
"0.7621153",
"0.7491323",
"0.7403502",
"0.7221512",
"0.7186418",
"0.71188676",
"0.706864",
"0.7044281",
"0.6993371",
"0.69815147",
"0.69485044",
"0.6904951",
"0.6862087",
"0.6807377",
"0.6804079",
"0.67433345",
"0.67120963",
"0.66838527",
"0.6665037",
"0.6659999",
"0.66458374... | 0.75088334 | 1 |
Small utility returning a record reader that can read gzip'ed files. | def _gzip_reader_fn():
return tf.TFRecordReader(
options=tf.python_io.TFRecordOptions(
compression_type=tf.python_io.TFRecordCompressionType.GZIP)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gzip_reader_fn(filenames):\n return tf.data.TFRecordDataset(\n filenames,\n compression_type='GZIP')",
"def _gzip_reader_fn(filenames):\n return tf.data.TFRecordDataset(\n filenames,\n compression_type='GZIP')",
"def _gzip_reader_fn(filenames):\n return tf.data.TFRecordDataset... | [
"0.7269404",
"0.7269404",
"0.7256386",
"0.72512805",
"0.7213792",
"0.66633874",
"0.6593823",
"0.6543221",
"0.65036976",
"0.64691526",
"0.64597785",
"0.64412504",
"0.63976043",
"0.62297446",
"0.61427087",
"0.61095643",
"0.61095643",
"0.6041713",
"0.60404605",
"0.6019779",
"0.5... | 0.777774 | 0 |
Create a modified whirl plot for an arbitrary polygon. Traditionally whirl plots are limited to ngons, to plot for an arbtirary polygon we express the construction of the whirl as subsequent connections between points while solving the miceproblem. | def whirl_plot(polygons, iterations, step, fpath, **kwargs):
for polygon in polygons:
for _ in range(iterations):
# pylint: disable=invalid-name
xy = np.vstack([polygon, polygon[0]])
plt.plot(*np.hsplit(xy, 2), **kwargs)
diff = polygon - np.roll(polygon, 1, a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_simple_polygonisation(n_points=20):\n # generate random sample points.\n sample_points = np.random.random_sample((n_points,2))*10\n # generate simple polygon\n seq = simple_polygonisation(sample_points)\n # plot polygon\n plt.figure()\n plt.plot(seq[:,0], seq[:,1], color=\"blue\", mar... | [
"0.57888085",
"0.57761914",
"0.57043",
"0.55698246",
"0.55198437",
"0.55105144",
"0.54731727",
"0.54656243",
"0.5344655",
"0.53189474",
"0.5304088",
"0.52775407",
"0.52313",
"0.5193505",
"0.5174574",
"0.5149485",
"0.5147914",
"0.51264966",
"0.51240855",
"0.5112683",
"0.509159... | 0.65695775 | 0 |
Trims white space border of a numpy image. | def _trim_border(img):
for i in range(img.shape[0]):
if np.any(img[i, :, :] != 255):
img = img[i:, :, :]
break
for i in range(img.shape[0] - 1, 0, -1):
if np.any(img[i, :, :] != 255):
img = img[: i + 1, :, :]
break
for i in range(img.shape[1]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_whitespace(self, border: int = 5) -> None:\n if self.img is None:\n raise FileExistsError(\"Load an image first with from_url.\")\n\n pix = np.asarray(self.img)\n\n pix = pix[:, :, 0:3] # Drop the alpha channel\n idx = np.where(pix - 255)[0:2] # Drop the color wh... | [
"0.72116804",
"0.71161026",
"0.7112761",
"0.6987696",
"0.68486035",
"0.68222636",
"0.6805708",
"0.6737506",
"0.65461594",
"0.6485702",
"0.64720446",
"0.6417604",
"0.6281844",
"0.6267445",
"0.62330204",
"0.6230816",
"0.6140212",
"0.61345065",
"0.61139953",
"0.60943305",
"0.609... | 0.805428 | 0 |
Return a set of unique field values from a list of DICOM files | def get_unique_field_values(dcm_file_list, field_name):
field_values = set()
for dcm in dcm_file_list:
field_values.add(str(DicomFile(dcm).get_attributes(field_name)))
return field_values | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fastLoad(f_list):\n\n data_list = []\n t_1 = datetime.now()\n for i, f in enumerate(f_list):\n t_data = loadFile(f)\n data_list.extend(t_data)\n data_list = [dict(r) for r in set([tuple(d.items()) for d in data_list])]\n print i, datetime.now() - t_1, \"removing duplicates.... | [
"0.59633434",
"0.5882781",
"0.58684295",
"0.5741516",
"0.56883377",
"0.5653832",
"0.56346226",
"0.5630092",
"0.5630056",
"0.562653",
"0.5568489",
"0.5567887",
"0.55291784",
"0.5525892",
"0.55244976",
"0.54796493",
"0.5465706",
"0.5440886",
"0.5437382",
"0.54364234",
"0.543321... | 0.8470222 | 0 |
Returns a list of the dicom files within root_path | def find_all_dicom_files(root_path):
dicoms = set()
try:
for fpath in get_all_files(root_path):
if is_dicom_file(fpath):
dicoms.add(fpath)
except IOError as ioe:
raise IOError('Error reading file {0}.'.format(fpath)) from ioe
return dicoms | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFiles(self):\n\t\treturn os.listdir(self.getPath())",
"def get_datapaths(input_dir):\n image_paths = []\n assert os.path.isdir(input_dir), f\"{input_dir} is not existed\"\n\n for root, _, names in os.walk(input_dir):\n for name in names:\n path = os.path.join(root, name)\n ... | [
"0.6847716",
"0.6676826",
"0.66070926",
"0.65441406",
"0.65221864",
"0.65035594",
"0.6451133",
"0.6429791",
"0.6397234",
"0.6359657",
"0.63431734",
"0.6332761",
"0.63222665",
"0.63222665",
"0.6319204",
"0.63162965",
"0.63142794",
"0.6311132",
"0.62893206",
"0.62882096",
"0.62... | 0.7571755 | 0 |
Tries to read the file using dicom.read_file, if the file exists and dicom.read_file does not raise and Exception returns True. False otherwise. | def is_dicom_file(filepath):
if not os.path.exists(filepath):
raise IOError('File {} not found.'.format(filepath))
filename = os.path.basename(filepath)
if filename == 'DICOMDIR':
return False
try:
_ = dicom.read_file(filepath)
except Exception as exc:
log.debug('Ch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_exists(file):\n try:\n Cryptography.read(file)\n return True\n except (FileNotFoundError, FileExistsError):\n return False",
"def FileCheck(fn):\n try:\n open(fn, \"r\")\n return 1\n except IOError:\n print(\"Error: File does not ... | [
"0.67407846",
"0.65363544",
"0.65280926",
"0.6463532",
"0.6462749",
"0.64249706",
"0.631542",
"0.62879235",
"0.6253404",
"0.6228707",
"0.6214524",
"0.62095505",
"0.61903375",
"0.6189899",
"0.6187227",
"0.6137085",
"0.61295354",
"0.61180586",
"0.6101576",
"0.60735005",
"0.6066... | 0.7037445 | 0 |
Group in a dictionary all the DICOM files in dicom_paths separated by the given `hdr_field` tag value. | def group_dicom_files(dicom_paths, hdr_field='PatientID'):
dicom_groups = defaultdict(list)
try:
for dcm in dicom_paths:
hdr = dicom.read_file(dcm)
group_key = getattr(hdr, hdr_field)
dicom_groups[group_key].append(dcm)
except KeyError as ke:
raise KeyErro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_visits(wdir):\n all_files = glob(os.path.join(wdir, '*flc.fits'))\n group = dict()\n for file in all_files:\n visit = fits.getheader(file)['LINENUM'].split('.')[0]\n if visit not in group:\n group[str(visit)] = [str(file)]\n elif visit in group:\n group... | [
"0.5577567",
"0.55713826",
"0.55147266",
"0.533641",
"0.5316674",
"0.52081",
"0.51825505",
"0.51507807",
"0.51382357",
"0.51257515",
"0.5118948",
"0.5054843",
"0.5034878",
"0.50288385",
"0.5027249",
"0.5012812",
"0.5007348",
"0.49748573",
"0.4972229",
"0.49720487",
"0.4963073... | 0.79826343 | 0 |
Decompress all .dcm files recursively found in DICOM_DIR. This uses 'gdcmconv raw'. It works when 'dcm2nii' shows the `Unsupported Transfer Syntax` error. This error is usually caused by lack of JPEG2000 support in dcm2nii compilation. | def decompress(input_dir, dcm_pattern='*.dcm'):
dcmfiles = sorted(recursive_glob(input_dir, dcm_pattern))
for dcm in dcmfiles:
cmd = 'gdcmconv --raw -i "{0}" -o "{0}"'.format(dcm)
log.debug('Calling {}.'.format(cmd))
subprocess.check_call(cmd, shell=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dicom_to_nrrd(self, dicom_root_dir, nrrd_files_dir):\n TEMP_FILE = '/Users/chunwei/Downloads/_TEMP'\n SYSTEM_COMMAND = 'gdcmconv -w {0} {1}'\n\n for i, subject_folder in enumerate(glob.glob(dicom_root_dir + '/*')):\n nrrd_file = nrrd_files_dir + '/'\\\n + re.searc... | [
"0.5886228",
"0.56491315",
"0.5584978",
"0.54134685",
"0.539382",
"0.5364296",
"0.5216882",
"0.5209561",
"0.51926136",
"0.51270014",
"0.50320065",
"0.50242835",
"0.49604785",
"0.49584168",
"0.49448156",
"0.491124",
"0.49083465",
"0.49060026",
"0.48979783",
"0.48747438",
"0.48... | 0.78430045 | 0 |
This function retrieve articles by article indexes and return found articles. | def retrieve_articles(article_indexes):
articles = []
for index in article_indexes:
filename, position = index.split('@')
with open(filename, 'r', encoding='utf-8') as articles_file:
articles_file.seek(int(position))
line = articles_file.readline()
article = l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetIndexArticles(self, article):\n index_articles = [a for a in self.site_config.GetFlattenedArticles() if \\\n isinstance(a, IndexArticle)]\n out = [i for i in index_articles if i.Match(article.type_name)]\n\n return out",
"def articles ():\n\n offset = int (arg ('offset', '0', re_integer... | [
"0.7164512",
"0.6909187",
"0.65383947",
"0.6387886",
"0.63624847",
"0.6330164",
"0.63012826",
"0.63006276",
"0.6228014",
"0.6227102",
"0.61900175",
"0.61707246",
"0.60809773",
"0.6071758",
"0.60450137",
"0.60200983",
"0.60097104",
"0.59602565",
"0.59474",
"0.5942827",
"0.5918... | 0.7359794 | 0 |
This method realizes searching by more than 1 keyword and you can search articles that include all keywords or at least one keyword. | def search_by_keywords(self, keywords, operator='or'):
if operator == 'or' and self.indexes:
articles_indexes = []
for keyword in keywords:
if keyword in self.indexes.keys():
articles_indexes += self.indexes[keyword]
articles_indexes = list... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_by_keyword(self, keyword):\n if self.indexes and keyword in self.indexes.keys():\n articles_indexes = self.indexes[keyword][:self.no_returned_articles]\n return retrieve_articles(articles_indexes)\n else:\n return None",
"def search(self, term):",
"def ... | [
"0.68880993",
"0.65679824",
"0.6564382",
"0.654274",
"0.64528704",
"0.6317772",
"0.6299783",
"0.62631476",
"0.62608874",
"0.6253983",
"0.62516856",
"0.622099",
"0.62086266",
"0.61941206",
"0.6184246",
"0.61816686",
"0.6169494",
"0.61456",
"0.6141546",
"0.61017454",
"0.6096363... | 0.73257583 | 0 |
Parse command line arguments and liftoff configuration. | def parse_options() -> Namespace:
opt_parser = OptionParser(
"liftoff",
[
"script",
"config_path",
"procs_no",
"gpus",
"per_gpu",
"no_detach",
"verbose",
"copy_to_clipboard",
"time_limit", #... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_commandline():\n parser = optparse.OptionParser(usage = __doc__,version=git_version.verbose_msg)\n\n parser.add_option(\"-t\", \"--timeFile\",help=\"Text file with central times.\",default = 'centralTimes.txt')\n\tparser.add_option(\"-c\", \"--channel\",help=\"IFO channel.\",default = 'L1:G... | [
"0.63322717",
"0.6321284",
"0.6277704",
"0.6245351",
"0.6236686",
"0.61924034",
"0.6171203",
"0.614352",
"0.61078733",
"0.60279673",
"0.6020191",
"0.6009043",
"0.5987942",
"0.59697133",
"0.59659815",
"0.5956007",
"0.5943503",
"0.59413415",
"0.59382457",
"0.5930941",
"0.592058... | 0.6638938 | 0 |
Returns the command for a pid if that process exists. | def get_command_for_pid(pid: int) -> str:
try:
result = subprocess.run(
f"ps -p {pid:d} -o cmd h", stdout=subprocess.PIPE, shell=True
)
return result.stdout.decode("utf-8").strip()
except subprocess.CalledProcessError as _e:
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_command(pid):",
"def getpid(command):\n try:\n _pidof = executeCommand(command)\n except Exception as er:\n print (\" not able to get pid\")\n return False\n return _pidof",
"def check_pid(pid):\n result = None\n try:\n s = os.stat('/proc/' + pid)\n if ... | [
"0.7689884",
"0.72743213",
"0.7050953",
"0.6783562",
"0.6736396",
"0.6593299",
"0.6572618",
"0.6539528",
"0.6495064",
"0.64656216",
"0.64396435",
"0.6315611",
"0.6309004",
"0.6309004",
"0.6278498",
"0.6276674",
"0.6251536",
"0.618571",
"0.6111853",
"0.6089545",
"0.6050999",
... | 0.7887666 | 0 |
Checks if a subprocess is still active. | def still_active(pid: int, cmd: str) -> bool:
os_cmd = get_command_for_pid(pid)
return cmd in os_cmd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _proc_is_alive(self):\n if self._proc is None:\n return False\n\n return self._proc.poll() is None",
"def isRunning(self):\n if not self.running:\n return False\n elif self.process.poll() == 0 or self.process.returncode >= 0:\n return False\n ... | [
"0.7778317",
"0.75869554",
"0.7559739",
"0.7541411",
"0.7532069",
"0.751048",
"0.74623996",
"0.732467",
"0.7226817",
"0.72260404",
"0.72010744",
"0.7168987",
"0.71515125",
"0.7148874",
"0.7137039",
"0.7127399",
"0.7125717",
"0.70777947",
"0.70722777",
"0.7040544",
"0.7028164"... | 0.7768741 | 1 |
This function gets the previous list of running processes, the resources, and return the new list of pids. The resources are modified if some processes ended. | def refresh_pids(active_pids, resources):
still_active_pids = []
no_change = True
for info in active_pids:
pid, gpu, title, cmd, lock_path = info
if still_active(pid, cmd):
still_active_pids.append(info)
else:
print(f"[{time.strftime(time.ctime())}] {title} se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_processes_running():\r\n p = [] #array of processes\r\n if platform == \"linux\" or platform == \"linux2\":\r\n for proc in psutil.process_iter():\r\n try:\r\n tmp=Process(proc.name(),int(proc.pid),proc.username(),int(0),int(0))\r\n p.appen... | [
"0.66955024",
"0.6464206",
"0.6179278",
"0.6140418",
"0.611959",
"0.60622585",
"0.6036306",
"0.6031246",
"0.59804934",
"0.5914358",
"0.5854065",
"0.5840564",
"0.58357877",
"0.5798018",
"0.5787222",
"0.5764939",
"0.57292414",
"0.5698399",
"0.56616515",
"0.5657792",
"0.56011176... | 0.7045869 | 0 |
Takes a generator and returns a shuffled generator. | def shuffle(some_generator):
seq = list(some_generator)
random.shuffle(seq)
for x in seq:
yield x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_array_shuffler(rng):\n def nruter(in_array):\n return jax.random.permutation(rng, jnp.asarray(in_array))\n\n return nruter",
"def shuffled(iterable):\n items = list(iterable)\n random.shuffle(items)\n return items",
"def shuffle(data, shuffle_size=10000):\n buf = []\n for... | [
"0.6300271",
"0.62952805",
"0.62433124",
"0.61444193",
"0.6055796",
"0.6012041",
"0.59882706",
"0.59802055",
"0.5964028",
"0.59303206",
"0.58966327",
"0.58935845",
"0.5879163",
"0.5858825",
"0.58194625",
"0.57744366",
"0.5760689",
"0.57575315",
"0.5751348",
"0.56938046",
"0.5... | 0.80171114 | 0 |
Basic HTTP auth decorator | def basic_http_auth(f):
def wrap(request, *args, **kwargs):
if request.META.get('HTTP_AUTHORIZATION', False):
authtype, auth = request.META['HTTP_AUTHORIZATION'].split(' ')
auth = base64.b64decode(auth)
username, password = auth.split(':')
user = authenticate(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def http_basic_auth(func):\r\n\t@wraps(func)\r\n\tdef _decorator(request, *args, **kwargs):\r\n\r\n\t\tif request.META.has_key('HTTP_AUTHORIZATION'):\r\n\t\t\ttry:\r\n\t\t\t\tauthmeth, auth = request.META['HTTP_AUTHORIZATION'].split(' ', 1)\r\n\t\t\t\tif authmeth.lower() == 'basic':\r\n\t\t\t\t\tauth = auth.strip(... | [
"0.8461793",
"0.79010516",
"0.7828926",
"0.78109825",
"0.7766358",
"0.7603452",
"0.7481247",
"0.7302498",
"0.7254346",
"0.7246135",
"0.721293",
"0.7180321",
"0.7180321",
"0.7162722",
"0.7149473",
"0.71488553",
"0.71381325",
"0.7052642",
"0.70506674",
"0.7043808",
"0.6986596",... | 0.79767287 | 1 |
Service an update request in the form of /update?ipv6=&ipv4=&domain= | def update(request):
from pprint import pformat
if 'ipv4' not in request.GET and 'ipv6' not in request.GET:
return HttpResponse("Must specify one or both of ipv4/ipv6 address\nParams:%s" % pformat(request.GET.dict()), status=400)
if not u'domain' in request.GET:
return HttpResponse("Must spe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateHosts(request):\n\n updater = HostUpdater()\n updater.run()\n return http.HttpResponse(\"Ok\")",
"def update():\n return 'update api in put'",
"def handleTransitUpdateRequest(self, request:CSERequest) -> Result:\n\t\tif (url := self._getForwardURL(request.id)) is None:\n\t\t\treturn Result(rsc=... | [
"0.6419556",
"0.622346",
"0.6201386",
"0.6055032",
"0.603461",
"0.6001513",
"0.5956058",
"0.5926744",
"0.5919697",
"0.5771281",
"0.5758475",
"0.5752289",
"0.5746953",
"0.57087284",
"0.5706464",
"0.5696872",
"0.5688933",
"0.568207",
"0.5681439",
"0.5669635",
"0.56664",
"0.56... | 0.69290113 | 0 |
Init a Paddle ASR Connection Handler instance | def __init__(self, asr_engine):
super().__init__()
logger.debug(
"create an paddle asr connection handler to process the websocket connection"
)
self.config = asr_engine.config # server config
self.model_config = asr_engine.executor.config
self.asr_engine = a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_handler(self):\n return PaddleASRConnectionHanddler(self)",
"def __init__(self, tts_engine):\n super().__init__()\n logger.debug(\n \"Create PaddleTTSConnectionHandler to process the tts request\")\n\n self.tts_engine = tts_engine\n self.executor = self.tts_e... | [
"0.70649016",
"0.6452158",
"0.63979906",
"0.6249045",
"0.61649555",
"0.6112942",
"0.61059374",
"0.6089189",
"0.6074557",
"0.60720205",
"0.604152",
"0.6030205",
"0.6029689",
"0.60231495",
"0.60225475",
"0.59963256",
"0.598929",
"0.5983683",
"0.5979326",
"0.597095",
"0.59434724... | 0.68113375 | 1 |
when in continous decoding, reset for next utterance. | def reset_continuous_decoding(self):
self.global_frame_offset = self.num_frames
self.model_reset() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n log.debug('Reseting decoder.')\n # State values\n self.state = c.STATE_INIT_COPY\n self.ustate = 0\n self.nextstate = 0\n\n # Input / output buffers\n self.buf = ''\n self.output_buf = ''\n # Temporary buffers for storing data in pro... | [
"0.63061255",
"0.5913596",
"0.5910032",
"0.5909014",
"0.5876435",
"0.5876435",
"0.5869188",
"0.5829226",
"0.580801",
"0.5803396",
"0.57463163",
"0.57294697",
"0.57294697",
"0.57294697",
"0.5713042",
"0.5710891",
"0.5707014",
"0.5701592",
"0.57004386",
"0.56940204",
"0.5694020... | 0.6538203 | 0 |
Decorate a function or method to have its first positional argument be treated as an (x, y, z) tuple which must fit inside chunk boundaries of 16, CHUNK_HEIGHT, and 16, respectively. A warning will be raised if the bounds check fails. | def check_bounds(f):
@wraps(f)
def deco(chunk, coords, *args, **kwargs):
x, y, z = coords
# Coordinates were out-of-bounds; warn and run away.
if not (0 <= x < 16 and 0 <= z < 16 and 0 <= y < CHUNK_HEIGHT):
warn("Coordinates %s are OOB in %s() of %s, ignoring call"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_coords_to_chunk(f):\n\n @wraps(f)\n def decorated(self, coords, *args, **kwargs):\n x, y, z = coords\n\n bigx, smallx, bigz, smallz = split_coords(x, z)\n bigcoords = bigx, bigz\n if bigcoords in self.chunk_cache:\n chunk = self.chunk_cache[bigcoords]\n ... | [
"0.5693027",
"0.56747705",
"0.5548657",
"0.5380239",
"0.536203",
"0.5236589",
"0.5205486",
"0.5205486",
"0.5182123",
"0.5156525",
"0.5111526",
"0.5082493",
"0.50712085",
"0.50699216",
"0.50692797",
"0.5059036",
"0.505624",
"0.5047516",
"0.50207466",
"0.50109756",
"0.500859",
... | 0.65880805 | 0 |
Set up glow tables. These tables provide glow maps for illuminated points. | def make_glows():
glow = [None] * 16
for i in range(16):
dim = 2 * i + 1
glow[i] = array("b", [0] * (dim**3))
for x, y, z in product(xrange(dim), repeat=3):
distance = abs(x - i) + abs(y - i) + abs(z - i)
glow[i][(x * dim + y) * dim + z] = i + 1 - distance
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setMyColorTable(lr,lg,lb):\n dislin.myvlt(lr,lg,lb,len(lr))",
"def _TableSetup(self):\n global _tablesetup\n global singlestarLocation\n if not _tablesetup:\n singlestar.star_setup(singlestarLocation)\n _tablesetup = True",
"def _pre_draw_bge(self):\r\n ... | [
"0.5263766",
"0.51500183",
"0.5125642",
"0.5118011",
"0.5108372",
"0.5051885",
"0.50198096",
"0.500046",
"0.49911672",
"0.49805543",
"0.4939404",
"0.49271867",
"0.49168372",
"0.4901901",
"0.48378637",
"0.48280895",
"0.48219773",
"0.48054692",
"0.4797667",
"0.47891274",
"0.478... | 0.54783833 | 0 |
Composite a light source onto a lightmap. The exact operation is not quite unlike an add. | def composite_glow(target, strength, x, y, z):
ambient = glow[strength]
xbound, zbound, ybound = 16, CHUNK_HEIGHT, 16
sx = x - strength
sy = y - strength
sz = z - strength
ex = x + strength
ey = y + strength
ez = z + strength
si, sj, sk = 0, 0, 0
ei, ej, ek = strength * 2, s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_light_catalogue():\n output_filename = os.path.join(constants.DESTINATION,\n 'concatenated',\n 'iphas-dr2-light.fits')\n\n instring = ''\n for lon in np.arange(25, 215+1, constants.STRIPWIDTH):\n for part in ['a', 'b']:\n... | [
"0.5610279",
"0.53546923",
"0.53237617",
"0.53043604",
"0.5270605",
"0.5213873",
"0.5177985",
"0.50907487",
"0.49780676",
"0.4953777",
"0.49467075",
"0.49402687",
"0.4936739",
"0.49170655",
"0.4907632",
"0.49029806",
"0.48886353",
"0.48827502",
"0.4881445",
"0.48701435",
"0.4... | 0.5379295 | 1 |
Calculate the amount of light that should be shone on a block. ``glow`` is the brighest neighboring light. ``block`` is the slot of the block being illuminated. The return value is always a valid light value. | def neighboring_light(glow, block):
return clamp(glow - blocks[block].dim, 0, 15) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def light_row(row):\n def filter_row(col, rw):\n \"\"\"For a given pixel position, turn on if it matches our row\n \"\"\"\n return rw == row\n light(MAX_BRIGHTNESS, filter_row)",
"def block_reward_calc(block_number):\n\n # FIXME: Magic number? Unify\n return int((remaining_emissi... | [
"0.52353996",
"0.51834047",
"0.5176242",
"0.5041428",
"0.50006485",
"0.4954916",
"0.4940197",
"0.49317864",
"0.47643924",
"0.4748225",
"0.46979314",
"0.46752948",
"0.46199557",
"0.4596901",
"0.45848566",
"0.45458958",
"0.45410168",
"0.45358545",
"0.44717708",
"0.44717708",
"0... | 0.7323498 | 0 |
Regenerate the height map array. The height map is merely the position of the tallest block in any xzcolumn. | def regenerate_heightmap(self):
for x in range(16):
for z in range(16):
column = x * 16 + z
for y in range(255, -1, -1):
if self.get_block((x, y, z)):
break
self.heightmap[column] = y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_map(self, size, random_data = False):\n heightmap = []\n\n if random_data:\n # random noise background\n for x in range(size):\n heightmap.append([])\n for y in range(size):\n heightmap[-1].append(random.random())\n else:\n # black background\n for x in ... | [
"0.58731276",
"0.5858455",
"0.5805188",
"0.5782575",
"0.57770145",
"0.5629142",
"0.55918765",
"0.55523336",
"0.5498356",
"0.5236181",
"0.5209923",
"0.51482797",
"0.50665766",
"0.50564885",
"0.5053328",
"0.50506574",
"0.5037577",
"0.5036161",
"0.50310326",
"0.49994954",
"0.496... | 0.8081936 | 0 |
Regenerate the ambient light map. Each block's individual light comes from two sources. The ambient light comes from the sky. The height map must be valid for this method to produce valid results. | def regenerate_skylight(self):
# Create an array of skylights, and a mask of dimming blocks.
lights = [0xf] * (16 * 16)
mask = [0x0] * (16 * 16)
# For each y-level, we're going to update the mask, apply it to the
# lights, apply the lights to the section, and then blur the ligh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regenerate_heightmap(self):\n\n for x in range(16):\n for z in range(16):\n column = x * 16 + z\n for y in range(255, -1, -1):\n if self.get_block((x, y, z)):\n break\n\n self.heightmap[column] = y",
"def... | [
"0.63644713",
"0.618652",
"0.5876813",
"0.58216393",
"0.56143755",
"0.54006845",
"0.5389068",
"0.53830737",
"0.53595954",
"0.53500336",
"0.5324122",
"0.5251416",
"0.5230712",
"0.5167854",
"0.51654243",
"0.5148389",
"0.51166826",
"0.51093215",
"0.49948815",
"0.49848995",
"0.49... | 0.65239954 | 0 |
Determine whether any damage is pending on this chunk. | def is_damaged(self):
return self.all_damaged or bool(self.damaged) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_damaged(self):\n return self.damaged",
"def damaged(self) -> bool:\n return len(self._damaged_cells) > 0",
"def can_take_damage(self):\n result = True\n if self.side_effects[\"shield\"] > 0:\n result = False\n return result",
"def is_bankrupted(self):\n ... | [
"0.7358269",
"0.72853124",
"0.69238526",
"0.64603144",
"0.6391741",
"0.6032398",
"0.6017207",
"0.6011936",
"0.59953684",
"0.5980947",
"0.59143126",
"0.58919996",
"0.5880647",
"0.5855917",
"0.5853071",
"0.578088",
"0.578088",
"0.578088",
"0.5766825",
"0.576636",
"0.5748378",
... | 0.732875 | 1 |
Make a packet representing the current damage on this chunk. This method is not private, but some care should be taken with it, since it wraps some fairly cryptic internal data structures. If this chunk is currently undamaged, this method will return an empty string, which should be safe to treat as a packet. Please ch... | def get_damage_packet(self):
if self.all_damaged:
# Resend the entire chunk!
return self.save_to_packet()
elif not self.damaged:
# Send nothing at all; we don't even have a scratch on us.
return ""
elif len(self.damaged) == 1:
# Use a ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def damage(self, damage):\n return self.damage",
"def damage(self):\n out = (self.blurbs[self.state][\"damage\"])\n self.next_state(\"damage\")\n return out",
"def get_damage(self):\n return self.__damage",
"def get_damage():\n\n return character['Damage']",
"def ship_... | [
"0.59331006",
"0.579906",
"0.57893956",
"0.5656282",
"0.55813575",
"0.5487684",
"0.54682094",
"0.54240894",
"0.5413487",
"0.5369096",
"0.5364261",
"0.5301248",
"0.5289231",
"0.5221748",
"0.52184904",
"0.52123284",
"0.52100843",
"0.519872",
"0.5175159",
"0.5127847",
"0.5119192... | 0.77795994 | 0 |
Clear this chunk's damage. | def clear_damage(self):
self.damaged.clear()
self.all_damaged = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal_damage(self, damage):\n # Another cool trick\n self.current_health = max(\n 0,\n self.current_health-damage\n )",
"def Hit(self, damage):\n self.health -= damage",
"def reset(self):\n self.damage_dealt = 0\n self.kills = 0\n self.g... | [
"0.65471846",
"0.6530023",
"0.6179079",
"0.61029494",
"0.6038493",
"0.5985546",
"0.5968368",
"0.59555227",
"0.5935097",
"0.58794016",
"0.5859021",
"0.5855798",
"0.58450335",
"0.58394456",
"0.58167946",
"0.58163226",
"0.5799631",
"0.5789179",
"0.5785586",
"0.57779443",
"0.5774... | 0.8044922 | 0 |
Generate a chunk packet. | def save_to_packet(self):
mask = 0
packed = []
ls = segment_array(self.blocklight)
for i, section in enumerate(self.sections):
if any(section.blocks):
mask |= 1 << i
packed.append(section.blocks.tostring())
for i, section in enumera... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writeChunk(chunk):",
"def chunk(f, n, data):\n\n\t# Chunk ID\n\tf.write(number(2, n))\n\t# Chunk length\n\tf.write(number(4, len(data)))\n\t# Data\n\tf.write(data)",
"def create(cls, raw_data, chunk_dir, prefix='chunk'):\n other_names = [f for f in os.listdir(chunk_dir) if \\\n ... | [
"0.6074541",
"0.5996047",
"0.5944307",
"0.5832408",
"0.58029795",
"0.57758665",
"0.57101524",
"0.56944996",
"0.5658533",
"0.5651672",
"0.5611162",
"0.5574393",
"0.5542967",
"0.55011904",
"0.5488767",
"0.5452836",
"0.5403471",
"0.5397011",
"0.533897",
"0.5329054",
"0.5314494",... | 0.6450546 | 0 |
Look up skylight value. | def get_skylight(self, coords):
x, y, z = coords
index, y = divmod(y, 16)
return self.sections[index].get_skylight((x, y, z)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLight(self):\n return self.light",
"def getLightSensor() -> int:\n pass",
"def get_lighting_value(self, lighting):\n if lighting:\n return self.lighting_map[lighting]\n else:\n return 'U'",
"def get_light(name):\n if name not in _cache:\n get_lights(... | [
"0.67105234",
"0.65349597",
"0.631679",
"0.6164893",
"0.6125347",
"0.6088632",
"0.60547674",
"0.5975332",
"0.5879654",
"0.5829457",
"0.5809481",
"0.5787087",
"0.57246304",
"0.56965107",
"0.56496423",
"0.5648658",
"0.56404704",
"0.56019545",
"0.5598698",
"0.557053",
"0.5568632... | 0.66485906 | 1 |
Destroy the block at the given coordinates. This may or may not set the block to be full of air; it uses the block's preferred replacement. For example, ice generally turns to water when destroyed. This is safe as a noop; for example, destroying a block of air with no metadata is not going to cause state changes. | def destroy(self, coords):
block = blocks[self.get_block(coords)]
self.set_block(coords, block.replace)
self.set_metadata(coords, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy(self):\n self._set_block(self._pos, _AIR)\n self._set_block(self._pos + _Vec3(0, 1, 0), _AIR)",
"def destroy(self, chunk, coords):\n\n chunk.destroy(coords)",
"async def remove_block(\n self,\n position: typing.Union[\n typing.Tuple[int, int, int],\n ... | [
"0.6853528",
"0.610607",
"0.5840603",
"0.57335365",
"0.5707883",
"0.56459004",
"0.5503273",
"0.5412381",
"0.5361791",
"0.5271652",
"0.5247244",
"0.5239406",
"0.5233161",
"0.52149624",
"0.51414394",
"0.5088466",
"0.5077469",
"0.50766724",
"0.5050439",
"0.50012434",
"0.4969171"... | 0.78478986 | 0 |
Get the height of an xzcolumn of blocks. | def height_at(self, x, z):
return self.heightmap[x * 16 + z] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __column_height(self, x):\n\t\tcolumn = self.board[:, x]\n\t\treturn np.count_nonzero(column)",
"def height(self, x):\n\t\treturn np.interp(x, self.x, self.z)",
"def height(self):\n return self.row",
"def height(self):\n yy = self.yy\n return max(yy) - min(yy)",
"def get_height(sel... | [
"0.70412153",
"0.6653234",
"0.6424809",
"0.6393254",
"0.6381678",
"0.63737303",
"0.63215065",
"0.6287072",
"0.6262861",
"0.62594336",
"0.62550616",
"0.62349355",
"0.62349355",
"0.62310463",
"0.6210102",
"0.6205395",
"0.6204255",
"0.6203204",
"0.61770934",
"0.6157957",
"0.6151... | 0.7296541 | 0 |
Execute a search and replace on all blocks in this chunk. Named after the ubiquitous Unix tool. Does a semantic s/search/replace/g on this chunk's blocks. | def sed(self, search, replace):
for section in self.sections:
for i, block in enumerate(section.blocks):
if block == search:
section.blocks[i] = replace
self.all_damaged = True
self.dirty = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_content(options):\n call_command('''grep -r -l -- '%(patrn)s' . | tr '\\\\n' '\\\\0' | xargs -0 sed -i \"s/%(patrn)s/%(repl)s/g\"''', options)",
"def run(self, edit):\n\t\t\n\t\tfor region in self.view.find_all(\"“\"):\n\t\t\tself.view.replace(edit, region, \"\\\"\")\n\n\t\tfor region in self.view.... | [
"0.5799908",
"0.56883264",
"0.55834264",
"0.5576345",
"0.53871274",
"0.5384175",
"0.53761226",
"0.5295978",
"0.5126247",
"0.5111896",
"0.4971735",
"0.4959113",
"0.49545926",
"0.4946214",
"0.49248308",
"0.49042535",
"0.48981127",
"0.48809478",
"0.48734272",
"0.48707765",
"0.48... | 0.72197974 | 0 |
tests the init method of MicrophoneToText | def test_init(self):
mic = mi.MicrophoneToText()
self.assertTrue(mic.switch)
self.assertIsNotNone(mic.resultkeywords)
self.assertIsNotNone(mic.result)
self.assertIsNotNone(mic.keywordsshort)
# tests also chunk and maxbuffer
self.assertIsNotNone(mic.q)
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, src='mic', debug = False):\n self.recog_obj = speech_recognition.Recognizer() #setting the recognizer object (a instance of Recognizer module of speech_recognition package)\n self.mic_obj = speech_recognition.Microphone() #setting the microphone object (a instance of Microphone mod... | [
"0.65088475",
"0.6317328",
"0.6297638",
"0.5739098",
"0.5717202",
"0.57086253",
"0.5613694",
"0.5601155",
"0.55943924",
"0.55922794",
"0.5561357",
"0.55337906",
"0.55214226",
"0.5499641",
"0.5494486",
"0.5462692",
"0.5460193",
"0.5424771",
"0.5377457",
"0.5363363",
"0.5362899... | 0.80085844 | 0 |
tests the switchoff method of MicrophoneToText | def test_switchoff(self):
mic = mi.MicrophoneToText()
mic.switchoff()
with self.assertRaises(OSError):
mic.stream.is_active()
self.assertFalse(mic.switch)
self.assertFalse(mic.audio_source.is_recording)
self.assertTrue(mic.result.closed) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def off(config: dict):\n switch_device(config, config[\"inching\"], \"off\")",
"def _turn_off(self):\n self._turn_display('OFF')",
"def turn_off(self):\n print(\"Turning the lights off\")\n self.led.all_off()\n self.client.publish(STATE_TOPIC, OFF) #publish",
"def rtsOff():\n ... | [
"0.65265304",
"0.64437073",
"0.63737315",
"0.62635034",
"0.61954254",
"0.6169329",
"0.61235493",
"0.6122673",
"0.60922056",
"0.60602874",
"0.60577524",
"0.6016153",
"0.599097",
"0.5986121",
"0.5974701",
"0.5949988",
"0.59367454",
"0.5933775",
"0.5930321",
"0.5915988",
"0.5910... | 0.7986152 | 0 |
tests the analyze_text method of MicrophoneToText | def test_analyze_text(self):
mic = mi.MicrophoneToText()
with open('../examples/result.txt', 'w', encoding='utf-8') as f:
f.write('x transcript": straße lautet aarbergerstraße }x\n')
f.write('x transcript": ort lautet testort }x\n')
f.write('x transcript": einkommen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_convert_audio_to_text(self):\n\n text = self.converter.convert_audio_to_text(START, END, [WORD], lambda: False)\n text = text.strip()\n self.assertEqual(text, WORD)",
"def speech_recognizer_function(self, text_widget):\r\n label_listening = Label(self.root, text=\"listening t... | [
"0.6532657",
"0.6448702",
"0.6332463",
"0.6206798",
"0.6167052",
"0.6119095",
"0.5889082",
"0.5853762",
"0.58503145",
"0.5848887",
"0.58040744",
"0.5803421",
"0.57464606",
"0.56818646",
"0.5678315",
"0.5678252",
"0.5670355",
"0.5666109",
"0.5643918",
"0.56433135",
"0.5622431"... | 0.7974098 | 0 |
tests the find_correct_keyword method from MicrophoneToText | def test_get_correct_keyword(self):
mic = mi.MicrophoneToText()
mic.keywordsshort = {'street': ['straße lautet aarberger straße '], 'location': ['ort lautet berlin'], 'income': ['einkommen lautet vierzigtausend']
, 'capital': ['eigenkapital lautet hundertfünfundzwanzigtause... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_findcorrectkeyword(self):\n mic = mi.MicrophoneToText()\n\n mic.keywordsshort[\"street\"] = [\"adresse lautet amselweg\", 'useless']\n mic.keywordsshort['location'] = [\"der ort lautet berlin\", 'useless']\n mic.keywordsshort['capital'] = [\"der Kaufpreis lautet vierhunderttaus... | [
"0.8400151",
"0.69928145",
"0.6940127",
"0.623138",
"0.61756164",
"0.6096718",
"0.6020738",
"0.5958086",
"0.59253246",
"0.5919958",
"0.5907681",
"0.59044945",
"0.5880023",
"0.5837451",
"0.58224136",
"0.5795018",
"0.5792562",
"0.57838136",
"0.57676005",
"0.5748379",
"0.5716321... | 0.8242476 | 1 |
tests the find_word method from MicrophoneToText | def test_find_word(self):
mic = mi.MicrophoneToText()
teststring = 'x transcript": ort lautet testort }x'
word = mic.find_word(teststring)
self.assertEqual(word, ' ort lautet testort ') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_find_word(self):\n self.assertEqual(find_word('GREEN'), [(1, 1), (1, 1), (0, 9)])\n self.assertEqual(find_word('ABSENT'), [])\n self.assertEqual(find_word('PW'), [(1, 7), (3, 7), (0, 8)])",
"def test_find_word2(self):\n self.assertEqual(find_word2('GREEN'), [(1, 1), (1, 1), (... | [
"0.75302786",
"0.67486084",
"0.6694181",
"0.6322505",
"0.6256139",
"0.62458503",
"0.62292504",
"0.61650485",
"0.6157438",
"0.61508054",
"0.61019486",
"0.6084692",
"0.60277694",
"0.6024091",
"0.6019456",
"0.6004083",
"0.5993218",
"0.5982803",
"0.5946654",
"0.5946654",
"0.59424... | 0.8740787 | 0 |
tests the MyRecognizeCallback class check if there appears following console output Connection closed Connection was successful | def test_recognize(self):
rec = mi.MyRecognizeCallback()
rec.on_close()
rec.on_connected()
rec.on_data('"final": true truetestd')
rec.on_error("testerror")
rec.on_hypothesis("testh")
rec.on_inactivity_timeout("testerrorinac")
rec.on_listening()
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callback_connect(self):\n pass",
"def callback_connect(self):\n pass",
"def callback_connect(self):\n pass",
"def isConnected():",
"def check_connection():\n if connected():\n ws.emit(Message('mycroft.internet.connected'))\n # check for pairing, if not automaticall... | [
"0.6066561",
"0.6066561",
"0.6066561",
"0.60609084",
"0.6043428",
"0.6035044",
"0.6002975",
"0.59806365",
"0.594079",
"0.5937401",
"0.59252286",
"0.591624",
"0.58994645",
"0.589289",
"0.5883992",
"0.5849009",
"0.58283126",
"0.5797944",
"0.5786313",
"0.5773687",
"0.5753486",
... | 0.7577983 | 0 |
tests another time the find_correct_keyword method | def test_findcorrectkeyword(self):
mic = mi.MicrophoneToText()
mic.keywordsshort["street"] = ["adresse lautet amselweg", 'useless']
mic.keywordsshort['location'] = ["der ort lautet berlin", 'useless']
mic.keywordsshort['capital'] = ["der Kaufpreis lautet vierhunderttausend", 'useless']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_correct_keyword(self):\n mic = mi.MicrophoneToText()\n\n mic.keywordsshort = {'street': ['straße lautet aarberger straße '], 'location': ['ort lautet berlin'], 'income': ['einkommen lautet vierzigtausend']\n , 'capital': ['eigenkapital lautet hundertfünfundzwa... | [
"0.7309068",
"0.6687913",
"0.6643784",
"0.65354556",
"0.6508402",
"0.6308688",
"0.6193006",
"0.61645675",
"0.61492896",
"0.61248577",
"0.6112851",
"0.6052495",
"0.60482764",
"0.6041861",
"0.60333693",
"0.6031148",
"0.59902656",
"0.59857243",
"0.59632605",
"0.5960688",
"0.5956... | 0.762991 | 0 |
Can create a service with a blank name. | def test_create_service_with_empty_name(self):
response = self.tenant_client.create_service(
type_=self.type,
description=self.description)
service = response.entity
self.addCleanup(self.tenant_client.delete_service, response.entity.id_)
self.assertEqual(response.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_service(self, service_name, *args, **kwargs):\n\n creator = self._service_creators.get(service_name, None)\n\n if creator is None:\n return None\n\n return creator(*args, **kwargs)",
"def test_creation_when_missing_service_name(self):\n self.data = {\n ... | [
"0.68884873",
"0.6859313",
"0.6785968",
"0.65416306",
"0.6514902",
"0.6495302",
"0.6493249",
"0.6388759",
"0.63853484",
"0.6314513",
"0.6299523",
"0.6253874",
"0.62526363",
"0.62521815",
"0.62285614",
"0.6164396",
"0.61389124",
"0.6129556",
"0.6096557",
"0.60756034",
"0.60548... | 0.79796934 | 0 |
Can create two different services with the same name, type and description. | def test_create_service_with_duplicate_data(self):
first_response = self.tenant_client.create_service(
name=self.name,
type_=self.type,
description=self.description)
first_service = first_response.entity
self.assertEqual(first_response.status_code, 200)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ipam_services_create(self):\n pass",
"def test_create_services_with_tag(self):\n tag1 = sample_tag(user=self.user, name='Electrical')\n tag2 = sample_tag(user=self.user, name='Distribution')\n\n payload = {\n 'title' : 'Fitting Job',\n 'tags' : [tag1.id,... | [
"0.6295653",
"0.6286004",
"0.61355627",
"0.6034166",
"0.5985182",
"0.5976208",
"0.5959228",
"0.58849037",
"0.58821464",
"0.5851764",
"0.58444655",
"0.5827681",
"0.58261716",
"0.5814517",
"0.580832",
"0.5779143",
"0.5774439",
"0.5768419",
"0.57149935",
"0.5706826",
"0.56977415... | 0.72636217 | 0 |
Initialise all the values that is going to be used in the program Create files by the given url and download the given url Then call pywget_inside_crawler() function | def initialise(url, depth):
dir_string = url[url.find('/')+2 : url.rfind('/')+1] # the directory name that is going to be created format of .../.../.../
dir_string_list = dir_string.split('/')
root_dir_name = dir_string_list[0] # the root direc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pywget_inside_crawler(url):\n\n # open and read the url\n content = ''\n try:\n request = urllib.request.urlopen(url)\n content = request.read().decode(\"utf-8\")\n except:\n pass\n\n # find all contents we need which are links and srcs using regex\n match = re.findall(r'... | [
"0.7065692",
"0.655426",
"0.65318704",
"0.6516066",
"0.64950967",
"0.6479882",
"0.64755625",
"0.6383626",
"0.6380122",
"0.6354922",
"0.63388115",
"0.6297223",
"0.6268197",
"0.62476665",
"0.62240934",
"0.62218875",
"0.61970305",
"0.61833394",
"0.61645144",
"0.6163209",
"0.6153... | 0.7149152 | 0 |
Crawl the given url find all and tags Get the information inside the tags and apply pywget_recursive() function on each of them | def pywget_inside_crawler(url, depth, start_dir, start_file, root_dir_name):
depth -= 1
content = ''
try:
request = urllib.request.urlopen(url)
content = request.read().decode("utf-8")
except:
pass
# all the information that's inside <a href> and <img src> tags
match = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parsing_all_page(url):\n html_doc = get_html(url)\n# html_doc = get_html_local()\n page_count = get_html_count(html_doc)\n print 'All have find pages %d' % page_count\n\n projects = []\n\n for page in range(1, page_count + 1):\n print 'Parsing %d%%' % (page*100/page_count)\n\n ... | [
"0.63029546",
"0.62863165",
"0.6204318",
"0.61818653",
"0.6096154",
"0.6072784",
"0.6072309",
"0.6070269",
"0.6025325",
"0.59984726",
"0.59908885",
"0.5942623",
"0.59376717",
"0.5925007",
"0.5916456",
"0.59152985",
"0.588088",
"0.5869225",
"0.57900435",
"0.57351506",
"0.57351... | 0.67279756 | 0 |
Recursively create directories and download files by the given url | def pywget_recursive(url, depth, start_dir, start_file, root_dir_name):
dir_string = url[url.find('/')+2 : url.rfind('/')+1] # the directory name that is going to be created
dir_string_list = dir_string.split('/')
dir_string_list[0] = root_dir_name
dir_string = '/'.join(dir_string_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialise(url, depth):\n dir_string = url[url.find('/')+2 : url.rfind('/')+1] # the directory name that is going to be created format of .../.../.../\n dir_string_list = dir_string.split('/')\n root_dir_name = dir_string_list[0] # the ro... | [
"0.7181396",
"0.71674454",
"0.7146739",
"0.6819767",
"0.6666435",
"0.66409063",
"0.6602934",
"0.65131176",
"0.649386",
"0.6482578",
"0.64362377",
"0.64026994",
"0.63971454",
"0.6395716",
"0.6394178",
"0.6333323",
"0.6332076",
"0.63098013",
"0.6302904",
"0.62709564",
"0.626272... | 0.75172716 | 0 |
Add information inside and to the given list If it is an absolute link, check if it's under the same domain, if so add it to the list otherwise ignore If it is a relative link, add prefix in the front and add it to the list | def add_item_to_list(given_list, prefix):
new_list = []
if given_list:
for item in given_list:
item.lstrip()
if item.startswith("http://") or item.startswith("https://") or item.startswith("//"):
if item.startswith(prefix):
new_list.append(item... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mk_link_list(self, BS_object, base_url):\n link_list = []\n body = BS_object.find('body')\n for element in body.find_all('a'):\n # for link in BS_object.find_all('a'): # TEST if there are any links in html head\n \n raw_link = element.get('href')\n print... | [
"0.5817685",
"0.5556544",
"0.5537983",
"0.55320865",
"0.5474401",
"0.54573244",
"0.541493",
"0.5372431",
"0.53233933",
"0.53223795",
"0.53190553",
"0.53161633",
"0.52707195",
"0.5259274",
"0.5230734",
"0.52237004",
"0.51826096",
"0.514296",
"0.5105568",
"0.5102637",
"0.510126... | 0.72055155 | 0 |
Test the setting of the target temperature with range. | async def test_set_target_temp_range(opp):
state = opp.states.get(ENTITY_ECOBEE)
assert state.attributes.get(ATTR_TEMPERATURE) is None
assert 21.0 == state.attributes.get(ATTR_TARGET_TEMP_LOW)
assert 24.0 == state.attributes.get(ATTR_TARGET_TEMP_HIGH)
await common.async_set_temperature(
opp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_temperatures_value(self):\n self.assertEqual(self.TminValue, 450.0)",
"async def test_set_only_target_temp_with_convert(opp):\n state = opp.states.get(ENTITY_WATER_HEATER_CELSIUS)\n assert state.attributes.get(\"temperature\") == 113\n await common.async_set_temperature(opp, 114, ENTITY_... | [
"0.712122",
"0.6892608",
"0.685135",
"0.68328077",
"0.6799549",
"0.67770034",
"0.6686436",
"0.6629148",
"0.6591793",
"0.6582087",
"0.6493302",
"0.6487197",
"0.64121413",
"0.6303357",
"0.62739325",
"0.6270018",
"0.62598914",
"0.6257415",
"0.6252457",
"0.620402",
"0.6201357",
... | 0.753526 | 0 |
Test setting the target temperature range without attribute. | async def test_set_target_temp_range_bad_attr(opp):
state = opp.states.get(ENTITY_ECOBEE)
assert state.attributes.get(ATTR_TEMPERATURE) is None
assert 21.0 == state.attributes.get(ATTR_TARGET_TEMP_LOW)
assert 24.0 == state.attributes.get(ATTR_TARGET_TEMP_HIGH)
with pytest.raises(vol.Invalid):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_set_target_temp_range(opp):\n state = opp.states.get(ENTITY_ECOBEE)\n assert state.attributes.get(ATTR_TEMPERATURE) is None\n assert 21.0 == state.attributes.get(ATTR_TARGET_TEMP_LOW)\n assert 24.0 == state.attributes.get(ATTR_TARGET_TEMP_HIGH)\n\n await common.async_set_temperature(\... | [
"0.7508329",
"0.7287901",
"0.7128554",
"0.70946324",
"0.69626224",
"0.69421434",
"0.6896598",
"0.67694557",
"0.6697478",
"0.6474526",
"0.64601743",
"0.63387096",
"0.63202316",
"0.63062906",
"0.624502",
"0.6209591",
"0.6144897",
"0.61321884",
"0.6119349",
"0.61118054",
"0.6096... | 0.7497247 | 1 |
Test setting the target humidity without required attribute. | async def test_set_target_humidity_bad_attr(opp):
state = opp.states.get(ENTITY_CLIMATE)
assert 67 == state.attributes.get(ATTR_HUMIDITY)
with pytest.raises(vol.Invalid):
await common.async_set_humidity(opp, None, ENTITY_CLIMATE)
await opp.async_block_till_done()
state = opp.states.get(ENT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_set_only_target_temp_bad_attr(opp):\n state = opp.states.get(ENTITY_WATER_HEATER)\n assert state.attributes.get(\"temperature\") == 119\n with pytest.raises(vol.Invalid):\n await common.async_set_temperature(opp, None, ENTITY_WATER_HEATER)\n assert state.attributes.get(\"temperatu... | [
"0.74001616",
"0.73816055",
"0.7277736",
"0.72660315",
"0.717504",
"0.70658773",
"0.67734814",
"0.6699962",
"0.6597737",
"0.6581366",
"0.6550373",
"0.63467187",
"0.6337172",
"0.6316925",
"0.6301849",
"0.6280884",
"0.6259297",
"0.6242652",
"0.62400675",
"0.6235142",
"0.6220746... | 0.7392733 | 1 |
Test the setting of the target humidity. | async def test_set_target_humidity(opp):
state = opp.states.get(ENTITY_CLIMATE)
assert 67 == state.attributes.get(ATTR_HUMIDITY)
await common.async_set_humidity(opp, 64, ENTITY_CLIMATE)
await opp.async_block_till_done()
state = opp.states.get(ENTITY_CLIMATE)
assert 64.0 == state.attributes.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_humidity(self):\n return self._client.hum_setpoint",
"def test_rh_specific_humidity():\n p = 1013.25 * units.mbar\n temperature = 20. * units.degC\n q = 0.012 * units.dimensionless\n rh = relative_humidity_from_specific_humidity(p, temperature, q)\n assert_almost_equal(rh, 82.717... | [
"0.70812947",
"0.688115",
"0.6815197",
"0.67476773",
"0.67109245",
"0.6650672",
"0.66435766",
"0.657569",
"0.65534496",
"0.6538978",
"0.6525243",
"0.64943826",
"0.6469849",
"0.64688325",
"0.64436466",
"0.64250076",
"0.6409314",
"0.6397432",
"0.63508534",
"0.63238615",
"0.6323... | 0.74006915 | 0 |
Test setting hvac mode without required attribute. Also check the state. | async def test_set_hvac_bad_attr_and_state(opp):
state = opp.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_HVAC_ACTION) == CURRENT_HVAC_COOL
assert state.state == HVAC_MODE_COOL
with pytest.raises(vol.Invalid):
await common.async_set_hvac_mode(opp, None, ENTITY_CLIMATE)
await ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hvac_settings_mode() -> None:\n response: models.KamereonVehicleDataResponse = fixtures.get_file_content_as_schema(\n f\"{fixtures.KAMEREON_FIXTURE_PATH}/vehicle_data/hvac-settings.json\",\n schemas.KamereonVehicleDataResponseSchema,\n )\n response.raise_for_error_code()\n\n vehi... | [
"0.7346793",
"0.659513",
"0.6553336",
"0.6547794",
"0.64788115",
"0.6474456",
"0.6468106",
"0.6432124",
"0.6405655",
"0.6400266",
"0.6380518",
"0.6365761",
"0.6360496",
"0.6344345",
"0.6340621",
"0.6338978",
"0.63107705",
"0.63105696",
"0.6308598",
"0.6301044",
"0.62510014",
... | 0.6619193 | 1 |
Test setting the hold mode eco. | async def test_set_hold_mode_eco(opp):
await common.async_set_preset_mode(opp, PRESET_ECO, ENTITY_ECOBEE)
await opp.async_block_till_done()
state = opp.states.get(ENTITY_ECOBEE)
assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_ECO | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_set_hold_mode_away(opp):\n await common.async_set_preset_mode(opp, PRESET_AWAY, ENTITY_ECOBEE)\n await opp.async_block_till_done()\n\n state = opp.states.get(ENTITY_ECOBEE)\n assert state.attributes.get(ATTR_PRESET_MODE) == PRESET_AWAY",
"async def test_set_away_mode_on(opp):\n awai... | [
"0.7248443",
"0.6252217",
"0.6161196",
"0.6013288",
"0.5826798",
"0.5784178",
"0.5759576",
"0.57385975",
"0.5711461",
"0.5701929",
"0.5627311",
"0.561392",
"0.55675197",
"0.55644256",
"0.55418855",
"0.54940426",
"0.5468023",
"0.546363",
"0.54626715",
"0.5459663",
"0.5440452",... | 0.7302554 | 0 |
Test setting the auxiliary heater without required attribute. | async def test_set_aux_heat_bad_attr(opp):
state = opp.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_AUX_HEAT) == STATE_OFF
with pytest.raises(vol.Invalid):
await common.async_set_aux_heat(opp, None, ENTITY_CLIMATE)
await opp.async_block_till_done()
assert state.attributes.ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_set_only_target_temp_bad_attr(opp):\n state = opp.states.get(ENTITY_WATER_HEATER)\n assert state.attributes.get(\"temperature\") == 119\n with pytest.raises(vol.Invalid):\n await common.async_set_temperature(opp, None, ENTITY_WATER_HEATER)\n assert state.attributes.get(\"temperatu... | [
"0.61905926",
"0.6005518",
"0.5960821",
"0.58043325",
"0.5786635",
"0.5720514",
"0.5720514",
"0.5720514",
"0.5720514",
"0.5720514",
"0.5720514",
"0.5720514",
"0.5720514",
"0.571382",
"0.56762445",
"0.5656435",
"0.565543",
"0.5654403",
"0.5651507",
"0.56441265",
"0.5606535",
... | 0.6089088 | 1 |
Test setting the auxiliary heater off/false. | async def test_set_aux_heat_off(opp):
await common.async_set_aux_heat(opp, False, ENTITY_CLIMATE)
await opp.async_block_till_done()
state = opp.states.get(ENTITY_CLIMATE)
assert state.attributes.get(ATTR_AUX_HEAT) == STATE_OFF | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_turn_aux_heat_off(self) -> None:\n self._aux = False\n self.async_write_ha_state()",
"def turn_aux_heat_off(self):\n self.set_operation_mode(STATE_HEAT)",
"def test_active_off(self):\n\n self.feature_test.set_percentage(0)\n self.assertFalse(self.feature_test.... | [
"0.660986",
"0.6608852",
"0.64839536",
"0.6451368",
"0.63626975",
"0.63294744",
"0.6312525",
"0.6208631",
"0.61349434",
"0.610655",
"0.6094739",
"0.60530114",
"0.60337293",
"0.6031825",
"0.60150415",
"0.583133",
"0.5802599",
"0.5797975",
"0.5787792",
"0.57814157",
"0.5779655"... | 0.6653747 | 0 |
Assert that this platform has a certain feature or raise an exception otherwise. | def assert_has_feature(self, feature_name):
if not self.features.get("has_{}".format(feature_name), False):
self.raise_config_error("Platform {} does not support to configure {feature_name}. "
"Please make sure the platform "
"y... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_supported_features(self):",
"def is_capable(self, capability):\n return DeviceException(DeviceException.FEATURE_NOT_IMPLEMENTED)",
"def setup(self):\n raise DeviceException(DeviceException.FEATURE_NOT_IMPLEMENTED)",
"def is_available(self):\n raise DeviceException(DeviceExcepti... | [
"0.6979583",
"0.62230426",
"0.61273456",
"0.5998881",
"0.5865305",
"0.5852499",
"0.5747555",
"0.57348573",
"0.572911",
"0.56581134",
"0.56463474",
"0.56033766",
"0.559378",
"0.5572093",
"0.5548158",
"0.55380577",
"0.5529435",
"0.55059284",
"0.54845357",
"0.54813004",
"0.54713... | 0.80035317 | 0 |
Return config spec for this platform. | def get_config_spec(cls):
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_configspec():\n files = sorted(pkg_resources.resource_listdir(__name__, \"\"))\n # NOTE:\n # Explicit convert the filter results to a list, since the returned\n # iterator can ONLY be used ONCE.\n specfiles = list(filter(lambda fn: fn.endswith(\".conf.spec\"), files))\n if os.environ.get... | [
"0.7266349",
"0.6795872",
"0.6613083",
"0.64155155",
"0.63677096",
"0.6321028",
"0.6321028",
"0.62734276",
"0.6209236",
"0.6196945",
"0.61863",
"0.6152768",
"0.614142",
"0.6137562",
"0.61059767",
"0.6094757",
"0.6090384",
"0.6090384",
"0.60408014",
"0.60370034",
"0.60344994",... | 0.7307367 | 0 |
Perform a firmware update. | def update_firmware(self) -> str: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_firmware(self):\n self.execute_command(CMD_UPDATE_FIRMWARE)",
"async def update(self) -> None:\n # pause logic\n if not self.running.is_set():\n self.add_to_output(\"Paused...\")\n await self.running.wait()\n\n # tell the user we are updating\n self... | [
"0.8272702",
"0.7195315",
"0.71505",
"0.71459144",
"0.67883563",
"0.67392296",
"0.664074",
"0.6583564",
"0.6561077",
"0.65192825",
"0.64113843",
"0.63289976",
"0.63289976",
"0.62914103",
"0.62672305",
"0.62541914",
"0.62110126",
"0.61896014",
"0.6174201",
"0.6156075",
"0.6145... | 0.7670653 | 1 |
Subclass this method in a platform module to configure the DMD. This method should return a reference to the DMD's platform interface method will will receive the frame data. | def configure_dmd(self) -> "DmdPlatformInterface":
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_dmd(self):\n raise NotImplementedError",
"def configure_rgb_dmd(self, name: str) -> \"DmdPlatformInterface\":\n raise NotImplementedError",
"def __init__(self, dataFrame):\n self.dataFrame = dataFrame",
"def __init__(self):\n super().__init__()\n self.dmdParams = {} ... | [
"0.6838673",
"0.57695377",
"0.5759185",
"0.5749999",
"0.5472397",
"0.54186225",
"0.540797",
"0.5396732",
"0.5386362",
"0.5366188",
"0.5345183",
"0.529332",
"0.5250661",
"0.5228156",
"0.52225274",
"0.5218811",
"0.52103",
"0.52002627",
"0.5152777",
"0.514994",
"0.51410395",
"... | 0.7256855 | 0 |
Return a reference to the hardware sound interface. | def configure_hardware_sound_system(self) -> "HardwareSoundPlatformInterface":
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mixer_dev(self):\n\t\treturn call_sdk_function('PrlVmDevSound_GetMixerDev', self.handle)",
"def get_output_dev(self):\n\t\treturn call_sdk_function('PrlVmDevSound_GetOutputDev', self.handle)",
"def getSound(self):\r\n return self._shipsound",
"def get_sound(self, ):\r\n return _channeld... | [
"0.6874726",
"0.655885",
"0.6412684",
"0.63888556",
"0.6375075",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"0.60455745",
"... | 0.7013568 | 0 |
Return addition config section for segment displays. | def get_segment_display_config_section(cls) -> Optional[str]:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_section(self,name):\n if self.__config.has_section(name):\n data={}\n for opt,val in self.__config.items(name):\n data[opt]=val\n return data\n else:\n raise Exception(_('EVOGTK: Section \"%s\" does not exist in this preferences insta... | [
"0.6262563",
"0.5879021",
"0.58110625",
"0.57781315",
"0.56835556",
"0.56570494",
"0.5653879",
"0.5543324",
"0.55162793",
"0.5471141",
"0.54562134",
"0.5451342",
"0.5448683",
"0.5439083",
"0.5400168",
"0.53734565",
"0.53500634",
"0.53457993",
"0.53192",
"0.53049344",
"0.53049... | 0.6996485 | 0 |
Validate segment display config for platform. | def validate_segment_display_section(self, segment_display, config) -> dict:
if self.get_segment_display_config_section():
spec = self.get_segment_display_config_section() # pylint: disable-msg=assignment-from-none
config = segment_display.machine.config_validator.validate_config(spec,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_display_option(display):\n display_options = get_display_options(verbose=False)\n if display not in display_options:\n err_str = \"The display value (%s) does not correspond to a possible \\\n display value in ENA\" % (display)\n raise ValueError(err_str)",
"async def configu... | [
"0.6280102",
"0.60534555",
"0.6044687",
"0.57998556",
"0.577863",
"0.577863",
"0.571655",
"0.55797225",
"0.55797225",
"0.5537359",
"0.53069067",
"0.5244744",
"0.52330995",
"0.5228028",
"0.51318383",
"0.5114275",
"0.5112588",
"0.5101397",
"0.50893086",
"0.50835794",
"0.5073127... | 0.81158113 | 0 |
Subclass this method in a platform module to configure a segment display. This method should return a reference to the segment display platform interface method will will receive the text to show. | async def configure_segment_display(self, number: str, display_size: int,
platform_settings) -> "SegmentDisplayPlatformInterface":
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def configure_segment_display(self, number: str, platform_settings) -> LightSegmentDisplay:\n settings = self.machine.config_validator.validate_config(\"light_segment_displays\", platform_settings)\n return LightSegmentDisplay(number, lights=settings['lights'], segment_type=settings['type'])",
... | [
"0.6924744",
"0.6400069",
"0.6285432",
"0.6190356",
"0.6038278",
"0.57669413",
"0.57462823",
"0.5709245",
"0.56849116",
"0.56409514",
"0.5581522",
"0.5579373",
"0.5565821",
"0.5550693",
"0.55264884",
"0.55241746",
"0.545651",
"0.542362",
"0.53820467",
"0.5363494",
"0.5354753"... | 0.72853565 | 0 |
Register display for flash task. | def _handle_software_flash(self, display):
self._displays.add(display) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_flash(display):\n ck_display[str(display)].configure(relief=tkinter.RAISED, bd=0, highlightbackground='blue', highlightthickness=8)",
"def start_displayhook(self):\n pass",
"def attach_display(self, display):\n self.extra_displays.append(display)\n self.addDockWidget(Qt.RightD... | [
"0.6220367",
"0.6065056",
"0.56963325",
"0.55691284",
"0.5387061",
"0.5368584",
"0.5353149",
"0.5286806",
"0.52129376",
"0.5203391",
"0.51823187",
"0.5180706",
"0.51797324",
"0.51759416",
"0.51678824",
"0.51358366",
"0.512952",
"0.51293564",
"0.5108795",
"0.51070505",
"0.5089... | 0.6626366 | 0 |
Initialise I2C platform and set feature. | def __init__(self, machine):
super().__init__(machine)
self.features['has_i2c'] = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, machine):\n super().__init__(machine)\n\n # Set default platform features. Each platform interface can change\n # these to notify the framework of the specific features it supports.\n self.features['has_drivers'] = True\n self.features['max_pulse'] = 255",
"d... | [
"0.69220597",
"0.69220597",
"0.6695689",
"0.66690606",
"0.6616049",
"0.647331",
"0.6393633",
"0.63410026",
"0.6271916",
"0.6267543",
"0.61609125",
"0.61256635",
"0.60582995",
"0.6043946",
"0.60244364",
"0.59609616",
"0.59184724",
"0.5909054",
"0.5897445",
"0.5890526",
"0.5881... | 0.77334565 | 1 |
Configure a servo device in platform. | async def configure_servo(self, number: str) -> "ServoPlatformInterface":
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_servo(self, board):\n self.servo = board.get_pin(f\"d:{self.pin}:p\")\n board.servo_config(\n pin = self.pin,\n min_pulse = 544,\n max_pulse = 2400,\n angle = 93\n )",
"def configure_servo(self, config):\n raise NotIm... | [
"0.76254755",
"0.7315433",
"0.66170114",
"0.64923394",
"0.63826114",
"0.6192792",
"0.6184836",
"0.6113773",
"0.61004287",
"0.6094591",
"0.6075602",
"0.6039231",
"0.5992154",
"0.5920275",
"0.5867684",
"0.58557546",
"0.585078",
"0.58460164",
"0.58157",
"0.58004034",
"0.57591856... | 0.75352657 | 1 |
Return config section for additional stepper config items. | def get_stepper_config_section(cls) -> Optional[str]:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_step_conf(self):\n return self.step_conf",
"def get_section(self,name):\n if self.__config.has_section(name):\n data={}\n for opt,val in self.__config.items(name):\n data[opt]=val\n return data\n else:\n raise Exception(_('EV... | [
"0.633057",
"0.6099127",
"0.58716476",
"0.58429116",
"0.5834169",
"0.5792962",
"0.5772797",
"0.56489396",
"0.5637136",
"0.5587155",
"0.5559611",
"0.55529994",
"0.55025566",
"0.5501261",
"0.54880255",
"0.54546607",
"0.544704",
"0.5441845",
"0.54394555",
"0.5427645",
"0.5409087... | 0.7092227 | 0 |
Validate a stepper config for platform. | def validate_stepper_section(self, stepper: "Stepper", config: dict) -> dict:
if self.get_stepper_config_section():
spec = self.get_stepper_config_section() # pylint: disable-msg=assignment-from-none
config = stepper.machine.config_validator.validate_config(spec, config, stepper.name)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_config(self):\n pass",
"def validate_config(self):\n pass",
"def validate_config(self):\n pass",
"def config_validate(ctx, **kwargs):\n # Validates pf9-express config file and obtains Auth Token\n #Load Active Config into ctx\n GetConfig(ctx).GetActiveConfig()\n ... | [
"0.6644383",
"0.6638077",
"0.6638077",
"0.62906194",
"0.6161882",
"0.61592",
"0.6156101",
"0.61285514",
"0.6109975",
"0.60931396",
"0.59612024",
"0.5943361",
"0.5935539",
"0.59314954",
"0.59131944",
"0.5908969",
"0.58302087",
"0.5828581",
"0.57923645",
"0.5778556",
"0.5759289... | 0.75444114 | 0 |
Configure a smart stepper (axis) device in platform. | async def configure_stepper(self, number: str, config: dict) -> "StepperPlatformInterface":
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_stepper(self):\n self.logger.info('configurating stepper')\n if 'Z' in self.current_axis:\n self.anc350_instrument.configure_stepper('ZPiezoStepper', self.settings['amplitudeZ'] * ur('V'), self.settings['frequencyZ'] * ur('Hz'))\n else:\n self.anc350_instrum... | [
"0.6743401",
"0.6004976",
"0.5996683",
"0.587907",
"0.5700965",
"0.56874853",
"0.56152296",
"0.5609609",
"0.5586614",
"0.556677",
"0.5564428",
"0.55539554",
"0.55473626",
"0.55334884",
"0.5523117",
"0.55059314",
"0.548029",
"0.5454373",
"0.5443241",
"0.54360276",
"0.5430548",... | 0.6466725 | 1 |
Parse light number to a list of channels. | def parse_light_number_to_channels(self, number: str, subtype: str):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rgb_light():\n return list(light.rgb())",
"def get_channel_numbers(self):\n channel_numbers = {\"vDeflection\": None, \"hDeflection\": None, \"height\": None, \"capacitiveSensorHeight\": None}\n for key, value in self.general.items():\n if value == \"vDeflection\":\n ... | [
"0.6089877",
"0.57426196",
"0.5585461",
"0.55491596",
"0.5453368",
"0.5392379",
"0.53050375",
"0.5286392",
"0.5272585",
"0.5230747",
"0.52130616",
"0.5209771",
"0.51865584",
"0.5179176",
"0.5165454",
"0.5161469",
"0.5122844",
"0.5068625",
"0.5067793",
"0.5067252",
"0.5040409"... | 0.7634664 | 0 |
Subclass this method in a platform module to configure a light. This method should return a reference to the light object which will be called to access the hardware. | def configure_light(self, number: str, subtype: str, config: LightConfig,
platform_settings: dict) -> "LightPlatformInterface":
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, light: pykulersky.Light):\n self._light = light\n self._hs_color = None\n self._brightness = None\n self._white_value = None\n self._available = True",
"def __init__(self, light, lights, settings):\n\n if 'name' in lights[light]:\n self.name... | [
"0.7045976",
"0.68374443",
"0.67335045",
"0.66650575",
"0.6658996",
"0.6635369",
"0.65825313",
"0.65682316",
"0.65436727",
"0.6541785",
"0.6537106",
"0.6503492",
"0.63855004",
"0.6335902",
"0.63337713",
"0.63275725",
"0.6303935",
"0.6284611",
"0.6283159",
"0.62752515",
"0.627... | 0.7442126 | 0 |
Subclass this method in a platform module to configure a switch. This method should return a reference to the switch's platform interface object which will be called to access the hardware. | def configure_switch(self, number: str, config: SwitchConfig, platform_config: dict) -> "SwitchPlatformInterface":
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_switch(self, config):\n raise NotImplementedError",
"def _init_hardware(self):\n return",
"def setup_platform(hass, config, add_devices_callback, discovery_info=None):\n host = config.get(CONF_HOST)\n name = config.get(CONF_NAME)\n token = config.get('token')\n\n add_dev... | [
"0.6538836",
"0.6523317",
"0.6505792",
"0.6399605",
"0.63249785",
"0.6282614",
"0.6255226",
"0.62351584",
"0.62351584",
"0.6210984",
"0.6205586",
"0.61878955",
"0.6154461",
"0.61467355",
"0.6083941",
"0.6024437",
"0.6023775",
"0.60223734",
"0.59842956",
"0.5959211",
"0.592400... | 0.75649524 | 0 |
Return config section for additional switch config items. | def get_switch_config_section(cls) -> Optional[str]:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_switch_config_section(cls):\n return None",
"def get_section(self,name):\n if self.__config.has_section(name):\n data={}\n for opt,val in self.__config.items(name):\n data[opt]=val\n return data\n else:\n raise Exception(_('E... | [
"0.7165999",
"0.6003366",
"0.5735365",
"0.5721832",
"0.5691188",
"0.569049",
"0.56896424",
"0.5651286",
"0.5600963",
"0.5576065",
"0.5570528",
"0.55503464",
"0.5539065",
"0.5482666",
"0.5422852",
"0.5421628",
"0.54125065",
"0.53546286",
"0.53522193",
"0.53439945",
"0.53227085... | 0.70081085 | 1 |
Validate a switch config for platform. | def validate_switch_section(self, switch: "Switch", config: dict) -> dict:
if self.get_switch_config_section():
spec = self.get_switch_config_section() # pylint: disable-msg=assignment-from-none
config = switch.machine.config_validator.validate_config(spec, config, switch.name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_switch_section(self, switch: Switch, config: dict) -> dict:\n base_spec = [\"device\"]\n if self.__class__.get_switch_config_section():\n base_spec.append(self.__class__.get_switch_config_section())\n switch.machine.config_validator.validate_config(\n \"switc... | [
"0.7353518",
"0.6292539",
"0.62700325",
"0.62700325",
"0.6195892",
"0.60210854",
"0.59656155",
"0.57471776",
"0.5687998",
"0.56748194",
"0.5667317",
"0.56560016",
"0.5586307",
"0.55708754",
"0.55694824",
"0.5551827",
"0.5543095",
"0.5540105",
"0.5536376",
"0.5514801",
"0.5511... | 0.77033305 | 0 |
Get all hardware switch states. Subclass this method in a platform module to return the hardware states of all the switches on that platform. of a switch. This method should return a dict with the switch numbers as keys and the hardware state of the switches as values. (0 = inactive, 1 = active) This method should not ... | async def get_hw_switch_states(self) -> Dict[str, bool]:
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_hw_switch_states(self):\n hw_states = dict()\n #k = self._kp.keypad()\n k = \"\"\n for number, sw in self.switches.items():\n if number == k:\n hw_states[number] = 1\n else:\n hw_states[number] = 0\n return hw_states",
... | [
"0.8233298",
"0.8158193",
"0.6846591",
"0.68295014",
"0.6802005",
"0.6770927",
"0.64101845",
"0.62502646",
"0.6102917",
"0.5934764",
"0.58256066",
"0.5736322",
"0.567661",
"0.5668026",
"0.56561065",
"0.5612815",
"0.559791",
"0.5555421",
"0.5537869",
"0.55164707",
"0.5462406",... | 0.8395653 | 0 |
Subclass this method in a platform module to configure a driver. This method should return a reference to the driver's platform interface object which will be called to access the hardware. | def configure_driver(self, config: DriverConfig, number: str, platform_settings: dict) -> "DriverPlatformInterface":
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure(self):\n\n self.platform.configure()",
"def configure_hardware_sound_system(self) -> \"HardwareSoundPlatformInterface\":\n raise NotImplementedError",
"def _init_hardware(self):\n return",
"def connect(self):\n\n log.info('Connecting to device \"{0}\" using {1} at \"... | [
"0.6744216",
"0.646518",
"0.6447951",
"0.6382508",
"0.63278764",
"0.6251928",
"0.6243054",
"0.62248623",
"0.62218076",
"0.61590505",
"0.60939956",
"0.6066648",
"0.6025949",
"0.59284776",
"0.5910068",
"0.5901698",
"0.58893013",
"0.5842704",
"0.58287215",
"0.5820805",
"0.580733... | 0.71012676 | 0 |
Subclass this method in a platform module to clear a hardware switch rule for this switch. Clearing a hardware rule means actions on this switch will no longer affect coils. Another way to think of this is that it 'disables' a hardware rule. This is what you'd use to disable flippers and autofire_coils during tilt, gam... | def clear_hw_rule(self, switch: SwitchSettings, coil: DriverSettings):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_hw_rule(self, switch, coil):\n raise NotImplementedError",
"def clear_hw_rule(self, switch, coil):\n self.log.info(\"clear_hw_rule(coil=%s sw=%s)\" %\n (coil.hw_driver.number, switch.hw_switch.number))\n self.communicator.rule_clear(coil.hw_driver.number, swit... | [
"0.8434804",
"0.7971575",
"0.6231786",
"0.62125003",
"0.61418617",
"0.5927485",
"0.5882054",
"0.58764935",
"0.5856638",
"0.5834958",
"0.58010286",
"0.57616067",
"0.5751494",
"0.57407105",
"0.5730733",
"0.5707406",
"0.5672204",
"0.56031424",
"0.5601723",
"0.55898315",
"0.55400... | 0.8259269 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.