function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def _set_scsa_rx(self, v, load=False): """ Setter method for scsa_rx, mapped from YANG variable /macsec/interfaces/interface/scsa_rx (container) If this variable is read-only (config: false) in the source YANG file, then _set_scsa_rx is considered as a private method. Backends looking to populate th...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _unset_scsa_rx(self): self.__scsa_rx = YANGDynClass(base=yc_scsa_rx_openconfig_macsec__macsec_interfaces_interface_scsa_rx, is_container='container', yang_name="scsa-rx", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.n...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _set_mka(self, v, load=False): """ Setter method for mka, mapped from YANG variable /macsec/interfaces/interface/mka (container) If this variable is read-only (config: false) in the source YANG file, then _set_mka is considered as a private method. Backends looking to populate this variable shou...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def __init__(self, *args, **kwargs): self._path_helper = False self._extmethods = False self.__interface = YANGDynClass(base=YANGListType("name",yc_interface_openconfig_macsec__macsec_interfaces_interface, yang_name="interface", parent=self, is_container='list', user_ordered=False, path_helper=self._path_...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _get_interface(self): """ Getter method for interface, mapped from YANG variable /macsec/interfaces/interface (list) YANG Description: List of interfaces on which MACsec is enabled / available """ return self.__interface
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _set_interface(self, v, load=False): """ Setter method for interface, mapped from YANG variable /macsec/interfaces/interface (list) If this variable is read-only (config: false) in the source YANG file, then _set_interface is considered as a private method. Backends looking to populate this vari...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def __init__(self, *args, **kwargs): self._path_helper = False self._extmethods = False self.__mka = YANGDynClass(base=yc_mka_openconfig_macsec__macsec_mka, is_container='container', yang_name="mka", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=N...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _get_mka(self): """ Getter method for mka, mapped from YANG variable /macsec/mka (container) YANG Description: The MKA """ return self.__mka
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _set_mka(self, v, load=False): """ Setter method for mka, mapped from YANG variable /macsec/mka (container) If this variable is read-only (config: false) in the source YANG file, then _set_mka is considered as a private method. Backends looking to populate this variable should do so via call...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _get_interfaces(self): """ Getter method for interfaces, mapped from YANG variable /macsec/interfaces (container) YANG Description: Enclosing container for the MACsec interfaces list """ return self.__interfaces
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _set_interfaces(self, v, load=False): """ Setter method for interfaces, mapped from YANG variable /macsec/interfaces (container) If this variable is read-only (config: false) in the source YANG file, then _set_interfaces is considered as a private method. Backends looking to populate this variab...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def __init__(self, *args, **kwargs): self._path_helper = False self._extmethods = False self.__macsec = YANGDynClass(base=yc_macsec_openconfig_macsec__macsec, is_container='container', yang_name="macsec", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensi...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _get_macsec(self): """ Getter method for macsec, mapped from YANG variable /macsec (container) YANG Description: The MACsec """ return self.__macsec
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def _set_macsec(self, v, load=False): """ Setter method for macsec, mapped from YANG variable /macsec (container) If this variable is read-only (config: false) in the source YANG file, then _set_macsec is considered as a private method. Backends looking to populate this variable should do so via...
google/gnxi
[ 229, 110, 229, 19, 1506413981 ]
def train_sequence_model(data, learning_rate=1e-3, epochs=1000, batch_size=128, blocks=2, filters=64, dropout_rate=0.2, embedding_dim=200, ...
google/eng-edu
[ 659, 382, 659, 6, 1486495587 ]
def __init__(self, name, formatter=None): super(FileCodec, self).__init__(name, formatter=formatter) self.extension = 'must-have-extension'
google/compare-codecs
[ 43, 22, 43, 30, 1418056941 ]
def _DecodeFile(self, videofile, encodedfile, workdir): tempyuvfile = os.path.join(workdir, videofile.basename + 'tempyuvfile.yuv') if os.path.isfile(tempyuvfile): print "Removing tempfile before decode:", tempyuvfile os.unlink(tempyuvfile) commandline = self.Decod...
google/compare-codecs
[ 43, 22, 43, 30, 1418056941 ]
def EncodeCommandLine(self, parameters, bitrate, videofile, encodedfile): """This function returns the command line that should be executed in order to turn an YUV file into an encoded file.""" # pylint: disable=W0613,R0201 raise encoder.Error('EncodeCommandLine not defined')
google/compare-codecs
[ 43, 22, 43, 30, 1418056941 ]
def ResultData(self, encodedfile): """Returns additional fields that the codec may know how to generate.""" # pylint: disable=W0613,R0201 return {}
google/compare-codecs
[ 43, 22, 43, 30, 1418056941 ]
def EncoderVersion(self): raise encoder.Error('File codecs must define their own version')
google/compare-codecs
[ 43, 22, 43, 30, 1418056941 ]
def MatroskaFrameInfo(encodedfile): # Run the mkvinfo tool across the file to get frame size info. commandline = 'mkvinfo -v %s' % encodedfile print commandline mkvinfo = subprocess.check_output(commandline, shell=True) frameinfo = [] for line in mkvinfo.splitlines(): match = re.search(r'Frame with size...
google/compare-codecs
[ 43, 22, 43, 30, 1418056941 ]
def run_in_shell(cmd): subprocess.check_call(cmd, shell=True)
miracl/amcl
[ 29, 19, 29, 7, 1549367563 ]
def rsaset(tb,tff,nb,base,ml) : bd=tb+"_"+base fnameh="config_big_"+bd+".h" run_in_shell(copytext+" config_big.h "+fnameh) replace(fnameh,"XXX",bd) replace(fnameh,"@NB@",nb) replace(fnameh,"@BASE@",base) fnameh="config_ff_"+tff+".h" run_in_shell(copytext+" config_ff.h "+fnameh) replace(fnameh,"XXX",bd) repla...
miracl/amcl
[ 29, 19, 29, 7, 1549367563 ]
def generate_custom_fields(): CustomField.objects.get_or_create( name='function_name', defaults={'label': 'function name', 'type': 'STR', 'show_as_attribute': True, 'description': 'Name given to the Google Cloud function'} ) CustomField.objects.get_or_create( ...
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def generate_options_for_env_id(server=None, **kwargs): gcp_envs = Environment.objects.filter( resource_handler__resource_technology__name="Google Cloud Platform") options = [] for env in gcp_envs: options.append((env.id, env.name)) if not options: raise RuntimeError("No valid Go...
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def generate_options_for_bucket_to_store_sourcecode(control_value=None, **kwargs): buckets = [] if control_value: environment = Environment.objects.get(id=control_value) project_id=environment.gcp_project rh = environment.resource_handler.cast() project=rh.gcp_projects.get(id=pro...
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def generate_options_for_available_memory_mb(**kwargs): return [ (128, '128 MB'), (256, '256 MB'), (512, '512 MB'), (1024, '1 GB'), (2048, '2 GB'), ]
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def create_build_client(rh,project_id,servicename): '''method to create cloud build client for given service''' account_info = json.loads(rh.gcp_projects.get(id=project_id).service_account_info) credentials=service_account.Credentials.from_service_account_info(account_info) client=build(servicename, "v...
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def create_file_with_sourcecode(sourcecode): # Creates a temporary file containing the sourcecode passed. path=sourcecode filename=Path(sourcecode).name if path.startswith(settings.MEDIA_URL): set_progress("Converting relative URL to filesystem path") path = path.replace(settings.MEDIA_U...
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def run(resource, logger=None, **kwargs): environment = Environment.objects.get(id='{{ env_id }}') function_name = '{{ function_name }}' source_code = """{{ source_code }}""" entry_point = '{{ entry_point }}' available_memory_mb = '{{ available_memory_mb }}' runtime = '{{ runtime }}' bucket ...
CloudBoltSoftware/cloudbolt-forge
[ 34, 32, 34, 16, 1437063482 ]
def __init__(self, accounts=None, debug=False): super(ElasticSearchService, self).__init__(accounts=accounts, debug=debug)
stackArmor/security_monkey
[ 1, 2, 1, 2, 1512311697 ]
def slurp_items(**kwargs): item_list = [] exception_map = {} kwargs['exception_map'] = exception_map account_db = Account.query.filter(Account.name == kwargs['account_name']).first() account_num = account_db.identifier es_info = self.get_all_es_d...
stackArmor/security_monkey
[ 1, 2, 1, 2, 1512311697 ]
def get_all_es_domains_in_region(self, **kwargs): from security_monkey.common.sts_connect import connect client = connect(kwargs['account_name'], "boto3.es.client", region=kwargs['region']) app.logger.debug("Checking {}/{}/{}".format(ElasticSearchService.index, kwargs['account_name'], kwargs['re...
stackArmor/security_monkey
[ 1, 2, 1, 2, 1512311697 ]
def build_item(self, domain, client, account_num, **kwargs): arn = ARN_PREFIX + ':es:{region}:{account_number}:domain/{domain_name}'.format( region=kwargs['region'], account_number=account_num, domain_name=domain) config = { 'arn': arn } ...
stackArmor/security_monkey
[ 1, 2, 1, 2, 1512311697 ]
def setup_db(): dbpath = os.path.dirname(os.path.realpath(__file__)) + os.sep +".."+os.sep+"gitdox.db" conn = sqlite3.connect(dbpath) cur = conn.cursor() # Drop tables if they exist cur.execute("DROP TABLE IF EXISTS docs") cur.execute("DROP TABLE IF EXISTS users") cur.execute("DROP TABLE IF EXISTS metadata") cu...
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def generic_query(sql, params, return_new_id=False): # generic_query("DELETE FROM rst_nodes WHERE doc=? and project=?",(doc,project)) dbpath = os.path.dirname(os.path.realpath(__file__)) + os.sep + ".." + os.sep + "gitdox.db" conn = sqlite3.connect(dbpath) with conn: cur = conn.cursor() if params is not None:...
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def invalidate_ether_docs(doc,corpus): generic_query("UPDATE docs SET validation=NULL WHERE name like ? and corpus like ? and mode = 'ether'", (doc, corpus))
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def doc_exists(doc,corpus): res = generic_query("SELECT name from docs where name=? and corpus=?",(doc,corpus)) return len(res) > 0
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def update_assignee(doc_id,user_name): generic_query("UPDATE docs SET assignee_username=? WHERE id=?",(user_name,doc_id))
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def update_docname(id,docname): generic_query("UPDATE docs SET name=? WHERE id=?",(docname,id)) invalidate_doc_by_id(id)
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def update_corpus(id,corpusname): generic_query("UPDATE docs SET corpus=? WHERE id=?",(corpusname,id)) invalidate_doc_by_id(id)
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def update_schema(id, schema): generic_query("UPDATE docs SET schema=? WHERE id=?", (schema, id))
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def cell(text): if isinstance(text, int): text = str(text) return "\n <td>" + text + "</td>"
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def save_meta(doc_id,key,value,corpus=False): if corpus: _, corpus_name, _, _, _, _, _ = get_doc_info(doc_id) new_id = generic_query("REPLACE INTO metadata(docid,key,value,corpus_meta) VALUES(?,?,?,?)", (None, key, value,corpus_name), return_new_id = True) else: new_id = generic_query("INSERT OR REPLACE INTO me...
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def get_doc_info(doc_id): res = generic_query("SELECT name,corpus,filename,status,assignee_username,mode,schema FROM docs WHERE id=?", (int(doc_id),)) if len(res) > 0: return res[0] else: return res
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def get_all_doc_ids_for_corpus(corpus): return map(lambda x: x[0], generic_query("SELECT id FROM docs WHERE corpus=?", (corpus,)))
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def get_doc_meta(doc_id, corpus=False): if corpus: fields = get_doc_info(doc_id) if len(fields) > 0: _, corpus_name, _, _, _, _, _ = fields return generic_query("SELECT * FROM metadata WHERE corpus_meta=? ORDER BY key COLLATE NOCASE",(corpus_name,)) else: return [] else: return generic_query("SELECT ...
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def get_validate_rules(sort=None, domain=None): query = "SELECT corpus, doc, domain, name, operator, argument, id FROM validate" args = [] if domain: query += " WHERE domain=? " args.append(domain) if sort: query += " ORDER BY " + sort return generic_query(query, args)
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def get_xml_rules(): return get_validate_rules(domain='xml')
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def get_ether_rules(): return get_validate_rules(domain='ether')
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def create_validate_rule(doc, corpus, domain, name, operator, argument): new_id = generic_query("INSERT INTO validate(doc,corpus,domain,name,operator,argument) VALUES(?,?,?,?,?,?)", (doc, corpus, domain, name, operator, argument), return_new_id = True) if domain == "meta": invalidate_doc_by_name("%","%") else: i...
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def update_validate_rule(doc, corpus, domain, name, operator, argument, id): generic_query("UPDATE validate SET doc = ?, corpus = ?, domain = ?, name = ?, operator = ?, argument = ? WHERE id = ?",(doc, corpus, domain, name, operator, argument, id)) if domain == "meta": invalidate_doc_by_name("%", "%") else: inva...
cligu/gitdox
[ 13, 4, 13, 28, 1480629062 ]
def run_prepare_receptor_spark(receptor): receptor_pdbqt = os.path.join(pdbqt_receptor_path.value, get_name_model_pdb(receptor)) command = ''.join([pythonsh.value, ' ', script_receptor4.value, ...
rodrigofaccioli/drugdesign
[ 3, 6, 3, 6, 1417717511 ]
def get_test_environment(): global _test_env if _test_env: return _test_env _test_env = TestEnvironment(**DEFAULT_ENV) return _test_env
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def get_test_env_var(key: str, default: Optional[str] = None): test_env = get_test_environment() return test_env.get(key, default)
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def load_schema_file(path: Optional[str] = None) -> Dict: path = path or RELEASE_TEST_SCHEMA_FILE with open(path, "rt") as fp: return json.load(fp)
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def validate_test(test: Test, schema: Optional[Dict] = None) -> Optional[str]: schema = schema or load_schema_file() try: jsonschema.validate(test, schema=schema) except (jsonschema.ValidationError, jsonschema.SchemaError) as e: return str(e.message) except Exception as e: retur...
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def as_smoke_test(test: Test) -> Test: if "smoke_test" not in test: logger.warning( f"Requested smoke test, but test with name {test['name']} does " f"not have any smoke test configuration." ) return test smoke_test_config = test.pop("smoke_test") new_test = ...
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def load_and_render_yaml_template( template_path: str, env: Optional[Dict] = None
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def load_test_cluster_env(test: Test, ray_wheels_url: str) -> Optional[Dict]: cluster_env_file = test["cluster"]["cluster_env"] cluster_env_path = os.path.join( RELEASE_PACKAGE_DIR, test.get("working_dir", ""), cluster_env_file ) env = get_test_environment() commit = env.get("RAY_COMMIT", N...
ray-project/ray
[ 24488, 4264, 24488, 2914, 1477424310 ]
def add_partition_statements(partitions, bucket, table_name): """Generate ALTER TABLE commands from existing partitions. It wil yield Athena statement string(s), the length of each string should be less than Athena query statement length limit, 262144 bytes. https://docs.aws.amazon.com/athena/latest/ug/...
airbnb/streamalert
[ 2767, 342, 2767, 92, 1485047456 ]
def unique_values_from_query(query_result): """Simplify Athena query results into a set of values. Useful for listing tables, partitions, databases, enable_metrics Args: query_result (dict): The result of run_athena_query Returns: set: Unique values from the query result """ r...
airbnb/streamalert
[ 2767, 342, 2767, 92, 1485047456 ]
def generate_alerts_table_schema(): """Generate the schema for alerts table in terraform by using a fake alert Returns: athena_schema (dict): Equivalent Athena schema used for generating create table statement """ alert = Alert('temp_rule_name', {}, {}) output = alert.output_dict() sche...
airbnb/streamalert
[ 2767, 342, 2767, 92, 1485047456 ]
def WriteKeyPath(self, key_path): """Writes a key path to the output. Args: key_path (str): key path. """ text = '{0:s}\n'.format(key_path) self.WriteText(text)
libyal/winreg-kb
[ 122, 17, 122, 5, 1411881319 ]
def Main(): """The main program function. Returns: bool: True if successful or False if not. """ argument_parser = argparse.ArgumentParser(description=( 'Extracts a catalog of Windows Registry keys and values.')) argument_parser.add_argument( 'source', nargs='?', action='store', metavar='PAT...
libyal/winreg-kb
[ 122, 17, 122, 5, 1411881319 ]
def convertMAC(mac): newMac="%s%s:%s%s:%s%s:%s%s:%s%s:%s%s" % (mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9],mac[10],mac[11]) return newMac
TravisFSmith/SweetSecurity
[ 754, 196, 754, 40, 1441859311 ]
def main(): hc2 = Client( 'v3', 'http://192.168.1.230/api/', 'admin', 'admin' ) info = hc2.info.get() print info weather = hc2.weather.get() print weather login = hc2.login.get() print login devices = hc2.devices.get(1) print devices devic...
kstaniek/fiblary
[ 9, 16, 9, 3, 1390870365 ]
def generate_jobstep_data(): # this must generic a *valid* dataset that should result in a full # run return { 'status': {'id': 'queued'}, 'data': {}, 'expectedSnapshot': None, 'snapshot': { 'id': 'a1028849e8cf4ff0a7d7fdfe3c4fe925', }, }
dropbox/changes-lxc-wrapper
[ 8, 7, 8, 3, 1405481019 ]
def teardown_function(function): assert threading.activeCount() == 1
dropbox/changes-lxc-wrapper
[ 8, 7, 8, 3, 1405481019 ]
def test_local_run(mock_run): command = WrapperCommand([ '--', 'echo 1', ]) command.run() mock_run.assert_called_once_with( release='precise', post_launch=None, snapshot=None, save_snapshot=False, s3_bucket=None, pre_launch=None, validate=...
dropbox/changes-lxc-wrapper
[ 8, 7, 8, 3, 1405481019 ]
def test_remote_run(mock_run, mock_api_cls): jobstep_id = uuid4() jobstep_data = generate_jobstep_data() mock_api = mock_api_cls.return_value mock_api.get_jobstep.return_value = jobstep_data command = WrapperCommand([ '--jobstep-id', jobstep_id.hex, '--api-url', 'http://changes.ex...
dropbox/changes-lxc-wrapper
[ 8, 7, 8, 3, 1405481019 ]
def test_already_finished_job(mock_run, mock_api_cls): jobstep_id = uuid4() jobstep_data = generate_jobstep_data() jobstep_data['status']['id'] = 'finished' mock_api = mock_api_cls.return_value mock_api.get_jobstep.return_value = jobstep_data command = WrapperCommand([ '--jobstep-id',...
dropbox/changes-lxc-wrapper
[ 8, 7, 8, 3, 1405481019 ]
def test_image_export_reference(exporters, state, bpy_image_default, gltf_image_default): state['settings']['images_data_storage'] = 'REFERENCE' gltf_image_default['uri'] = '../filepath.png' output = exporters.ImageExporter.export(state, bpy_image_default) assert output == gltf_image_default
Kupoman/blendergltf
[ 314, 50, 314, 14, 1455166435 ]
def test_image_export_embed_glb(exporters, state, bpy_image_default, gltf_image_default): state['settings']['images_data_storage'] = 'EMBED' state['settings']['gltf_export_binary'] = True gltf_image_default['mimeType'] = 'image/png' gltf_image_default['bufferView'] = 'bufferView_buffer_Image_0' out...
Kupoman/blendergltf
[ 314, 50, 314, 14, 1455166435 ]
def test_image_check(exporters, state, bpy_image_default): assert exporters.ImageExporter.check(state, bpy_image_default)
Kupoman/blendergltf
[ 314, 50, 314, 14, 1455166435 ]
def test_image_check_0_x(exporters, state, bpy_image_default): bpy_image_default.size = [0, 1] assert exporters.ImageExporter.check(state, bpy_image_default) is not True
Kupoman/blendergltf
[ 314, 50, 314, 14, 1455166435 ]
def get_active_topics(host=TASR_HOST, port=TASR_PORT, timeout=TIMEOUT): ''' GET /tasr/active_topics Retrieves available metadata for active topics (i.e. -- groups) with registered schemas. A dict of <topic name>:<topic metadata> is returned. ''' url = 'http://%s:%s/tasr/active_topics' % (host, port...
ifwe/tasr
[ 5, 1, 5, 1, 1435712483 ]
def register_schema(topic_name, schema_str, host=TASR_HOST, port=TASR_PORT, timeout=TIMEOUT): ''' PUT /tasr/topic/<topic name> Register a schema string for a topic. Returns a SchemaMetadata object with the topic-version, topic-timestamp and ID metadata. ''' url = 'http://%...
ifwe/tasr
[ 5, 1, 5, 1, 1435712483 ]
def get_schema_version(topic_name, version, host=TASR_HOST, port=TASR_PORT, timeout=TIMEOUT): ''' GET /tasr/topic/<topic name>/version/<version> Retrieve a specific schema registered for the given topic name identified by a version (a positive integer). Returns a RegisteredSchema obj...
ifwe/tasr
[ 5, 1, 5, 1, 1435712483 ]
def schema_for_schema_str(schema_str, object_on_miss=False, host=TASR_HOST, port=TASR_PORT, timeout=TIMEOUT): ''' POST /tasr/schema In essence this is very similar to the schema_for_id_str, but with the calculation of the ID string being moved to the server. That is, the c...
ifwe/tasr
[ 5, 1, 5, 1, 1435712483 ]
def __init__(self, host=TASR_HOST, port=TASR_PORT, timeout=TIMEOUT): self.host = host self.port = port self.timeout = timeout
ifwe/tasr
[ 5, 1, 5, 1, 1435712483 ]
def get_active_topics(self): '''Returns a dict of <topic name>:<metadata> for active topics.''' return get_active_topics(self.host, self.port, self.timeout)
ifwe/tasr
[ 5, 1, 5, 1, 1435712483 ]
def register_schema(self, topic_name, schema_str): '''Register a schema for a topic''' return register_schema(topic_name, schema_str)
ifwe/tasr
[ 5, 1, 5, 1, 1435712483 ]
def get_schema_version(self, topic_name, version=None): '''Get a schema by version for the topic''' return get_schema_version(topic_name, version, self.host, self.port, self.timeout)
ifwe/tasr
[ 5, 1, 5, 1, 1435712483 ]
def test_constructor_and_read_properties(self): sd = ShapeDtype((2, 3), np.int32) self.assertEqual(sd.shape, (2, 3)) self.assertEqual(sd.dtype, np.int32)
google/trax
[ 7391, 769, 7391, 106, 1570288154 ]
def test_signature_on_ndarray(self): array = np.array([[2, 3, 5, 7], [11, 13, 17, 19]], dtype=np.int16) sd = shapes.signature(array) self.assertEqual(sd.shape, (2, 4)) self.assertEqual(sd.dtype, np.int16)
google/trax
[ 7391, 769, 7391, 106, 1570288154 ]
def test_splice_signatures(self): sd1 = ShapeDtype((1,)) sd2 = ShapeDtype((2,)) sd3 = ShapeDtype((3,)) sd4 = ShapeDtype((4,)) sd5 = ShapeDtype((5,)) # Signatures can be ShapeDtype instances, tuples of 2+ ShapeDtype instances, # or empty tuples. sig1 = sd1 sig2 = (sd2, sd3, sd4) ...
google/trax
[ 7391, 769, 7391, 106, 1570288154 ]
def run_test (cmd, *args): cmd = PJ ('tests', cmd) p = subprocess.Popen ([cmd] + list(args), stdout=subprocess.PIPE) out = p.stdout.read() return out
samrushing/irken-compiler
[ 207, 16, 207, 36, 1305764021 ]
def test_t_dump_image(): # generate the output run_test ('t_dump_image') # load the image and run it exp0 = run_test ('t_dump_image','-l') exp1 = open ('tests/t_dump_image.exp').read() assert (exp0 == exp1)
samrushing/irken-compiler
[ 207, 16, 207, 36, 1305764021 ]
def test_t22(): out = run_test ('t22') lines = out.split ('\n') assert (lines[0].count ('<closure pc=') == 5) r6 = [ str(x) for x in range (6) ] assert (lines[1:] == (r6 + r6 + ['#u', '']))
samrushing/irken-compiler
[ 207, 16, 207, 36, 1305764021 ]
def test_t_vm(): out = run_test ('t_vm', 'vm/tests/t11.byc') assert (out.split()[-2:] == ['7', '#u'])
samrushing/irken-compiler
[ 207, 16, 207, 36, 1305764021 ]
def load_baseband_sweep_tones(ri, tone_banks, num_tone_samples): return ri.set_tone_freqs(freqs=np.vstack(tone_banks), nsamp=num_tone_samples)
ColumbiaCMB/kid_readout
[ 3, 7, 3, 3, 1370440123 ]
def run_sweep(ri, tone_banks, num_tone_samples, length_seconds=0, state=None, description='', verbose=False, wait_for_sync=0.1, **kwargs): """ Return a SweepArray acquired using the given tone banks. Parameters ---------- ri : RoachInterface An instance of a subclass. tone...
ColumbiaCMB/kid_readout
[ 3, 7, 3, 3, 1370440123 ]
def run_multipart_sweep(ri, length_seconds=0, state=None, description='', num_tones_read_at_once=32, verbose=False, **kwargs): num_tones = ri.tone_bins.shape[1] num_steps = num_tones // num_tones_read_at_once if num_steps == 0: num_steps = 1 indices_to_read = range(num_to...
ColumbiaCMB/kid_readout
[ 3, 7, 3, 3, 1370440123 ]
def script_code(): """ Return the source code of a module running as '__main__'. Acquisition scripts can use this to save their code. If attempting to load the source code raises an exception, return a string representation of the exception. Returns ------- str The code, with lines sep...
ColumbiaCMB/kid_readout
[ 3, 7, 3, 3, 1370440123 ]
def git_status(): import kid_readout kid_readout_directory = os.path.dirname(os.path.abspath(kid_readout.__file__)) try: return subprocess.check_output(("cd {}; git status --porcelain".format(kid_readout_directory)), shell=True) except Exception as e: return str(e)
ColumbiaCMB/kid_readout
[ 3, 7, 3, 3, 1370440123 ]
def new_nc_file(suffix='', directory=settings.BASE_DATA_DIR, metadata=None): if suffix and not suffix.startswith('_'): suffix = '_' + suffix if metadata is None: metadata = all_metadata() root_path = os.path.join(directory, time.strftime('%Y-%m-%d_%H%M%S') + suffix + nc.NCFile.EXTENSION) ...
ColumbiaCMB/kid_readout
[ 3, 7, 3, 3, 1370440123 ]
def show_settings(): print("cryostat: {}".format(settings.CRYOSTAT)) for k, v in settings.COOLDOWN.items(): print("{}: {}".format(k, v)) raw_input("Press enter to continue or ctrl-C to quit.")
ColumbiaCMB/kid_readout
[ 3, 7, 3, 3, 1370440123 ]
def generate_leaf_updates(leaf_block, dist_thresholds, inds, indptr, data, dist): updates = [[(-1, -1, np.inf)] for i in range(leaf_block.shape[0])] for n in numba.prange(leaf_block.shape[0]): for i in range(leaf_block.shape[1]): p = leaf_block[n, i] if p < 0: b...
lmcinnes/pynndescent
[ 731, 93, 731, 58, 1518045834 ]
def init_rp_tree(inds, indptr, data, dist, current_graph, leaf_array): n_leaves = leaf_array.shape[0] block_size = 65536 n_blocks = n_leaves // block_size for i in range(n_blocks + 1): block_start = i * block_size block_end = min(n_leaves, (i + 1) * block_size) leaf_block = le...
lmcinnes/pynndescent
[ 731, 93, 731, 58, 1518045834 ]