repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/models.py
Model.set_database
def set_database(self, db): ''' Sets the `Database` that this model instance belongs to. This is done automatically when the instance is read from the database or written to it. ''' # This can not be imported globally due to circular import from .database import Database ...
python
def set_database(self, db): ''' Sets the `Database` that this model instance belongs to. This is done automatically when the instance is read from the database or written to it. ''' # This can not be imported globally due to circular import from .database import Database ...
[ "def", "set_database", "(", "self", ",", "db", ")", ":", "# This can not be imported globally due to circular import", "from", ".", "database", "import", "Database", "assert", "isinstance", "(", "db", ",", "Database", ")", ",", "\"database must be database.Database instan...
Sets the `Database` that this model instance belongs to. This is done automatically when the instance is read from the database or written to it.
[ "Sets", "the", "Database", "that", "this", "model", "instance", "belongs", "to", ".", "This", "is", "done", "automatically", "when", "the", "instance", "is", "read", "from", "the", "database", "or", "written", "to", "it", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/models.py#L153-L161
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/models.py
Model.from_tsv
def from_tsv(cls, line, field_names, timezone_in_use=pytz.utc, database=None): ''' Create a model instance from a tab-separated line. The line may or may not include a newline. The `field_names` list must match the fields defined in the model, but does not have to include all of them. -...
python
def from_tsv(cls, line, field_names, timezone_in_use=pytz.utc, database=None): ''' Create a model instance from a tab-separated line. The line may or may not include a newline. The `field_names` list must match the fields defined in the model, but does not have to include all of them. -...
[ "def", "from_tsv", "(", "cls", ",", "line", ",", "field_names", ",", "timezone_in_use", "=", "pytz", ".", "utc", ",", "database", "=", "None", ")", ":", "from", "six", "import", "next", "values", "=", "iter", "(", "parse_tsv", "(", "line", ")", ")", ...
Create a model instance from a tab-separated line. The line may or may not include a newline. The `field_names` list must match the fields defined in the model, but does not have to include all of them. - `line`: the TSV-formatted data. - `field_names`: names of the model fields in the data. ...
[ "Create", "a", "model", "instance", "from", "a", "tab", "-", "separated", "line", ".", "The", "line", "may", "or", "may", "not", "include", "a", "newline", ".", "The", "field_names", "list", "must", "match", "the", "fields", "defined", "in", "the", "mode...
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/models.py#L207-L228
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/models.py
Model.to_tsv
def to_tsv(self, include_readonly=True): ''' Returns the instance's column values as a tab-separated line. A newline is not included. - `include_readonly`: if false, returns only fields that can be inserted into database. ''' data = self.__dict__ fields = self.fields(wri...
python
def to_tsv(self, include_readonly=True): ''' Returns the instance's column values as a tab-separated line. A newline is not included. - `include_readonly`: if false, returns only fields that can be inserted into database. ''' data = self.__dict__ fields = self.fields(wri...
[ "def", "to_tsv", "(", "self", ",", "include_readonly", "=", "True", ")", ":", "data", "=", "self", ".", "__dict__", "fields", "=", "self", ".", "fields", "(", "writable", "=", "not", "include_readonly", ")", "return", "'\\t'", ".", "join", "(", "field", ...
Returns the instance's column values as a tab-separated line. A newline is not included. - `include_readonly`: if false, returns only fields that can be inserted into database.
[ "Returns", "the", "instance", "s", "column", "values", "as", "a", "tab", "-", "separated", "line", ".", "A", "newline", "is", "not", "included", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/models.py#L230-L238
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/models.py
Model.to_dict
def to_dict(self, include_readonly=True, field_names=None): ''' Returns the instance's column values as a dict. - `include_readonly`: if false, returns only fields that can be inserted into database. - `field_names`: an iterable of field names to return (optional) ''' fi...
python
def to_dict(self, include_readonly=True, field_names=None): ''' Returns the instance's column values as a dict. - `include_readonly`: if false, returns only fields that can be inserted into database. - `field_names`: an iterable of field names to return (optional) ''' fi...
[ "def", "to_dict", "(", "self", ",", "include_readonly", "=", "True", ",", "field_names", "=", "None", ")", ":", "fields", "=", "self", ".", "fields", "(", "writable", "=", "not", "include_readonly", ")", "if", "field_names", "is", "not", "None", ":", "fi...
Returns the instance's column values as a dict. - `include_readonly`: if false, returns only fields that can be inserted into database. - `field_names`: an iterable of field names to return (optional)
[ "Returns", "the", "instance", "s", "column", "values", "as", "a", "dict", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/models.py#L240-L253
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/utils.py
import_submodules
def import_submodules(package_name): """ Import all submodules of a module. """ import importlib, pkgutil package = importlib.import_module(package_name) return { name: importlib.import_module(package_name + '.' + name) for _, name, _ in pkgutil.iter_modules(package.__path__) ...
python
def import_submodules(package_name): """ Import all submodules of a module. """ import importlib, pkgutil package = importlib.import_module(package_name) return { name: importlib.import_module(package_name + '.' + name) for _, name, _ in pkgutil.iter_modules(package.__path__) ...
[ "def", "import_submodules", "(", "package_name", ")", ":", "import", "importlib", ",", "pkgutil", "package", "=", "importlib", ".", "import_module", "(", "package_name", ")", "return", "{", "name", ":", "importlib", ".", "import_module", "(", "package_name", "+"...
Import all submodules of a module.
[ "Import", "all", "submodules", "of", "a", "module", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/utils.py#L84-L93
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
ServerError.get_error_code_msg
def get_error_code_msg(cls, full_error_message): """ Extract the code and message of the exception that clickhouse-server generated. See the list of error codes here: https://github.com/yandex/ClickHouse/blob/master/dbms/src/Common/ErrorCodes.cpp """ for pattern in cls.E...
python
def get_error_code_msg(cls, full_error_message): """ Extract the code and message of the exception that clickhouse-server generated. See the list of error codes here: https://github.com/yandex/ClickHouse/blob/master/dbms/src/Common/ErrorCodes.cpp """ for pattern in cls.E...
[ "def", "get_error_code_msg", "(", "cls", ",", "full_error_message", ")", ":", "for", "pattern", "in", "cls", ".", "ERROR_PATTERNS", ":", "match", "=", "pattern", ".", "match", "(", "full_error_message", ")", "if", "match", ":", "# assert match.group('type1') == ma...
Extract the code and message of the exception that clickhouse-server generated. See the list of error codes here: https://github.com/yandex/ClickHouse/blob/master/dbms/src/Common/ErrorCodes.cpp
[ "Extract", "the", "code", "and", "message", "of", "the", "exception", "that", "clickhouse", "-", "server", "generated", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L58-L71
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.create_table
def create_table(self, model_class): ''' Creates a table for the given model class, if it does not exist already. ''' if model_class.is_system_model(): raise DatabaseException("You can't create system table") if getattr(model_class, 'engine') is None: rais...
python
def create_table(self, model_class): ''' Creates a table for the given model class, if it does not exist already. ''' if model_class.is_system_model(): raise DatabaseException("You can't create system table") if getattr(model_class, 'engine') is None: rais...
[ "def", "create_table", "(", "self", ",", "model_class", ")", ":", "if", "model_class", ".", "is_system_model", "(", ")", ":", "raise", "DatabaseException", "(", "\"You can't create system table\"", ")", "if", "getattr", "(", "model_class", ",", "'engine'", ")", ...
Creates a table for the given model class, if it does not exist already.
[ "Creates", "a", "table", "for", "the", "given", "model", "class", "if", "it", "does", "not", "exist", "already", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L136-L144
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.drop_table
def drop_table(self, model_class): ''' Drops the database table of the given model class, if it exists. ''' if model_class.is_system_model(): raise DatabaseException("You can't drop system table") self._send(model_class.drop_table_sql(self))
python
def drop_table(self, model_class): ''' Drops the database table of the given model class, if it exists. ''' if model_class.is_system_model(): raise DatabaseException("You can't drop system table") self._send(model_class.drop_table_sql(self))
[ "def", "drop_table", "(", "self", ",", "model_class", ")", ":", "if", "model_class", ".", "is_system_model", "(", ")", ":", "raise", "DatabaseException", "(", "\"You can't drop system table\"", ")", "self", ".", "_send", "(", "model_class", ".", "drop_table_sql", ...
Drops the database table of the given model class, if it exists.
[ "Drops", "the", "database", "table", "of", "the", "given", "model", "class", "if", "it", "exists", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L146-L152
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.does_table_exist
def does_table_exist(self, model_class): ''' Checks whether a table for the given model class already exists. Note that this only checks for existence of a table with the expected name. ''' sql = "SELECT count() FROM system.tables WHERE database = '%s' AND name = '%s'" r ...
python
def does_table_exist(self, model_class): ''' Checks whether a table for the given model class already exists. Note that this only checks for existence of a table with the expected name. ''' sql = "SELECT count() FROM system.tables WHERE database = '%s' AND name = '%s'" r ...
[ "def", "does_table_exist", "(", "self", ",", "model_class", ")", ":", "sql", "=", "\"SELECT count() FROM system.tables WHERE database = '%s' AND name = '%s'\"", "r", "=", "self", ".", "_send", "(", "sql", "%", "(", "self", ".", "db_name", ",", "model_class", ".", ...
Checks whether a table for the given model class already exists. Note that this only checks for existence of a table with the expected name.
[ "Checks", "whether", "a", "table", "for", "the", "given", "model", "class", "already", "exists", ".", "Note", "that", "this", "only", "checks", "for", "existence", "of", "a", "table", "with", "the", "expected", "name", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L154-L161
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.insert
def insert(self, model_instances, batch_size=1000): ''' Insert records into the database. - `model_instances`: any iterable containing instances of a single model class. - `batch_size`: number of records to send per chunk (use a lower number if your records are very large). ''' ...
python
def insert(self, model_instances, batch_size=1000): ''' Insert records into the database. - `model_instances`: any iterable containing instances of a single model class. - `batch_size`: number of records to send per chunk (use a lower number if your records are very large). ''' ...
[ "def", "insert", "(", "self", ",", "model_instances", ",", "batch_size", "=", "1000", ")", ":", "from", "six", "import", "next", "from", "io", "import", "BytesIO", "i", "=", "iter", "(", "model_instances", ")", "try", ":", "first_instance", "=", "next", ...
Insert records into the database. - `model_instances`: any iterable containing instances of a single model class. - `batch_size`: number of records to send per chunk (use a lower number if your records are very large).
[ "Insert", "records", "into", "the", "database", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L177-L222
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.count
def count(self, model_class, conditions=None): ''' Counts the number of records in the model's table. - `model_class`: the model to count. - `conditions`: optional SQL conditions (contents of the WHERE clause). ''' query = 'SELECT count() FROM $table' if conditio...
python
def count(self, model_class, conditions=None): ''' Counts the number of records in the model's table. - `model_class`: the model to count. - `conditions`: optional SQL conditions (contents of the WHERE clause). ''' query = 'SELECT count() FROM $table' if conditio...
[ "def", "count", "(", "self", ",", "model_class", ",", "conditions", "=", "None", ")", ":", "query", "=", "'SELECT count() FROM $table'", "if", "conditions", ":", "query", "+=", "' WHERE '", "+", "conditions", "query", "=", "self", ".", "_substitute", "(", "q...
Counts the number of records in the model's table. - `model_class`: the model to count. - `conditions`: optional SQL conditions (contents of the WHERE clause).
[ "Counts", "the", "number", "of", "records", "in", "the", "model", "s", "table", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L224-L236
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.select
def select(self, query, model_class=None, settings=None): ''' Performs a query and returns a generator of model instances. - `query`: the SQL query to execute. - `model_class`: the model class matching the query's table, or `None` for getting back instances of an ad-hoc model....
python
def select(self, query, model_class=None, settings=None): ''' Performs a query and returns a generator of model instances. - `query`: the SQL query to execute. - `model_class`: the model class matching the query's table, or `None` for getting back instances of an ad-hoc model....
[ "def", "select", "(", "self", ",", "query", ",", "model_class", "=", "None", ",", "settings", "=", "None", ")", ":", "query", "+=", "' FORMAT TabSeparatedWithNamesAndTypes'", "query", "=", "self", ".", "_substitute", "(", "query", ",", "model_class", ")", "r...
Performs a query and returns a generator of model instances. - `query`: the SQL query to execute. - `model_class`: the model class matching the query's table, or `None` for getting back instances of an ad-hoc model. - `settings`: query settings to send as HTTP GET parameters
[ "Performs", "a", "query", "and", "returns", "a", "generator", "of", "model", "instances", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L238-L257
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.raw
def raw(self, query, settings=None, stream=False): ''' Performs a query and returns its output as text. - `query`: the SQL query to execute. - `settings`: query settings to send as HTTP GET parameters - `stream`: if true, the HTTP response from ClickHouse will be streamed. ...
python
def raw(self, query, settings=None, stream=False): ''' Performs a query and returns its output as text. - `query`: the SQL query to execute. - `settings`: query settings to send as HTTP GET parameters - `stream`: if true, the HTTP response from ClickHouse will be streamed. ...
[ "def", "raw", "(", "self", ",", "query", ",", "settings", "=", "None", ",", "stream", "=", "False", ")", ":", "query", "=", "self", ".", "_substitute", "(", "query", ",", "None", ")", "return", "self", ".", "_send", "(", "query", ",", "settings", "...
Performs a query and returns its output as text. - `query`: the SQL query to execute. - `settings`: query settings to send as HTTP GET parameters - `stream`: if true, the HTTP response from ClickHouse will be streamed.
[ "Performs", "a", "query", "and", "returns", "its", "output", "as", "text", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L259-L268
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.paginate
def paginate(self, model_class, order_by, page_num=1, page_size=100, conditions=None, settings=None): ''' Selects records and returns a single page of model instances. - `model_class`: the model class matching the query's table, or `None` for getting back instances of an ad-hoc model....
python
def paginate(self, model_class, order_by, page_num=1, page_size=100, conditions=None, settings=None): ''' Selects records and returns a single page of model instances. - `model_class`: the model class matching the query's table, or `None` for getting back instances of an ad-hoc model....
[ "def", "paginate", "(", "self", ",", "model_class", ",", "order_by", ",", "page_num", "=", "1", ",", "page_size", "=", "100", ",", "conditions", "=", "None", ",", "settings", "=", "None", ")", ":", "count", "=", "self", ".", "count", "(", "model_class"...
Selects records and returns a single page of model instances. - `model_class`: the model class matching the query's table, or `None` for getting back instances of an ad-hoc model. - `order_by`: columns to use for sorting the query (contents of the ORDER BY clause). - `page_num`: the p...
[ "Selects", "records", "and", "returns", "a", "single", "page", "of", "model", "instances", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L270-L304
train
Infinidat/infi.clickhouse_orm
src/infi/clickhouse_orm/database.py
Database.migrate
def migrate(self, migrations_package_name, up_to=9999): ''' Executes schema migrations. - `migrations_package_name` - fully qualified name of the Python package containing the migrations. - `up_to` - number of the last migration to apply. ''' from .migrations i...
python
def migrate(self, migrations_package_name, up_to=9999): ''' Executes schema migrations. - `migrations_package_name` - fully qualified name of the Python package containing the migrations. - `up_to` - number of the last migration to apply. ''' from .migrations i...
[ "def", "migrate", "(", "self", ",", "migrations_package_name", ",", "up_to", "=", "9999", ")", ":", "from", ".", "migrations", "import", "MigrationHistory", "logger", "=", "logging", ".", "getLogger", "(", "'migrations'", ")", "applied_migrations", "=", "self", ...
Executes schema migrations. - `migrations_package_name` - fully qualified name of the Python package containing the migrations. - `up_to` - number of the last migration to apply.
[ "Executes", "schema", "migrations", "." ]
595f2023e334e3925a5c3fbfdd6083a5992a7169
https://github.com/Infinidat/infi.clickhouse_orm/blob/595f2023e334e3925a5c3fbfdd6083a5992a7169/src/infi/clickhouse_orm/database.py#L306-L325
train
pyusb/pyusb
usb/core.py
_try_get_string
def _try_get_string(dev, index, langid = None, default_str_i0 = "", default_access_error = "Error Accessing String"): """ try to get a string, but return a string no matter what """ if index == 0 : string = default_str_i0 else: try: if langid is None: ...
python
def _try_get_string(dev, index, langid = None, default_str_i0 = "", default_access_error = "Error Accessing String"): """ try to get a string, but return a string no matter what """ if index == 0 : string = default_str_i0 else: try: if langid is None: ...
[ "def", "_try_get_string", "(", "dev", ",", "index", ",", "langid", "=", "None", ",", "default_str_i0", "=", "\"\"", ",", "default_access_error", "=", "\"Error Accessing String\"", ")", ":", "if", "index", "==", "0", ":", "string", "=", "default_str_i0", "else"...
try to get a string, but return a string no matter what
[ "try", "to", "get", "a", "string", "but", "return", "a", "string", "no", "matter", "what" ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L52-L66
train
pyusb/pyusb
usb/core.py
_try_lookup
def _try_lookup(table, value, default = ""): """ try to get a string from the lookup table, return "" instead of key error """ try: string = table[ value ] except KeyError: string = default return string
python
def _try_lookup(table, value, default = ""): """ try to get a string from the lookup table, return "" instead of key error """ try: string = table[ value ] except KeyError: string = default return string
[ "def", "_try_lookup", "(", "table", ",", "value", ",", "default", "=", "\"\"", ")", ":", "try", ":", "string", "=", "table", "[", "value", "]", "except", "KeyError", ":", "string", "=", "default", "return", "string" ]
try to get a string from the lookup table, return "" instead of key error
[ "try", "to", "get", "a", "string", "from", "the", "lookup", "table", "return", "instead", "of", "key", "error" ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L68-L76
train
pyusb/pyusb
usb/core.py
find
def find(find_all=False, backend = None, custom_match = None, **args): r"""Find an USB device and return it. find() is the function used to discover USB devices. You can pass as arguments any combination of the USB Device Descriptor fields to match a device. For example: find(idVendor=0x3f4, idPr...
python
def find(find_all=False, backend = None, custom_match = None, **args): r"""Find an USB device and return it. find() is the function used to discover USB devices. You can pass as arguments any combination of the USB Device Descriptor fields to match a device. For example: find(idVendor=0x3f4, idPr...
[ "def", "find", "(", "find_all", "=", "False", ",", "backend", "=", "None", ",", "custom_match", "=", "None", ",", "*", "*", "args", ")", ":", "def", "device_iter", "(", "*", "*", "kwargs", ")", ":", "for", "dev", "in", "backend", ".", "enumerate_devi...
r"""Find an USB device and return it. find() is the function used to discover USB devices. You can pass as arguments any combination of the USB Device Descriptor fields to match a device. For example: find(idVendor=0x3f4, idProduct=0x2009) will return the Device object for the device with idVend...
[ "r", "Find", "an", "USB", "device", "and", "return", "it", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1179-L1273
train
pyusb/pyusb
usb/core.py
show_devices
def show_devices(verbose=False, **kwargs): """Show information about connected devices. The verbose flag sets to verbose or not. **kwargs are passed directly to the find() function. """ kwargs["find_all"] = True devices = find(**kwargs) strings = "" for device in devices: if not...
python
def show_devices(verbose=False, **kwargs): """Show information about connected devices. The verbose flag sets to verbose or not. **kwargs are passed directly to the find() function. """ kwargs["find_all"] = True devices = find(**kwargs) strings = "" for device in devices: if not...
[ "def", "show_devices", "(", "verbose", "=", "False", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"find_all\"", "]", "=", "True", "devices", "=", "find", "(", "*", "*", "kwargs", ")", "strings", "=", "\"\"", "for", "device", "in", "devices", "...
Show information about connected devices. The verbose flag sets to verbose or not. **kwargs are passed directly to the find() function.
[ "Show", "information", "about", "connected", "devices", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1275-L1291
train
pyusb/pyusb
usb/core.py
Device.langids
def langids(self): """ Return the USB device's supported language ID codes. These are 16-bit codes familiar to Windows developers, where for example instead of en-US you say 0x0409. USB_LANGIDS.pdf on the usb.org developer site for more info. String requests using a LANGID not i...
python
def langids(self): """ Return the USB device's supported language ID codes. These are 16-bit codes familiar to Windows developers, where for example instead of en-US you say 0x0409. USB_LANGIDS.pdf on the usb.org developer site for more info. String requests using a LANGID not i...
[ "def", "langids", "(", "self", ")", ":", "if", "self", ".", "_langids", "is", "None", ":", "try", ":", "self", ".", "_langids", "=", "util", ".", "get_langids", "(", "self", ")", "except", "USBError", ":", "self", ".", "_langids", "=", "(", ")", "r...
Return the USB device's supported language ID codes. These are 16-bit codes familiar to Windows developers, where for example instead of en-US you say 0x0409. USB_LANGIDS.pdf on the usb.org developer site for more info. String requests using a LANGID not in this array should not be sent...
[ "Return", "the", "USB", "device", "s", "supported", "language", "ID", "codes", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L794-L810
train
pyusb/pyusb
usb/core.py
Device.serial_number
def serial_number(self): """ Return the USB device's serial number string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use. """ if self._serial_number is None: self._serial_number = util....
python
def serial_number(self): """ Return the USB device's serial number string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use. """ if self._serial_number is None: self._serial_number = util....
[ "def", "serial_number", "(", "self", ")", ":", "if", "self", ".", "_serial_number", "is", "None", ":", "self", ".", "_serial_number", "=", "util", ".", "get_string", "(", "self", ",", "self", ".", "iSerialNumber", ")", "return", "self", ".", "_serial_numbe...
Return the USB device's serial number string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use.
[ "Return", "the", "USB", "device", "s", "serial", "number", "string", "descriptor", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L813-L821
train
pyusb/pyusb
usb/core.py
Device.product
def product(self): """ Return the USB device's product string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use. """ if self._product is None: self._product = util.get_string(self, self.iP...
python
def product(self): """ Return the USB device's product string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use. """ if self._product is None: self._product = util.get_string(self, self.iP...
[ "def", "product", "(", "self", ")", ":", "if", "self", ".", "_product", "is", "None", ":", "self", ".", "_product", "=", "util", ".", "get_string", "(", "self", ",", "self", ".", "iProduct", ")", "return", "self", ".", "_product" ]
Return the USB device's product string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use.
[ "Return", "the", "USB", "device", "s", "product", "string", "descriptor", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L824-L832
train
pyusb/pyusb
usb/core.py
Device.parent
def parent(self): """ Return the parent device. """ if self._has_parent is None: _parent = self._ctx.backend.get_parent(self._ctx.dev) self._has_parent = _parent is not None if self._has_parent: self._parent = Device(_parent, self._ctx.backend) ...
python
def parent(self): """ Return the parent device. """ if self._has_parent is None: _parent = self._ctx.backend.get_parent(self._ctx.dev) self._has_parent = _parent is not None if self._has_parent: self._parent = Device(_parent, self._ctx.backend) ...
[ "def", "parent", "(", "self", ")", ":", "if", "self", ".", "_has_parent", "is", "None", ":", "_parent", "=", "self", ".", "_ctx", ".", "backend", ".", "get_parent", "(", "self", ".", "_ctx", ".", "dev", ")", "self", ".", "_has_parent", "=", "_parent"...
Return the parent device.
[ "Return", "the", "parent", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L835-L844
train
pyusb/pyusb
usb/core.py
Device.manufacturer
def manufacturer(self): """ Return the USB device's manufacturer string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use. """ if self._manufacturer is None: self._manufacturer = util.get_...
python
def manufacturer(self): """ Return the USB device's manufacturer string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use. """ if self._manufacturer is None: self._manufacturer = util.get_...
[ "def", "manufacturer", "(", "self", ")", ":", "if", "self", ".", "_manufacturer", "is", "None", ":", "self", ".", "_manufacturer", "=", "util", ".", "get_string", "(", "self", ",", "self", ".", "iManufacturer", ")", "return", "self", ".", "_manufacturer" ]
Return the USB device's manufacturer string descriptor. This property will cause some USB traffic the first time it is accessed and cache the resulting value for future use.
[ "Return", "the", "USB", "device", "s", "manufacturer", "string", "descriptor", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L847-L855
train
pyusb/pyusb
usb/core.py
Device.set_interface_altsetting
def set_interface_altsetting(self, interface = None, alternate_setting = None): r"""Set the alternate setting for an interface. When you want to use an interface and it has more than one alternate setting, you should call this method to select the appropriate alternate setting. If you c...
python
def set_interface_altsetting(self, interface = None, alternate_setting = None): r"""Set the alternate setting for an interface. When you want to use an interface and it has more than one alternate setting, you should call this method to select the appropriate alternate setting. If you c...
[ "def", "set_interface_altsetting", "(", "self", ",", "interface", "=", "None", ",", "alternate_setting", "=", "None", ")", ":", "self", ".", "_ctx", ".", "managed_set_interface", "(", "self", ",", "interface", ",", "alternate_setting", ")" ]
r"""Set the alternate setting for an interface. When you want to use an interface and it has more than one alternate setting, you should call this method to select the appropriate alternate setting. If you call the method without one or the two parameters, it will be selected the first ...
[ "r", "Set", "the", "alternate", "setting", "for", "an", "interface", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L879-L904
train
pyusb/pyusb
usb/core.py
Device.reset
def reset(self): r"""Reset the device.""" self._ctx.managed_open() self._ctx.dispose(self, False) self._ctx.backend.reset_device(self._ctx.handle) self._ctx.dispose(self, True)
python
def reset(self): r"""Reset the device.""" self._ctx.managed_open() self._ctx.dispose(self, False) self._ctx.backend.reset_device(self._ctx.handle) self._ctx.dispose(self, True)
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_ctx", ".", "managed_open", "(", ")", "self", ".", "_ctx", ".", "dispose", "(", "self", ",", "False", ")", "self", ".", "_ctx", ".", "backend", ".", "reset_device", "(", "self", ".", "_ctx", ".",...
r"""Reset the device.
[ "r", "Reset", "the", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L913-L918
train
pyusb/pyusb
usb/core.py
Device.ctrl_transfer
def ctrl_transfer(self, bmRequestType, bRequest, wValue=0, wIndex=0, data_or_wLength = None, timeout = None): r"""Do a control transfer on the endpoint 0. This method is used to issue a control transfer over the endpoint 0 (endpoint 0 is required to always be a control endpoint). ...
python
def ctrl_transfer(self, bmRequestType, bRequest, wValue=0, wIndex=0, data_or_wLength = None, timeout = None): r"""Do a control transfer on the endpoint 0. This method is used to issue a control transfer over the endpoint 0 (endpoint 0 is required to always be a control endpoint). ...
[ "def", "ctrl_transfer", "(", "self", ",", "bmRequestType", ",", "bRequest", ",", "wValue", "=", "0", ",", "wIndex", "=", "0", ",", "data_or_wLength", "=", "None", ",", "timeout", "=", "None", ")", ":", "try", ":", "buff", "=", "util", ".", "create_buff...
r"""Do a control transfer on the endpoint 0. This method is used to issue a control transfer over the endpoint 0 (endpoint 0 is required to always be a control endpoint). The parameters bmRequestType, bRequest, wValue and wIndex are the same of the USB Standard Control Request format. ...
[ "r", "Do", "a", "control", "transfer", "on", "the", "endpoint", "0", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L999-L1053
train
pyusb/pyusb
usb/core.py
Device.is_kernel_driver_active
def is_kernel_driver_active(self, interface): r"""Determine if there is kernel driver associated with the interface. If a kernel driver is active, the object will be unable to perform I/O. The interface parameter is the device interface number to check. """ self._ctx.ma...
python
def is_kernel_driver_active(self, interface): r"""Determine if there is kernel driver associated with the interface. If a kernel driver is active, the object will be unable to perform I/O. The interface parameter is the device interface number to check. """ self._ctx.ma...
[ "def", "is_kernel_driver_active", "(", "self", ",", "interface", ")", ":", "self", ".", "_ctx", ".", "managed_open", "(", ")", "return", "self", ".", "_ctx", ".", "backend", ".", "is_kernel_driver_active", "(", "self", ".", "_ctx", ".", "handle", ",", "int...
r"""Determine if there is kernel driver associated with the interface. If a kernel driver is active, the object will be unable to perform I/O. The interface parameter is the device interface number to check.
[ "r", "Determine", "if", "there", "is", "kernel", "driver", "associated", "with", "the", "interface", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1055-L1066
train
pyusb/pyusb
usb/core.py
Device.detach_kernel_driver
def detach_kernel_driver(self, interface): r"""Detach a kernel driver. If successful, you will then be able to perform I/O. The interface parameter is the device interface number to detach the driver from. """ self._ctx.managed_open() self._ctx.backend.detach_ke...
python
def detach_kernel_driver(self, interface): r"""Detach a kernel driver. If successful, you will then be able to perform I/O. The interface parameter is the device interface number to detach the driver from. """ self._ctx.managed_open() self._ctx.backend.detach_ke...
[ "def", "detach_kernel_driver", "(", "self", ",", "interface", ")", ":", "self", ".", "_ctx", ".", "managed_open", "(", ")", "self", ".", "_ctx", ".", "backend", ".", "detach_kernel_driver", "(", "self", ".", "_ctx", ".", "handle", ",", "interface", ")" ]
r"""Detach a kernel driver. If successful, you will then be able to perform I/O. The interface parameter is the device interface number to detach the driver from.
[ "r", "Detach", "a", "kernel", "driver", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1068-L1079
train
pyusb/pyusb
usb/libloader.py
load_library
def load_library(lib, name=None, lib_cls=None): """Loads a library. Catches and logs exceptions. Returns: the loaded library or None arguments: * lib -- path to/name of the library to be loaded * name -- the library's identifier (for logging) Defaults to None. ...
python
def load_library(lib, name=None, lib_cls=None): """Loads a library. Catches and logs exceptions. Returns: the loaded library or None arguments: * lib -- path to/name of the library to be loaded * name -- the library's identifier (for logging) Defaults to None. ...
[ "def", "load_library", "(", "lib", ",", "name", "=", "None", ",", "lib_cls", "=", "None", ")", ":", "try", ":", "if", "lib_cls", ":", "return", "lib_cls", "(", "lib", ")", "else", ":", "return", "ctypes", ".", "CDLL", "(", "lib", ")", "except", "Ex...
Loads a library. Catches and logs exceptions. Returns: the loaded library or None arguments: * lib -- path to/name of the library to be loaded * name -- the library's identifier (for logging) Defaults to None. * lib_cls -- library class. Defaults to None (-> cty...
[ "Loads", "a", "library", ".", "Catches", "and", "logs", "exceptions", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/libloader.py#L88-L115
train
pyusb/pyusb
usb/libloader.py
load_locate_library
def load_locate_library(candidates, cygwin_lib, name, win_cls=None, cygwin_cls=None, others_cls=None, find_library=None, check_symbols=None): """Locates and loads a library. Returns: the loaded library arguments: * candidates -- candidates list for lo...
python
def load_locate_library(candidates, cygwin_lib, name, win_cls=None, cygwin_cls=None, others_cls=None, find_library=None, check_symbols=None): """Locates and loads a library. Returns: the loaded library arguments: * candidates -- candidates list for lo...
[ "def", "load_locate_library", "(", "candidates", ",", "cygwin_lib", ",", "name", ",", "win_cls", "=", "None", ",", "cygwin_cls", "=", "None", ",", "others_cls", "=", "None", ",", "find_library", "=", "None", ",", "check_symbols", "=", "None", ")", ":", "if...
Locates and loads a library. Returns: the loaded library arguments: * candidates -- candidates list for locate_library() * cygwin_lib -- name of the cygwin library * name -- lib identifier (for logging). Defaults to None. * win_cls -- class that is used to instantiate the ...
[ "Locates", "and", "loads", "a", "library", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/libloader.py#L117-L177
train
pyusb/pyusb
usb/control.py
get_status
def get_status(dev, recipient = None): r"""Return the status for the specified recipient. dev is the Device object to which the request will be sent to. The recipient can be None (on which the status will be queried from the device), an Interface or Endpoint descriptors. The status value is r...
python
def get_status(dev, recipient = None): r"""Return the status for the specified recipient. dev is the Device object to which the request will be sent to. The recipient can be None (on which the status will be queried from the device), an Interface or Endpoint descriptors. The status value is r...
[ "def", "get_status", "(", "dev", ",", "recipient", "=", "None", ")", ":", "bmRequestType", ",", "wIndex", "=", "_parse_recipient", "(", "recipient", ",", "util", ".", "CTRL_IN", ")", "ret", "=", "dev", ".", "ctrl_transfer", "(", "bmRequestType", "=", "bmRe...
r"""Return the status for the specified recipient. dev is the Device object to which the request will be sent to. The recipient can be None (on which the status will be queried from the device), an Interface or Endpoint descriptors. The status value is returned as an integer with the lower wo...
[ "r", "Return", "the", "status", "for", "the", "specified", "recipient", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L79-L96
train
pyusb/pyusb
usb/control.py
get_descriptor
def get_descriptor(dev, desc_size, desc_type, desc_index, wIndex = 0): r"""Return the specified descriptor. dev is the Device object to which the request will be sent to. desc_size is the descriptor size. desc_type and desc_index are the descriptor type and index, respectively. wIndex index i...
python
def get_descriptor(dev, desc_size, desc_type, desc_index, wIndex = 0): r"""Return the specified descriptor. dev is the Device object to which the request will be sent to. desc_size is the descriptor size. desc_type and desc_index are the descriptor type and index, respectively. wIndex index i...
[ "def", "get_descriptor", "(", "dev", ",", "desc_size", ",", "desc_type", ",", "desc_index", ",", "wIndex", "=", "0", ")", ":", "wValue", "=", "desc_index", "|", "(", "desc_type", "<<", "8", ")", "bmRequestType", "=", "util", ".", "build_request_type", "(",...
r"""Return the specified descriptor. dev is the Device object to which the request will be sent to. desc_size is the descriptor size. desc_type and desc_index are the descriptor type and index, respectively. wIndex index is used for string descriptors and represents the Language ID. For other...
[ "r", "Return", "the", "specified", "descriptor", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L135-L160
train
pyusb/pyusb
usb/control.py
set_descriptor
def set_descriptor(dev, desc, desc_type, desc_index, wIndex = None): r"""Update an existing descriptor or add a new one. dev is the Device object to which the request will be sent to. The desc parameter is the descriptor to be sent to the device. desc_type and desc_index are the descriptor type an...
python
def set_descriptor(dev, desc, desc_type, desc_index, wIndex = None): r"""Update an existing descriptor or add a new one. dev is the Device object to which the request will be sent to. The desc parameter is the descriptor to be sent to the device. desc_type and desc_index are the descriptor type an...
[ "def", "set_descriptor", "(", "dev", ",", "desc", ",", "desc_type", ",", "desc_index", ",", "wIndex", "=", "None", ")", ":", "wValue", "=", "desc_index", "|", "(", "desc_type", "<<", "8", ")", "bmRequestType", "=", "util", ".", "build_request_type", "(", ...
r"""Update an existing descriptor or add a new one. dev is the Device object to which the request will be sent to. The desc parameter is the descriptor to be sent to the device. desc_type and desc_index are the descriptor type and index, respectively. wIndex index is used for string descriptors ...
[ "r", "Update", "an", "existing", "descriptor", "or", "add", "a", "new", "one", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L162-L186
train
pyusb/pyusb
usb/control.py
get_configuration
def get_configuration(dev): r"""Get the current active configuration of the device. dev is the Device object to which the request will be sent to. This function differs from the Device.get_active_configuration method because the later may use cached data, while this function always does a devi...
python
def get_configuration(dev): r"""Get the current active configuration of the device. dev is the Device object to which the request will be sent to. This function differs from the Device.get_active_configuration method because the later may use cached data, while this function always does a devi...
[ "def", "get_configuration", "(", "dev", ")", ":", "bmRequestType", "=", "util", ".", "build_request_type", "(", "util", ".", "CTRL_IN", ",", "util", ".", "CTRL_TYPE_STANDARD", ",", "util", ".", "CTRL_RECIPIENT_DEVICE", ")", "return", "dev", ".", "ctrl_transfer",...
r"""Get the current active configuration of the device. dev is the Device object to which the request will be sent to. This function differs from the Device.get_active_configuration method because the later may use cached data, while this function always does a device request.
[ "r", "Get", "the", "current", "active", "configuration", "of", "the", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L188-L206
train
pyusb/pyusb
usb/control.py
get_interface
def get_interface(dev, bInterfaceNumber): r"""Get the current alternate setting of the interface. dev is the Device object to which the request will be sent to. """ bmRequestType = util.build_request_type( util.CTRL_IN, util.CTRL_TYPE_STANDARD...
python
def get_interface(dev, bInterfaceNumber): r"""Get the current alternate setting of the interface. dev is the Device object to which the request will be sent to. """ bmRequestType = util.build_request_type( util.CTRL_IN, util.CTRL_TYPE_STANDARD...
[ "def", "get_interface", "(", "dev", ",", "bInterfaceNumber", ")", ":", "bmRequestType", "=", "util", ".", "build_request_type", "(", "util", ".", "CTRL_IN", ",", "util", ".", "CTRL_TYPE_STANDARD", ",", "util", ".", "CTRL_RECIPIENT_INTERFACE", ")", "return", "dev...
r"""Get the current alternate setting of the interface. dev is the Device object to which the request will be sent to.
[ "r", "Get", "the", "current", "alternate", "setting", "of", "the", "interface", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L216-L231
train
pyusb/pyusb
tools/vcp_terminal.py
configInputQueue
def configInputQueue(): """ configure a queue for accepting characters and return the queue """ def captureInput(iqueue): while True: c = getch() if c == '\x03' or c == '\x04': # end on ctrl+c / ctrl+d log.debug("Break received (\\x{0:02X})".format(ord(c)))...
python
def configInputQueue(): """ configure a queue for accepting characters and return the queue """ def captureInput(iqueue): while True: c = getch() if c == '\x03' or c == '\x04': # end on ctrl+c / ctrl+d log.debug("Break received (\\x{0:02X})".format(ord(c)))...
[ "def", "configInputQueue", "(", ")", ":", "def", "captureInput", "(", "iqueue", ")", ":", "while", "True", ":", "c", "=", "getch", "(", ")", "if", "c", "==", "'\\x03'", "or", "c", "==", "'\\x04'", ":", "# end on ctrl+c / ctrl+d", "log", ".", "debug", "...
configure a queue for accepting characters and return the queue
[ "configure", "a", "queue", "for", "accepting", "characters", "and", "return", "the", "queue" ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L518-L537
train
pyusb/pyusb
tools/vcp_terminal.py
fmt_text
def fmt_text(text): """ convert characters that aren't printable to hex format """ PRINTABLE_CHAR = set( list(range(ord(' '), ord('~') + 1)) + [ord('\r'), ord('\n')]) newtext = ("\\x{:02X}".format( c) if c not in PRINTABLE_CHAR else chr(c) for c in text) textlines = "\r\n".join(l.str...
python
def fmt_text(text): """ convert characters that aren't printable to hex format """ PRINTABLE_CHAR = set( list(range(ord(' '), ord('~') + 1)) + [ord('\r'), ord('\n')]) newtext = ("\\x{:02X}".format( c) if c not in PRINTABLE_CHAR else chr(c) for c in text) textlines = "\r\n".join(l.str...
[ "def", "fmt_text", "(", "text", ")", ":", "PRINTABLE_CHAR", "=", "set", "(", "list", "(", "range", "(", "ord", "(", "' '", ")", ",", "ord", "(", "'~'", ")", "+", "1", ")", ")", "+", "[", "ord", "(", "'\\r'", ")", ",", "ord", "(", "'\\n'", ")"...
convert characters that aren't printable to hex format
[ "convert", "characters", "that", "aren", "t", "printable", "to", "hex", "format" ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L540-L549
train
pyusb/pyusb
tools/vcp_terminal.py
ftdi_to_clkbits
def ftdi_to_clkbits(baudrate): # from libftdi """ 10,27 => divisor = 10000, rate = 300 88,13 => divisor = 5000, rate = 600 C4,09 => divisor = 2500, rate = 1200 E2,04 => divisor = 1250, rate = 2,400 71,02 => divisor = 625, rate = 4,800 38,41 => divisor = 312.5, rate = 9,600 D0,80 => divi...
python
def ftdi_to_clkbits(baudrate): # from libftdi """ 10,27 => divisor = 10000, rate = 300 88,13 => divisor = 5000, rate = 600 C4,09 => divisor = 2500, rate = 1200 E2,04 => divisor = 1250, rate = 2,400 71,02 => divisor = 625, rate = 4,800 38,41 => divisor = 312.5, rate = 9,600 D0,80 => divi...
[ "def", "ftdi_to_clkbits", "(", "baudrate", ")", ":", "# from libftdi", "clk", "=", "48000000", "clk_div", "=", "16", "frac_code", "=", "[", "0", ",", "3", ",", "2", ",", "4", ",", "1", ",", "5", ",", "6", ",", "7", "]", "actual_baud", "=", "0", "...
10,27 => divisor = 10000, rate = 300 88,13 => divisor = 5000, rate = 600 C4,09 => divisor = 2500, rate = 1200 E2,04 => divisor = 1250, rate = 2,400 71,02 => divisor = 625, rate = 4,800 38,41 => divisor = 312.5, rate = 9,600 D0,80 => divisor = 208.25, rate = 14406 9C,80 => divisor = 156, rate...
[ "10", "27", "=", ">", "divisor", "=", "10000", "rate", "=", "300", "88", "13", "=", ">", "divisor", "=", "5000", "rate", "=", "600", "C4", "09", "=", ">", "divisor", "=", "2500", "rate", "=", "1200", "E2", "04", "=", ">", "divisor", "=", "1250"...
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L576-L617
train
pyusb/pyusb
tools/vcp_terminal.py
ComPort._read
def _read(self): """ check ep for data, add it to queue and sleep for interval """ while self._rxactive: try: rv = self._ep_in.read(self._ep_in.wMaxPacketSize) if self._isFTDI: status = rv[:2] # FTDI prepends 2 flow control characters, ...
python
def _read(self): """ check ep for data, add it to queue and sleep for interval """ while self._rxactive: try: rv = self._ep_in.read(self._ep_in.wMaxPacketSize) if self._isFTDI: status = rv[:2] # FTDI prepends 2 flow control characters, ...
[ "def", "_read", "(", "self", ")", ":", "while", "self", ".", "_rxactive", ":", "try", ":", "rv", "=", "self", ".", "_ep_in", ".", "read", "(", "self", ".", "_ep_in", ".", "wMaxPacketSize", ")", "if", "self", ".", "_isFTDI", ":", "status", "=", "rv"...
check ep for data, add it to queue and sleep for interval
[ "check", "ep", "for", "data", "add", "it", "to", "queue", "and", "sleep", "for", "interval" ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L187-L206
train
pyusb/pyusb
tools/vcp_terminal.py
ComPort._resetFTDI
def _resetFTDI(self): """ reset the FTDI device """ if not self._isFTDI: return txdir = 0 # 0:OUT, 1:IN req_type = 2 # 0:std, 1:class, 2:vendor recipient = 0 # 0:device, 1:interface, 2:endpoint, 3:other req_type = (txdir << 7) + ...
python
def _resetFTDI(self): """ reset the FTDI device """ if not self._isFTDI: return txdir = 0 # 0:OUT, 1:IN req_type = 2 # 0:std, 1:class, 2:vendor recipient = 0 # 0:device, 1:interface, 2:endpoint, 3:other req_type = (txdir << 7) + ...
[ "def", "_resetFTDI", "(", "self", ")", ":", "if", "not", "self", ".", "_isFTDI", ":", "return", "txdir", "=", "0", "# 0:OUT, 1:IN", "req_type", "=", "2", "# 0:std, 1:class, 2:vendor", "recipient", "=", "0", "# 0:device, 1:interface, 2:endpoint, 3:other", "req_type",...
reset the FTDI device
[ "reset", "the", "FTDI", "device" ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/tools/vcp_terminal.py#L359-L373
train
pyusb/pyusb
usb/legacy.py
busses
def busses(): r"""Returns a tuple with the usb busses.""" return (Bus(g) for k, g in groupby( sorted(core.find(find_all=True), key=lambda d: d.bus), lambda d: d.bus))
python
def busses(): r"""Returns a tuple with the usb busses.""" return (Bus(g) for k, g in groupby( sorted(core.find(find_all=True), key=lambda d: d.bus), lambda d: d.bus))
[ "def", "busses", "(", ")", ":", "return", "(", "Bus", "(", "g", ")", "for", "k", ",", "g", "in", "groupby", "(", "sorted", "(", "core", ".", "find", "(", "find_all", "=", "True", ")", ",", "key", "=", "lambda", "d", ":", "d", ".", "bus", ")",...
r"""Returns a tuple with the usb busses.
[ "r", "Returns", "a", "tuple", "with", "the", "usb", "busses", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L337-L341
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.bulkWrite
def bulkWrite(self, endpoint, buffer, timeout = 100): r"""Perform a bulk write request to the endpoint specified. Arguments: endpoint: endpoint number. buffer: sequence data buffer to write. This parameter can be any sequence type. ...
python
def bulkWrite(self, endpoint, buffer, timeout = 100): r"""Perform a bulk write request to the endpoint specified. Arguments: endpoint: endpoint number. buffer: sequence data buffer to write. This parameter can be any sequence type. ...
[ "def", "bulkWrite", "(", "self", ",", "endpoint", ",", "buffer", ",", "timeout", "=", "100", ")", ":", "return", "self", ".", "dev", ".", "write", "(", "endpoint", ",", "buffer", ",", "timeout", ")" ]
r"""Perform a bulk write request to the endpoint specified. Arguments: endpoint: endpoint number. buffer: sequence data buffer to write. This parameter can be any sequence type. timeout: operation timeout in milliseconds. (default: 100...
[ "r", "Perform", "a", "bulk", "write", "request", "to", "the", "endpoint", "specified", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L131-L141
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.bulkRead
def bulkRead(self, endpoint, size, timeout = 100): r"""Performs a bulk read request to the endpoint specified. Arguments: endpoint: endpoint number. size: number of bytes to read. timeout: operation timeout in milliseconds. (default: 100) ...
python
def bulkRead(self, endpoint, size, timeout = 100): r"""Performs a bulk read request to the endpoint specified. Arguments: endpoint: endpoint number. size: number of bytes to read. timeout: operation timeout in milliseconds. (default: 100) ...
[ "def", "bulkRead", "(", "self", ",", "endpoint", ",", "size", ",", "timeout", "=", "100", ")", ":", "return", "self", ".", "dev", ".", "read", "(", "endpoint", ",", "size", ",", "timeout", ")" ]
r"""Performs a bulk read request to the endpoint specified. Arguments: endpoint: endpoint number. size: number of bytes to read. timeout: operation timeout in milliseconds. (default: 100) Returns a tuple with the data read.
[ "r", "Performs", "a", "bulk", "read", "request", "to", "the", "endpoint", "specified", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L143-L152
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.interruptWrite
def interruptWrite(self, endpoint, buffer, timeout = 100): r"""Perform a interrupt write request to the endpoint specified. Arguments: endpoint: endpoint number. buffer: sequence data buffer to write. This parameter can be any sequence type. ...
python
def interruptWrite(self, endpoint, buffer, timeout = 100): r"""Perform a interrupt write request to the endpoint specified. Arguments: endpoint: endpoint number. buffer: sequence data buffer to write. This parameter can be any sequence type. ...
[ "def", "interruptWrite", "(", "self", ",", "endpoint", ",", "buffer", ",", "timeout", "=", "100", ")", ":", "return", "self", ".", "dev", ".", "write", "(", "endpoint", ",", "buffer", ",", "timeout", ")" ]
r"""Perform a interrupt write request to the endpoint specified. Arguments: endpoint: endpoint number. buffer: sequence data buffer to write. This parameter can be any sequence type. timeout: operation timeout in milliseconds. (default...
[ "r", "Perform", "a", "interrupt", "write", "request", "to", "the", "endpoint", "specified", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L154-L164
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.interruptRead
def interruptRead(self, endpoint, size, timeout = 100): r"""Performs a interrupt read request to the endpoint specified. Arguments: endpoint: endpoint number. size: number of bytes to read. timeout: operation timeout in milliseconds. (default: 100) ...
python
def interruptRead(self, endpoint, size, timeout = 100): r"""Performs a interrupt read request to the endpoint specified. Arguments: endpoint: endpoint number. size: number of bytes to read. timeout: operation timeout in milliseconds. (default: 100) ...
[ "def", "interruptRead", "(", "self", ",", "endpoint", ",", "size", ",", "timeout", "=", "100", ")", ":", "return", "self", ".", "dev", ".", "read", "(", "endpoint", ",", "size", ",", "timeout", ")" ]
r"""Performs a interrupt read request to the endpoint specified. Arguments: endpoint: endpoint number. size: number of bytes to read. timeout: operation timeout in milliseconds. (default: 100) Returns a tuple with the data read.
[ "r", "Performs", "a", "interrupt", "read", "request", "to", "the", "endpoint", "specified", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L166-L175
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.controlMsg
def controlMsg(self, requestType, request, buffer, value = 0, index = 0, timeout = 100): r"""Perform a control request to the default control pipe on a device. Arguments: requestType: specifies the direction of data flow, the type of request, and the recipient. ...
python
def controlMsg(self, requestType, request, buffer, value = 0, index = 0, timeout = 100): r"""Perform a control request to the default control pipe on a device. Arguments: requestType: specifies the direction of data flow, the type of request, and the recipient. ...
[ "def", "controlMsg", "(", "self", ",", "requestType", ",", "request", ",", "buffer", ",", "value", "=", "0", ",", "index", "=", "0", ",", "timeout", "=", "100", ")", ":", "return", "self", ".", "dev", ".", "ctrl_transfer", "(", "requestType", ",", "r...
r"""Perform a control request to the default control pipe on a device. Arguments: requestType: specifies the direction of data flow, the type of request, and the recipient. request: specifies the request. buffer: if the transfer is a write transfer, ...
[ "r", "Perform", "a", "control", "request", "to", "the", "default", "control", "pipe", "on", "a", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L177-L198
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.claimInterface
def claimInterface(self, interface): r"""Claims the interface with the Operating System. Arguments: interface: interface number or an Interface object. """ if isinstance(interface, Interface): interface = interface.interfaceNumber util.claim_interface(se...
python
def claimInterface(self, interface): r"""Claims the interface with the Operating System. Arguments: interface: interface number or an Interface object. """ if isinstance(interface, Interface): interface = interface.interfaceNumber util.claim_interface(se...
[ "def", "claimInterface", "(", "self", ",", "interface", ")", ":", "if", "isinstance", "(", "interface", ",", "Interface", ")", ":", "interface", "=", "interface", ".", "interfaceNumber", "util", ".", "claim_interface", "(", "self", ".", "dev", ",", "interfac...
r"""Claims the interface with the Operating System. Arguments: interface: interface number or an Interface object.
[ "r", "Claims", "the", "interface", "with", "the", "Operating", "System", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L208-L218
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.releaseInterface
def releaseInterface(self): r"""Release an interface previously claimed with claimInterface.""" util.release_interface(self.dev, self.__claimed_interface) self.__claimed_interface = -1
python
def releaseInterface(self): r"""Release an interface previously claimed with claimInterface.""" util.release_interface(self.dev, self.__claimed_interface) self.__claimed_interface = -1
[ "def", "releaseInterface", "(", "self", ")", ":", "util", ".", "release_interface", "(", "self", ".", "dev", ",", "self", ".", "__claimed_interface", ")", "self", ".", "__claimed_interface", "=", "-", "1" ]
r"""Release an interface previously claimed with claimInterface.
[ "r", "Release", "an", "interface", "previously", "claimed", "with", "claimInterface", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L220-L223
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.setConfiguration
def setConfiguration(self, configuration): r"""Set the active configuration of a device. Arguments: configuration: a configuration value or a Configuration object. """ if isinstance(configuration, Configuration): configuration = configuration.value self.d...
python
def setConfiguration(self, configuration): r"""Set the active configuration of a device. Arguments: configuration: a configuration value or a Configuration object. """ if isinstance(configuration, Configuration): configuration = configuration.value self.d...
[ "def", "setConfiguration", "(", "self", ",", "configuration", ")", ":", "if", "isinstance", "(", "configuration", ",", "Configuration", ")", ":", "configuration", "=", "configuration", ".", "value", "self", ".", "dev", ".", "set_configuration", "(", "configurati...
r"""Set the active configuration of a device. Arguments: configuration: a configuration value or a Configuration object.
[ "r", "Set", "the", "active", "configuration", "of", "a", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L238-L247
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.setAltInterface
def setAltInterface(self, alternate): r"""Sets the active alternate setting of the current interface. Arguments: alternate: an alternate setting number or an Interface object. """ if isinstance(alternate, Interface): alternate = alternate.alternateSetting ...
python
def setAltInterface(self, alternate): r"""Sets the active alternate setting of the current interface. Arguments: alternate: an alternate setting number or an Interface object. """ if isinstance(alternate, Interface): alternate = alternate.alternateSetting ...
[ "def", "setAltInterface", "(", "self", ",", "alternate", ")", ":", "if", "isinstance", "(", "alternate", ",", "Interface", ")", ":", "alternate", "=", "alternate", ".", "alternateSetting", "self", ".", "dev", ".", "set_interface_altsetting", "(", "self", ".", ...
r"""Sets the active alternate setting of the current interface. Arguments: alternate: an alternate setting number or an Interface object.
[ "r", "Sets", "the", "active", "alternate", "setting", "of", "the", "current", "interface", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L249-L258
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.getString
def getString(self, index, length, langid = None): r"""Retrieve the string descriptor specified by index and langid from a device. Arguments: index: index of descriptor in the device. length: number of bytes of the string (ignored) langid: Language ID. If...
python
def getString(self, index, length, langid = None): r"""Retrieve the string descriptor specified by index and langid from a device. Arguments: index: index of descriptor in the device. length: number of bytes of the string (ignored) langid: Language ID. If...
[ "def", "getString", "(", "self", ",", "index", ",", "length", ",", "langid", "=", "None", ")", ":", "return", "util", ".", "get_string", "(", "self", ".", "dev", ",", "index", ",", "langid", ")", ".", "encode", "(", "'ascii'", ")" ]
r"""Retrieve the string descriptor specified by index and langid from a device. Arguments: index: index of descriptor in the device. length: number of bytes of the string (ignored) langid: Language ID. If it is omitted, the first language will...
[ "r", "Retrieve", "the", "string", "descriptor", "specified", "by", "index", "and", "langid", "from", "a", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L260-L270
train
pyusb/pyusb
usb/legacy.py
DeviceHandle.getDescriptor
def getDescriptor(self, desc_type, desc_index, length, endpoint = -1): r"""Retrieves a descriptor from the device identified by the type and index of the descriptor. Arguments: desc_type: descriptor type. desc_index: index of the descriptor. len: descriptor l...
python
def getDescriptor(self, desc_type, desc_index, length, endpoint = -1): r"""Retrieves a descriptor from the device identified by the type and index of the descriptor. Arguments: desc_type: descriptor type. desc_index: index of the descriptor. len: descriptor l...
[ "def", "getDescriptor", "(", "self", ",", "desc_type", ",", "desc_index", ",", "length", ",", "endpoint", "=", "-", "1", ")", ":", "return", "control", ".", "get_descriptor", "(", "self", ".", "dev", ",", "length", ",", "desc_type", ",", "desc_index", ")...
r"""Retrieves a descriptor from the device identified by the type and index of the descriptor. Arguments: desc_type: descriptor type. desc_index: index of the descriptor. len: descriptor length. endpoint: ignored.
[ "r", "Retrieves", "a", "descriptor", "from", "the", "device", "identified", "by", "the", "type", "and", "index", "of", "the", "descriptor", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/legacy.py#L272-L282
train
pyusb/pyusb
usb/backend/__init__.py
IBackend.get_endpoint_descriptor
def get_endpoint_descriptor(self, dev, ep, intf, alt, config): r"""Return an endpoint descriptor of the given device. The object returned is required to have all the Endpoint Descriptor fields acessible as member variables. They must be convertible (but not required to be equal) to the ...
python
def get_endpoint_descriptor(self, dev, ep, intf, alt, config): r"""Return an endpoint descriptor of the given device. The object returned is required to have all the Endpoint Descriptor fields acessible as member variables. They must be convertible (but not required to be equal) to the ...
[ "def", "get_endpoint_descriptor", "(", "self", ",", "dev", ",", "ep", ",", "intf", ",", "alt", ",", "config", ")", ":", "_not_implemented", "(", "self", ".", "get_endpoint_descriptor", ")" ]
r"""Return an endpoint descriptor of the given device. The object returned is required to have all the Endpoint Descriptor fields acessible as member variables. They must be convertible (but not required to be equal) to the int type. The ep parameter is the endpoint logical index (not ...
[ "r", "Return", "an", "endpoint", "descriptor", "of", "the", "given", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L140-L151
train
pyusb/pyusb
usb/backend/__init__.py
IBackend.bulk_write
def bulk_write(self, dev_handle, ep, intf, data, timeout): r"""Perform a bulk write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of the in...
python
def bulk_write(self, dev_handle, ep, intf, data, timeout): r"""Perform a bulk write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of the in...
[ "def", "bulk_write", "(", "self", ",", "dev_handle", ",", "ep", ",", "intf", ",", "data", ",", "timeout", ")", ":", "_not_implemented", "(", "self", ".", "bulk_write", ")" ]
r"""Perform a bulk write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of the interface containing the endpoint. The data parameter is the ...
[ "r", "Perform", "a", "bulk", "write", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L225-L238
train
pyusb/pyusb
usb/backend/__init__.py
IBackend.bulk_read
def bulk_read(self, dev_handle, ep, intf, buff, timeout): r"""Perform a bulk read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field of th...
python
def bulk_read(self, dev_handle, ep, intf, buff, timeout): r"""Perform a bulk read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field of th...
[ "def", "bulk_read", "(", "self", ",", "dev_handle", ",", "ep", ",", "intf", ",", "buff", ",", "timeout", ")", ":", "_not_implemented", "(", "self", ".", "bulk_read", ")" ]
r"""Perform a bulk read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field of the interface containing the endpoint. The buff parameter is...
[ "r", "Perform", "a", "bulk", "read", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L240-L253
train
pyusb/pyusb
usb/backend/__init__.py
IBackend.intr_write
def intr_write(self, dev_handle, ep, intf, data, timeout): r"""Perform an interrupt write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of ...
python
def intr_write(self, dev_handle, ep, intf, data, timeout): r"""Perform an interrupt write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of ...
[ "def", "intr_write", "(", "self", ",", "dev_handle", ",", "ep", ",", "intf", ",", "data", ",", "timeout", ")", ":", "_not_implemented", "(", "self", ".", "intr_write", ")" ]
r"""Perform an interrupt write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of the interface containing the endpoint. The data parameter i...
[ "r", "Perform", "an", "interrupt", "write", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L255-L268
train
pyusb/pyusb
usb/backend/__init__.py
IBackend.intr_read
def intr_read(self, dev_handle, ep, intf, size, timeout): r"""Perform an interrut read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field ...
python
def intr_read(self, dev_handle, ep, intf, size, timeout): r"""Perform an interrut read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field ...
[ "def", "intr_read", "(", "self", ",", "dev_handle", ",", "ep", ",", "intf", ",", "size", ",", "timeout", ")", ":", "_not_implemented", "(", "self", ".", "intr_read", ")" ]
r"""Perform an interrut read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field of the interface containing the endpoint. The buff parameter ...
[ "r", "Perform", "an", "interrut", "read", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L270-L283
train
pyusb/pyusb
usb/backend/__init__.py
IBackend.iso_write
def iso_write(self, dev_handle, ep, intf, data, timeout): r"""Perform an isochronous write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of...
python
def iso_write(self, dev_handle, ep, intf, data, timeout): r"""Perform an isochronous write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of...
[ "def", "iso_write", "(", "self", ",", "dev_handle", ",", "ep", ",", "intf", ",", "data", ",", "timeout", ")", ":", "_not_implemented", "(", "self", ".", "iso_write", ")" ]
r"""Perform an isochronous write. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be sent to. intf is the bInterfaceNumber field of the interface containing the endpoint. The data parameter ...
[ "r", "Perform", "an", "isochronous", "write", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L285-L298
train
pyusb/pyusb
usb/backend/__init__.py
IBackend.iso_read
def iso_read(self, dev_handle, ep, intf, size, timeout): r"""Perform an isochronous read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field ...
python
def iso_read(self, dev_handle, ep, intf, size, timeout): r"""Perform an isochronous read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field ...
[ "def", "iso_read", "(", "self", ",", "dev_handle", ",", "ep", ",", "intf", ",", "size", ",", "timeout", ")", ":", "_not_implemented", "(", "self", ".", "iso_read", ")" ]
r"""Perform an isochronous read. dev_handle is the value returned by the open_device() method. The ep parameter is the bEndpointAddress field whose endpoint the data will be received from. intf is the bInterfaceNumber field of the interface containing the endpoint. The buff parameter ...
[ "r", "Perform", "an", "isochronous", "read", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L300-L313
train
pyusb/pyusb
usb/backend/__init__.py
IBackend.ctrl_transfer
def ctrl_transfer(self, dev_handle, bmRequestType, bRequest, wValue, wIndex, data, timeout): r"""Perform a control transfer on the endpoint 0. The di...
python
def ctrl_transfer(self, dev_handle, bmRequestType, bRequest, wValue, wIndex, data, timeout): r"""Perform a control transfer on the endpoint 0. The di...
[ "def", "ctrl_transfer", "(", "self", ",", "dev_handle", ",", "bmRequestType", ",", "bRequest", ",", "wValue", ",", "wIndex", ",", "data", ",", "timeout", ")", ":", "_not_implemented", "(", "self", ".", "ctrl_transfer", ")" ]
r"""Perform a control transfer on the endpoint 0. The direction of the transfer is inferred from the bmRequestType field of the setup packet. dev_handle is the value returned by the open_device() method. bmRequestType, bRequest, wValue and wIndex are the same fields of the setu...
[ "r", "Perform", "a", "control", "transfer", "on", "the", "endpoint", "0", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/backend/__init__.py#L315-L340
train
pyusb/pyusb
usb/util.py
find_descriptor
def find_descriptor(desc, find_all=False, custom_match=None, **args): r"""Find an inner descriptor. find_descriptor works in the same way as the core.find() function does, but it acts on general descriptor objects. For example, suppose you have a Device object called dev and want a Configuration of thi...
python
def find_descriptor(desc, find_all=False, custom_match=None, **args): r"""Find an inner descriptor. find_descriptor works in the same way as the core.find() function does, but it acts on general descriptor objects. For example, suppose you have a Device object called dev and want a Configuration of thi...
[ "def", "find_descriptor", "(", "desc", ",", "find_all", "=", "False", ",", "custom_match", "=", "None", ",", "*", "*", "args", ")", ":", "def", "desc_iter", "(", "*", "*", "kwargs", ")", ":", "for", "d", "in", "desc", ":", "tests", "=", "(", "val",...
r"""Find an inner descriptor. find_descriptor works in the same way as the core.find() function does, but it acts on general descriptor objects. For example, suppose you have a Device object called dev and want a Configuration of this object with its bConfigurationValue equals to 1, the code would ...
[ "r", "Find", "an", "inner", "descriptor", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/util.py#L151-L179
train
pyusb/pyusb
usb/util.py
get_langids
def get_langids(dev): r"""Retrieve the list of supported Language IDs from the device. Most client code should not call this function directly, but instead use the langids property on the Device object, which will call this function as needed and cache the result. USB LANGIDs are 16-bit integers f...
python
def get_langids(dev): r"""Retrieve the list of supported Language IDs from the device. Most client code should not call this function directly, but instead use the langids property on the Device object, which will call this function as needed and cache the result. USB LANGIDs are 16-bit integers f...
[ "def", "get_langids", "(", "dev", ")", ":", "from", "usb", ".", "control", "import", "get_descriptor", "buf", "=", "get_descriptor", "(", "dev", ",", "254", ",", "DESC_TYPE_STRING", ",", "0", ")", "# The array is retrieved by asking for string descriptor zero, which i...
r"""Retrieve the list of supported Language IDs from the device. Most client code should not call this function directly, but instead use the langids property on the Device object, which will call this function as needed and cache the result. USB LANGIDs are 16-bit integers familiar to Windows develop...
[ "r", "Retrieve", "the", "list", "of", "supported", "Language", "IDs", "from", "the", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/util.py#L222-L270
train
pyusb/pyusb
usb/util.py
get_string
def get_string(dev, index, langid = None): r"""Retrieve a string descriptor from the device. dev is the Device object which the string will be read from. index is the string descriptor index and langid is the Language ID of the descriptor. If langid is omitted, the string descriptor of the first L...
python
def get_string(dev, index, langid = None): r"""Retrieve a string descriptor from the device. dev is the Device object which the string will be read from. index is the string descriptor index and langid is the Language ID of the descriptor. If langid is omitted, the string descriptor of the first L...
[ "def", "get_string", "(", "dev", ",", "index", ",", "langid", "=", "None", ")", ":", "if", "0", "==", "index", ":", "return", "None", "from", "usb", ".", "control", "import", "get_descriptor", "langids", "=", "dev", ".", "langids", "if", "0", "==", "...
r"""Retrieve a string descriptor from the device. dev is the Device object which the string will be read from. index is the string descriptor index and langid is the Language ID of the descriptor. If langid is omitted, the string descriptor of the first Language ID will be returned. Zero is never...
[ "r", "Retrieve", "a", "string", "descriptor", "from", "the", "device", "." ]
ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9
https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/util.py#L272-L317
train
atztogo/phonopy
phonopy/unfolding/core.py
Unfolding._set_translations
def _set_translations(self): """Set primitive translations in supercell _trans_s Translations with respect to supercell basis vectors _trans_p Translations with respect to primitive cell basis vectors _N Number of the translations = det(supercel_matri...
python
def _set_translations(self): """Set primitive translations in supercell _trans_s Translations with respect to supercell basis vectors _trans_p Translations with respect to primitive cell basis vectors _N Number of the translations = det(supercel_matri...
[ "def", "_set_translations", "(", "self", ")", ":", "pcell", "=", "PhonopyAtoms", "(", "numbers", "=", "[", "1", "]", ",", "scaled_positions", "=", "[", "[", "0", ",", "0", ",", "0", "]", "]", ",", "cell", "=", "np", ".", "diag", "(", "[", "1", ...
Set primitive translations in supercell _trans_s Translations with respect to supercell basis vectors _trans_p Translations with respect to primitive cell basis vectors _N Number of the translations = det(supercel_matrix)
[ "Set", "primitive", "translations", "in", "supercell" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/unfolding/core.py#L164-L182
train
atztogo/phonopy
phonopy/qha/core.py
QHA.run
def run(self, verbose=False): """Fit parameters to EOS at temperatures Even if fitting failed, simply omit the volume point. In this case, the failed temperature point doesn't exist in the returned arrays. """ if verbose: print(("#%11s" + "%14s" * 4) % ("T", "E_0",...
python
def run(self, verbose=False): """Fit parameters to EOS at temperatures Even if fitting failed, simply omit the volume point. In this case, the failed temperature point doesn't exist in the returned arrays. """ if verbose: print(("#%11s" + "%14s" * 4) % ("T", "E_0",...
[ "def", "run", "(", "self", ",", "verbose", "=", "False", ")", ":", "if", "verbose", ":", "print", "(", "(", "\"#%11s\"", "+", "\"%14s\"", "*", "4", ")", "%", "(", "\"T\"", ",", "\"E_0\"", ",", "\"B_0\"", ",", "\"B'_0\"", ",", "\"V_0\"", ")", ")", ...
Fit parameters to EOS at temperatures Even if fitting failed, simply omit the volume point. In this case, the failed temperature point doesn't exist in the returned arrays.
[ "Fit", "parameters", "to", "EOS", "at", "temperatures" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/qha/core.py#L144-L211
train
atztogo/phonopy
phonopy/structure/cells.py
_trim_cell
def _trim_cell(relative_axes, cell, symprec): """Trim overlapping atoms Parameters ---------- relative_axes: ndarray Transformation matrix to transform supercell to a smaller cell such as: trimmed_lattice = np.dot(relative_axes.T, cell.get_cell()) shape=(3,3) cell: Phono...
python
def _trim_cell(relative_axes, cell, symprec): """Trim overlapping atoms Parameters ---------- relative_axes: ndarray Transformation matrix to transform supercell to a smaller cell such as: trimmed_lattice = np.dot(relative_axes.T, cell.get_cell()) shape=(3,3) cell: Phono...
[ "def", "_trim_cell", "(", "relative_axes", ",", "cell", ",", "symprec", ")", ":", "positions", "=", "cell", ".", "get_scaled_positions", "(", ")", "numbers", "=", "cell", ".", "get_atomic_numbers", "(", ")", "masses", "=", "cell", ".", "get_masses", "(", "...
Trim overlapping atoms Parameters ---------- relative_axes: ndarray Transformation matrix to transform supercell to a smaller cell such as: trimmed_lattice = np.dot(relative_axes.T, cell.get_cell()) shape=(3,3) cell: PhonopyAtoms A supercell symprec: float ...
[ "Trim", "overlapping", "atoms" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L459-L543
train
atztogo/phonopy
phonopy/structure/cells.py
get_reduced_bases
def get_reduced_bases(lattice, method='delaunay', tolerance=1e-5): """Search kinds of shortest basis vectors Parameters ---------- lattice : ndarray or list of list Basis vectors by row vectors, [a, b, c]^T shape=(3, 3) method : str ...
python
def get_reduced_bases(lattice, method='delaunay', tolerance=1e-5): """Search kinds of shortest basis vectors Parameters ---------- lattice : ndarray or list of list Basis vectors by row vectors, [a, b, c]^T shape=(3, 3) method : str ...
[ "def", "get_reduced_bases", "(", "lattice", ",", "method", "=", "'delaunay'", ",", "tolerance", "=", "1e-5", ")", ":", "if", "method", "==", "'niggli'", ":", "return", "spg", ".", "niggli_reduce", "(", "lattice", ",", "eps", "=", "tolerance", ")", "else", ...
Search kinds of shortest basis vectors Parameters ---------- lattice : ndarray or list of list Basis vectors by row vectors, [a, b, c]^T shape=(3, 3) method : str delaunay: Delaunay reduction niggli: Niggli reduction tolerance : float Tolerance to find shorte...
[ "Search", "kinds", "of", "shortest", "basis", "vectors" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L549-L577
train
atztogo/phonopy
phonopy/structure/cells.py
get_smallest_vectors
def get_smallest_vectors(supercell_bases, supercell_pos, primitive_pos, symprec=1e-5): """Find shortest atomic pair vectors Note ---- Shortest vectors from an atom in primitive cell to an atom in supercell in the fractional ...
python
def get_smallest_vectors(supercell_bases, supercell_pos, primitive_pos, symprec=1e-5): """Find shortest atomic pair vectors Note ---- Shortest vectors from an atom in primitive cell to an atom in supercell in the fractional ...
[ "def", "get_smallest_vectors", "(", "supercell_bases", ",", "supercell_pos", ",", "primitive_pos", ",", "symprec", "=", "1e-5", ")", ":", "reduced_bases", "=", "get_reduced_bases", "(", "supercell_bases", ",", "method", "=", "'delaunay'", ",", "tolerance", "=", "s...
Find shortest atomic pair vectors Note ---- Shortest vectors from an atom in primitive cell to an atom in supercell in the fractional coordinates of primitive cell. If an atom in supercell is on the border centered at an atom in primitive and there are multiple vectors that have the same di...
[ "Find", "shortest", "atomic", "pair", "vectors" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L595-L741
train
atztogo/phonopy
phonopy/structure/cells.py
compute_all_sg_permutations
def compute_all_sg_permutations(positions, # scaled positions rotations, # scaled translations, # scaled lattice, # column vectors symprec): """Compute a permutation for every space gr...
python
def compute_all_sg_permutations(positions, # scaled positions rotations, # scaled translations, # scaled lattice, # column vectors symprec): """Compute a permutation for every space gr...
[ "def", "compute_all_sg_permutations", "(", "positions", ",", "# scaled positions", "rotations", ",", "# scaled", "translations", ",", "# scaled", "lattice", ",", "# column vectors", "symprec", ")", ":", "out", "=", "[", "]", "# Finally the shape is fixed as (num_sym, num_...
Compute a permutation for every space group operation. See 'compute_permutation_for_rotation' for more info. Output has shape (num_rot, num_pos)
[ "Compute", "a", "permutation", "for", "every", "space", "group", "operation", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L744-L764
train
atztogo/phonopy
phonopy/structure/cells.py
compute_permutation_for_rotation
def compute_permutation_for_rotation(positions_a, # scaled positions positions_b, lattice, # column vectors symprec): """Get the overall permutation such that positions_a[perm[i]] == positions_b...
python
def compute_permutation_for_rotation(positions_a, # scaled positions positions_b, lattice, # column vectors symprec): """Get the overall permutation such that positions_a[perm[i]] == positions_b...
[ "def", "compute_permutation_for_rotation", "(", "positions_a", ",", "# scaled positions", "positions_b", ",", "lattice", ",", "# column vectors", "symprec", ")", ":", "# Sort both sides by some measure which is likely to produce a small", "# maximum value of (sorted_rotated_index - sor...
Get the overall permutation such that positions_a[perm[i]] == positions_b[i] (modulo the lattice) or in numpy speak, positions_a[perm] == positions_b (modulo the lattice) This version is optimized for the case where positions_a and positions_b are related by a rotation.
[ "Get", "the", "overall", "permutation", "such", "that" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L767-L811
train
atztogo/phonopy
phonopy/structure/cells.py
_compute_permutation_c
def _compute_permutation_c(positions_a, # scaled positions positions_b, lattice, # column vectors symprec): """Version of '_compute_permutation_for_rotation' which just directly calls the C function, without any conditioning of t...
python
def _compute_permutation_c(positions_a, # scaled positions positions_b, lattice, # column vectors symprec): """Version of '_compute_permutation_for_rotation' which just directly calls the C function, without any conditioning of t...
[ "def", "_compute_permutation_c", "(", "positions_a", ",", "# scaled positions", "positions_b", ",", "lattice", ",", "# column vectors", "symprec", ")", ":", "permutation", "=", "np", ".", "zeros", "(", "shape", "=", "(", "len", "(", "positions_a", ")", ",", ")...
Version of '_compute_permutation_for_rotation' which just directly calls the C function, without any conditioning of the data. Skipping the conditioning step makes this EXTREMELY slow on large structures.
[ "Version", "of", "_compute_permutation_for_rotation", "which", "just", "directly", "calls", "the", "C", "function", "without", "any", "conditioning", "of", "the", "data", ".", "Skipping", "the", "conditioning", "step", "makes", "this", "EXTREMELY", "slow", "on", "...
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L814-L858
train
atztogo/phonopy
phonopy/structure/cells.py
estimate_supercell_matrix
def estimate_supercell_matrix(spglib_dataset, max_num_atoms=120): """Estimate supercell matrix from conventional cell Diagonal supercell matrix is estimated from basis vector lengths and maximum number of atoms to be accepted. Supercell is assumed to be made from the stand...
python
def estimate_supercell_matrix(spglib_dataset, max_num_atoms=120): """Estimate supercell matrix from conventional cell Diagonal supercell matrix is estimated from basis vector lengths and maximum number of atoms to be accepted. Supercell is assumed to be made from the stand...
[ "def", "estimate_supercell_matrix", "(", "spglib_dataset", ",", "max_num_atoms", "=", "120", ")", ":", "spg_num", "=", "spglib_dataset", "[", "'number'", "]", "num_atoms", "=", "len", "(", "spglib_dataset", "[", "'std_types'", "]", ")", "lengths", "=", "_get_lat...
Estimate supercell matrix from conventional cell Diagonal supercell matrix is estimated from basis vector lengths and maximum number of atoms to be accepted. Supercell is assumed to be made from the standardized cell and to be closest to sphere under keeping lattice symmetry. For triclinic, monoclinic,...
[ "Estimate", "supercell", "matrix", "from", "conventional", "cell" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L1208-L1246
train
atztogo/phonopy
phonopy/structure/cells.py
_get_lattice_parameters
def _get_lattice_parameters(lattice): """Return basis vector lengths Parameters ---------- lattice : array_like Basis vectors given as column vectors shape=(3, 3), dtype='double' Returns ------- ndarray, shape=(3,), dtype='double' """ return np.array(np.sqrt(np.do...
python
def _get_lattice_parameters(lattice): """Return basis vector lengths Parameters ---------- lattice : array_like Basis vectors given as column vectors shape=(3, 3), dtype='double' Returns ------- ndarray, shape=(3,), dtype='double' """ return np.array(np.sqrt(np.do...
[ "def", "_get_lattice_parameters", "(", "lattice", ")", ":", "return", "np", ".", "array", "(", "np", ".", "sqrt", "(", "np", ".", "dot", "(", "lattice", ".", "T", ",", "lattice", ")", ".", "diagonal", "(", ")", ")", ",", "dtype", "=", "'double'", "...
Return basis vector lengths Parameters ---------- lattice : array_like Basis vectors given as column vectors shape=(3, 3), dtype='double' Returns ------- ndarray, shape=(3,), dtype='double'
[ "Return", "basis", "vector", "lengths" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L1249-L1265
train
atztogo/phonopy
phonopy/structure/cells.py
SNF3x3._second
def _second(self): """Find Smith normal form for Right-low 2x2 matrix""" self._second_one_loop() A = self._A if A[2, 1] == 0: return True elif A[2, 1] % A[1, 1] == 0: self._second_finalize() self._Ps += self._L self._L = [] ...
python
def _second(self): """Find Smith normal form for Right-low 2x2 matrix""" self._second_one_loop() A = self._A if A[2, 1] == 0: return True elif A[2, 1] % A[1, 1] == 0: self._second_finalize() self._Ps += self._L self._L = [] ...
[ "def", "_second", "(", "self", ")", ":", "self", ".", "_second_one_loop", "(", ")", "A", "=", "self", ".", "_A", "if", "A", "[", "2", ",", "1", "]", "==", "0", ":", "return", "True", "elif", "A", "[", "2", ",", "1", "]", "%", "A", "[", "1",...
Find Smith normal form for Right-low 2x2 matrix
[ "Find", "Smith", "normal", "form", "for", "Right", "-", "low", "2x2", "matrix" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L1030-L1043
train
atztogo/phonopy
phonopy/structure/cells.py
SNF3x3._second_column
def _second_column(self): """Right-low 2x2 matrix Assume elements in first row and column are all zero except for A[0,0]. """ if self._A[1, 1] == 0 and self._A[2, 1] != 0: self._swap_rows(1, 2) if self._A[2, 1] != 0: self._zero_second_column()
python
def _second_column(self): """Right-low 2x2 matrix Assume elements in first row and column are all zero except for A[0,0]. """ if self._A[1, 1] == 0 and self._A[2, 1] != 0: self._swap_rows(1, 2) if self._A[2, 1] != 0: self._zero_second_column()
[ "def", "_second_column", "(", "self", ")", ":", "if", "self", ".", "_A", "[", "1", ",", "1", "]", "==", "0", "and", "self", ".", "_A", "[", "2", ",", "1", "]", "!=", "0", ":", "self", ".", "_swap_rows", "(", "1", ",", "2", ")", "if", "self"...
Right-low 2x2 matrix Assume elements in first row and column are all zero except for A[0,0].
[ "Right", "-", "low", "2x2", "matrix" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L1055-L1066
train
atztogo/phonopy
phonopy/structure/cells.py
SNF3x3._swap_rows
def _swap_rows(self, i, j): """Swap i and j rows As the side effect, determinant flips. """ L = np.eye(3, dtype='intc') L[i, i] = 0 L[j, j] = 0 L[i, j] = 1 L[j, i] = 1 self._L.append(L.copy()) self._A = np.dot(L, self._A)
python
def _swap_rows(self, i, j): """Swap i and j rows As the side effect, determinant flips. """ L = np.eye(3, dtype='intc') L[i, i] = 0 L[j, j] = 0 L[i, j] = 1 L[j, i] = 1 self._L.append(L.copy()) self._A = np.dot(L, self._A)
[ "def", "_swap_rows", "(", "self", ",", "i", ",", "j", ")", ":", "L", "=", "np", ".", "eye", "(", "3", ",", "dtype", "=", "'intc'", ")", "L", "[", "i", ",", "i", "]", "=", "0", "L", "[", "j", ",", "j", "]", "=", "0", "L", "[", "i", ","...
Swap i and j rows As the side effect, determinant flips.
[ "Swap", "i", "and", "j", "rows" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L1088-L1101
train
atztogo/phonopy
phonopy/structure/cells.py
SNF3x3._flip_sign_row
def _flip_sign_row(self, i): """Multiply -1 for all elements in row""" L = np.eye(3, dtype='intc') L[i, i] = -1 self._L.append(L.copy()) self._A = np.dot(L, self._A)
python
def _flip_sign_row(self, i): """Multiply -1 for all elements in row""" L = np.eye(3, dtype='intc') L[i, i] = -1 self._L.append(L.copy()) self._A = np.dot(L, self._A)
[ "def", "_flip_sign_row", "(", "self", ",", "i", ")", ":", "L", "=", "np", ".", "eye", "(", "3", ",", "dtype", "=", "'intc'", ")", "L", "[", "i", ",", "i", "]", "=", "-", "1", "self", ".", "_L", ".", "append", "(", "L", ".", "copy", "(", "...
Multiply -1 for all elements in row
[ "Multiply", "-", "1", "for", "all", "elements", "in", "row" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/structure/cells.py#L1103-L1109
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.dataset
def dataset(self, dataset): """Set dataset having displacements and optionally forces Note ---- Elements of the list accessed by 'first_atoms' corresponds to each displaced supercell. Each displaced supercell contains only one displacement. dict['first_atoms']['forces'] ...
python
def dataset(self, dataset): """Set dataset having displacements and optionally forces Note ---- Elements of the list accessed by 'first_atoms' corresponds to each displaced supercell. Each displaced supercell contains only one displacement. dict['first_atoms']['forces'] ...
[ "def", "dataset", "(", "self", ",", "dataset", ")", ":", "if", "'displacements'", "in", "dataset", ":", "natom", "=", "self", ".", "_supercell", ".", "get_number_of_atoms", "(", ")", "if", "type", "(", "dataset", "[", "'displacements'", "]", ")", "is", "...
Set dataset having displacements and optionally forces Note ---- Elements of the list accessed by 'first_atoms' corresponds to each displaced supercell. Each displaced supercell contains only one displacement. dict['first_atoms']['forces'] gives atomic forces in each dis...
[ "Set", "dataset", "having", "displacements", "and", "optionally", "forces" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L448-L492
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.forces
def forces(self, sets_of_forces): """Set forces in displacement dataset. Parameters ---------- sets_of_forces : array_like A set of atomic forces in displaced supercells. The order of displaced supercells has to match with that in displacement dataset...
python
def forces(self, sets_of_forces): """Set forces in displacement dataset. Parameters ---------- sets_of_forces : array_like A set of atomic forces in displaced supercells. The order of displaced supercells has to match with that in displacement dataset...
[ "def", "forces", "(", "self", ",", "sets_of_forces", ")", ":", "if", "'first_atoms'", "in", "self", ".", "_displacement_dataset", ":", "for", "disp", ",", "forces", "in", "zip", "(", "self", ".", "_displacement_dataset", "[", "'first_atoms'", "]", ",", "sets...
Set forces in displacement dataset. Parameters ---------- sets_of_forces : array_like A set of atomic forces in displaced supercells. The order of displaced supercells has to match with that in displacement dataset. shape=(displaced supercells, at...
[ "Set", "forces", "in", "displacement", "dataset", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L498-L522
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.force_constants
def force_constants(self, force_constants): """Set force constants Parameters ---------- force_constants : array_like Force constants matrix. If this is given in own condiguous ndarray with order='C' and dtype='double', internal copy of data is avoide...
python
def force_constants(self, force_constants): """Set force constants Parameters ---------- force_constants : array_like Force constants matrix. If this is given in own condiguous ndarray with order='C' and dtype='double', internal copy of data is avoide...
[ "def", "force_constants", "(", "self", ",", "force_constants", ")", ":", "if", "type", "(", "force_constants", ")", "is", "np", ".", "ndarray", ":", "fc_shape", "=", "force_constants", ".", "shape", "if", "fc_shape", "[", "0", "]", "!=", "fc_shape", "[", ...
Set force constants Parameters ---------- force_constants : array_like Force constants matrix. If this is given in own condiguous ndarray with order='C' and dtype='double', internal copy of data is avoided. Therefore some computational resources are saved. ...
[ "Set", "force", "constants" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L528-L553
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.generate_displacements
def generate_displacements(self, distance=0.01, is_plusminus='auto', is_diagonal=True, is_trigonal=False): """Generate displacement dataset""" displacement_directions = get_least_d...
python
def generate_displacements(self, distance=0.01, is_plusminus='auto', is_diagonal=True, is_trigonal=False): """Generate displacement dataset""" displacement_directions = get_least_d...
[ "def", "generate_displacements", "(", "self", ",", "distance", "=", "0.01", ",", "is_plusminus", "=", "'auto'", ",", "is_diagonal", "=", "True", ",", "is_trigonal", "=", "False", ")", ":", "displacement_directions", "=", "get_least_displacements", "(", "self", "...
Generate displacement dataset
[ "Generate", "displacement", "dataset" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L570-L586
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.get_dynamical_matrix_at_q
def get_dynamical_matrix_at_q(self, q): """Calculate dynamical matrix at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,), dtype='double' Returns ------- dynamical_matrix: ndarray Dynamical matrix. ...
python
def get_dynamical_matrix_at_q(self, q): """Calculate dynamical matrix at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,), dtype='double' Returns ------- dynamical_matrix: ndarray Dynamical matrix. ...
[ "def", "get_dynamical_matrix_at_q", "(", "self", ",", "q", ")", ":", "self", ".", "_set_dynamical_matrix", "(", ")", "if", "self", ".", "_dynamical_matrix", "is", "None", ":", "msg", "=", "(", "\"Dynamical matrix has not yet built.\"", ")", "raise", "RuntimeError"...
Calculate dynamical matrix at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,), dtype='double' Returns ------- dynamical_matrix: ndarray Dynamical matrix. shape=(bands, bands), dtype='complex'
[ "Calculate", "dynamical", "matrix", "at", "a", "given", "q", "-", "point" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L652-L675
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.get_frequencies
def get_frequencies(self, q): """Calculate phonon frequencies at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,), dtype='double' Returns ------- frequencies: ndarray Phonon frequencies. s...
python
def get_frequencies(self, q): """Calculate phonon frequencies at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,), dtype='double' Returns ------- frequencies: ndarray Phonon frequencies. s...
[ "def", "get_frequencies", "(", "self", ",", "q", ")", ":", "self", ".", "_set_dynamical_matrix", "(", ")", "if", "self", ".", "_dynamical_matrix", "is", "None", ":", "msg", "=", "(", "\"Dynamical matrix has not yet built.\"", ")", "raise", "RuntimeError", "(", ...
Calculate phonon frequencies at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,), dtype='double' Returns ------- frequencies: ndarray Phonon frequencies. shape=(bands, ), dtype='double'
[ "Calculate", "phonon", "frequencies", "at", "a", "given", "q", "-", "point" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L677-L707
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.get_frequencies_with_eigenvectors
def get_frequencies_with_eigenvectors(self, q): """Calculate phonon frequencies and eigenvectors at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,) Returns ------- (frequencies, eigenvectors) frequencie...
python
def get_frequencies_with_eigenvectors(self, q): """Calculate phonon frequencies and eigenvectors at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,) Returns ------- (frequencies, eigenvectors) frequencie...
[ "def", "get_frequencies_with_eigenvectors", "(", "self", ",", "q", ")", ":", "self", ".", "_set_dynamical_matrix", "(", ")", "if", "self", ".", "_dynamical_matrix", "is", "None", ":", "msg", "=", "(", "\"Dynamical matrix has not yet built.\"", ")", "raise", "Runti...
Calculate phonon frequencies and eigenvectors at a given q-point Parameters ---------- q: array_like A q-vector. shape=(3,) Returns ------- (frequencies, eigenvectors) frequencies: ndarray Phonon frequencies shape...
[ "Calculate", "phonon", "frequencies", "and", "eigenvectors", "at", "a", "given", "q", "-", "point" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L709-L746
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.run_band_structure
def run_band_structure(self, paths, with_eigenvectors=False, with_group_velocities=False, is_band_connection=False, path_connections=None, labels=None, ...
python
def run_band_structure(self, paths, with_eigenvectors=False, with_group_velocities=False, is_band_connection=False, path_connections=None, labels=None, ...
[ "def", "run_band_structure", "(", "self", ",", "paths", ",", "with_eigenvectors", "=", "False", ",", "with_group_velocities", "=", "False", ",", "is_band_connection", "=", "False", ",", "path_connections", "=", "None", ",", "labels", "=", "None", ",", "is_legacy...
Run phonon band structure calculation. Parameters ---------- paths : List of array_like Sets of qpoints that can be passed to phonopy.set_band_structure(). Numbers of qpoints can be different. shape of each array_like : (qpoints, 3) with_eigenvectors ...
[ "Run", "phonon", "band", "structure", "calculation", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L749-L808
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.init_mesh
def init_mesh(self, mesh=100.0, shift=None, is_time_reversal=True, is_mesh_symmetry=True, with_eigenvectors=False, with_group_velocities=False, is_gamma_center=False, use_iter_...
python
def init_mesh(self, mesh=100.0, shift=None, is_time_reversal=True, is_mesh_symmetry=True, with_eigenvectors=False, with_group_velocities=False, is_gamma_center=False, use_iter_...
[ "def", "init_mesh", "(", "self", ",", "mesh", "=", "100.0", ",", "shift", "=", "None", ",", "is_time_reversal", "=", "True", ",", "is_mesh_symmetry", "=", "True", ",", "with_eigenvectors", "=", "False", ",", "with_group_velocities", "=", "False", ",", "is_ga...
Initialize mesh sampling phonon calculation without starting to run. Phonon calculation starts explicitly with calling Mesh.run() or implicitly with accessing getters of Mesh instance, e.g., Mesh.frequencies. Parameters ---------- mesh: array_like or float, optional ...
[ "Initialize", "mesh", "sampling", "phonon", "calculation", "without", "starting", "to", "run", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L974-L1082
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.run_mesh
def run_mesh(self, mesh=100.0, shift=None, is_time_reversal=True, is_mesh_symmetry=True, with_eigenvectors=False, with_group_velocities=False, is_gamma_center=False): """Run mesh sampling phono...
python
def run_mesh(self, mesh=100.0, shift=None, is_time_reversal=True, is_mesh_symmetry=True, with_eigenvectors=False, with_group_velocities=False, is_gamma_center=False): """Run mesh sampling phono...
[ "def", "run_mesh", "(", "self", ",", "mesh", "=", "100.0", ",", "shift", "=", "None", ",", "is_time_reversal", "=", "True", ",", "is_mesh_symmetry", "=", "True", ",", "with_eigenvectors", "=", "False", ",", "with_group_velocities", "=", "False", ",", "is_gam...
Run mesh sampling phonon calculation. See the parameter details in Phonopy.init_mesh().
[ "Run", "mesh", "sampling", "phonon", "calculation", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1084-L1105
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.set_mesh
def set_mesh(self, mesh, shift=None, is_time_reversal=True, is_mesh_symmetry=True, is_eigenvectors=False, is_gamma_center=False, run_immediately=True): """Phonon calculations on sampling mesh g...
python
def set_mesh(self, mesh, shift=None, is_time_reversal=True, is_mesh_symmetry=True, is_eigenvectors=False, is_gamma_center=False, run_immediately=True): """Phonon calculations on sampling mesh g...
[ "def", "set_mesh", "(", "self", ",", "mesh", ",", "shift", "=", "None", ",", "is_time_reversal", "=", "True", ",", "is_mesh_symmetry", "=", "True", ",", "is_eigenvectors", "=", "False", ",", "is_gamma_center", "=", "False", ",", "run_immediately", "=", "True...
Phonon calculations on sampling mesh grids Parameters ---------- mesh: array_like Mesh numbers along a, b, c axes. dtype='intc' shape=(3,) shift: array_like, optional, default None (no shift) Mesh shifts along a*, b*, c* axes with respect ...
[ "Phonon", "calculations", "on", "sampling", "mesh", "grids" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1107-L1168
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.get_mesh_dict
def get_mesh_dict(self): """Returns calculated mesh sampling phonons Returns ------- dict keys: qpoints, weights, frequencies, eigenvectors, and group_velocities Each value for the corresponding key is explained as below. qpoints: ...
python
def get_mesh_dict(self): """Returns calculated mesh sampling phonons Returns ------- dict keys: qpoints, weights, frequencies, eigenvectors, and group_velocities Each value for the corresponding key is explained as below. qpoints: ...
[ "def", "get_mesh_dict", "(", "self", ")", ":", "if", "self", ".", "_mesh", "is", "None", ":", "msg", "=", "(", "\"run_mesh has to be done.\"", ")", "raise", "RuntimeError", "(", "msg", ")", "retdict", "=", "{", "'qpoints'", ":", "self", ".", "_mesh", "."...
Returns calculated mesh sampling phonons Returns ------- dict keys: qpoints, weights, frequencies, eigenvectors, and group_velocities Each value for the corresponding key is explained as below. qpoints: ndarray q-points in ...
[ "Returns", "calculated", "mesh", "sampling", "phonons" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1170-L1216
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.set_iter_mesh
def set_iter_mesh(self, mesh, shift=None, is_time_reversal=True, is_mesh_symmetry=True, is_eigenvectors=False, is_gamma_center=False): """Create an IterMesh instancer Attr...
python
def set_iter_mesh(self, mesh, shift=None, is_time_reversal=True, is_mesh_symmetry=True, is_eigenvectors=False, is_gamma_center=False): """Create an IterMesh instancer Attr...
[ "def", "set_iter_mesh", "(", "self", ",", "mesh", ",", "shift", "=", "None", ",", "is_time_reversal", "=", "True", ",", "is_mesh_symmetry", "=", "True", ",", "is_eigenvectors", "=", "False", ",", "is_gamma_center", "=", "False", ")", ":", "warnings", ".", ...
Create an IterMesh instancer Attributes ---------- See set_mesh method.
[ "Create", "an", "IterMesh", "instancer" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1252-L1277
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.run_qpoints
def run_qpoints(self, q_points, with_eigenvectors=False, with_group_velocities=False, with_dynamical_matrices=False, nac_q_direction=None): """Phonon calculations on q-points. Parameters --------...
python
def run_qpoints(self, q_points, with_eigenvectors=False, with_group_velocities=False, with_dynamical_matrices=False, nac_q_direction=None): """Phonon calculations on q-points. Parameters --------...
[ "def", "run_qpoints", "(", "self", ",", "q_points", ",", "with_eigenvectors", "=", "False", ",", "with_group_velocities", "=", "False", ",", "with_dynamical_matrices", "=", "False", ",", "nac_q_direction", "=", "None", ")", ":", "if", "self", ".", "_dynamical_ma...
Phonon calculations on q-points. Parameters ---------- q_points: array_like or float, optional q-points in reduced coordinates. dtype='double', shape=(q-points, 3) with_eigenvectors: bool, optional Eigenvectors are stored by setting True. Default Fals...
[ "Phonon", "calculations", "on", "q", "-", "points", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1349-L1394
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.run_total_dos
def run_total_dos(self, sigma=None, freq_min=None, freq_max=None, freq_pitch=None, use_tetrahedron_method=True): """Calculate total DOS from phonons on sampling mesh. Parameters -------...
python
def run_total_dos(self, sigma=None, freq_min=None, freq_max=None, freq_pitch=None, use_tetrahedron_method=True): """Calculate total DOS from phonons on sampling mesh. Parameters -------...
[ "def", "run_total_dos", "(", "self", ",", "sigma", "=", "None", ",", "freq_min", "=", "None", ",", "freq_max", "=", "None", ",", "freq_pitch", "=", "None", ",", "use_tetrahedron_method", "=", "True", ")", ":", "if", "self", ".", "_mesh", "is", "None", ...
Calculate total DOS from phonons on sampling mesh. Parameters ---------- sigma : float, optional Smearing width for smearing method. Default is None freq_min, freq_max, freq_pitch : float, optional Minimum and maximum frequencies in which range DOS is computed ...
[ "Calculate", "total", "DOS", "from", "phonons", "on", "sampling", "mesh", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1436-L1466
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.get_total_DOS
def get_total_DOS(self): """Return frequency points and total DOS as a tuple. Returns ------- A tuple with (frequency_points, total_dos). frequency_points: ndarray shape=(frequency_sampling_points, ), dtype='double' total_dos: shape=(frequency_sa...
python
def get_total_DOS(self): """Return frequency points and total DOS as a tuple. Returns ------- A tuple with (frequency_points, total_dos). frequency_points: ndarray shape=(frequency_sampling_points, ), dtype='double' total_dos: shape=(frequency_sa...
[ "def", "get_total_DOS", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"Phonopy.get_total_DOS is deprecated. \"", "\"Use Phonopy.get_total_dos_dict.\"", ",", "DeprecationWarning", ")", "dos", "=", "self", ".", "get_total_dos_dict", "(", ")", "return", "dos", "...
Return frequency points and total DOS as a tuple. Returns ------- A tuple with (frequency_points, total_dos). frequency_points: ndarray shape=(frequency_sampling_points, ), dtype='double' total_dos: shape=(frequency_sampling_points, ), dtype='double'
[ "Return", "frequency", "points", "and", "total", "DOS", "as", "a", "tuple", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1519-L1538
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.run_projected_dos
def run_projected_dos(self, sigma=None, freq_min=None, freq_max=None, freq_pitch=None, use_tetrahedron_method=True, direction=None, xyz_pr...
python
def run_projected_dos(self, sigma=None, freq_min=None, freq_max=None, freq_pitch=None, use_tetrahedron_method=True, direction=None, xyz_pr...
[ "def", "run_projected_dos", "(", "self", ",", "sigma", "=", "None", ",", "freq_min", "=", "None", ",", "freq_max", "=", "None", ",", "freq_pitch", "=", "None", ",", "use_tetrahedron_method", "=", "True", ",", "direction", "=", "None", ",", "xyz_projection", ...
Calculate projected DOS from phonons on sampling mesh. Parameters ---------- sigma : float, optional Smearing width for smearing method. Default is None freq_min, freq_max, freq_pitch : float, optional Minimum and maximum frequencies in which range DOS is compute...
[ "Calculate", "projected", "DOS", "from", "phonons", "on", "sampling", "mesh", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1578-L1633
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.get_partial_DOS
def get_partial_DOS(self): """Return frequency points and partial DOS as a tuple. Projection is done to atoms and may be also done along directions depending on the parameters at run_partial_dos. Returns ------- A tuple with (frequency_points, partial_dos). fre...
python
def get_partial_DOS(self): """Return frequency points and partial DOS as a tuple. Projection is done to atoms and may be also done along directions depending on the parameters at run_partial_dos. Returns ------- A tuple with (frequency_points, partial_dos). fre...
[ "def", "get_partial_DOS", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"Phonopy.get_partial_DOS is deprecated. \"", "\"Use Phonopy.get_projected_dos_dict.\"", ",", "DeprecationWarning", ")", "pdos", "=", "self", ".", "get_projected_dos_dict", "(", ")", "return",...
Return frequency points and partial DOS as a tuple. Projection is done to atoms and may be also done along directions depending on the parameters at run_partial_dos. Returns ------- A tuple with (frequency_points, partial_dos). frequency_points: ndarray sha...
[ "Return", "frequency", "points", "and", "partial", "DOS", "as", "a", "tuple", "." ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1695-L1717
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.plot_projected_dos
def plot_projected_dos(self, pdos_indices=None, legend=None): """Plot projected DOS Parameters ---------- pdos_indices : list of list, optional Sets of indices of atoms whose projected DOS are summed over. The indices start with 0. An example is as follwos: ...
python
def plot_projected_dos(self, pdos_indices=None, legend=None): """Plot projected DOS Parameters ---------- pdos_indices : list of list, optional Sets of indices of atoms whose projected DOS are summed over. The indices start with 0. An example is as follwos: ...
[ "def", "plot_projected_dos", "(", "self", ",", "pdos_indices", "=", "None", ",", "legend", "=", "None", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", ")", "ax", ".", "xaxis", ".", "s...
Plot projected DOS Parameters ---------- pdos_indices : list of list, optional Sets of indices of atoms whose projected DOS are summed over. The indices start with 0. An example is as follwos: pdos_indices=[[0, 1], [2, 3, 4, 5]] Default is No...
[ "Plot", "projected", "DOS" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1727-L1760
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.run_thermal_properties
def run_thermal_properties(self, t_min=0, t_max=1000, t_step=10, temperatures=None, is_projection=False, band_indices=None, ...
python
def run_thermal_properties(self, t_min=0, t_max=1000, t_step=10, temperatures=None, is_projection=False, band_indices=None, ...
[ "def", "run_thermal_properties", "(", "self", ",", "t_min", "=", "0", ",", "t_max", "=", "1000", ",", "t_step", "=", "10", ",", "temperatures", "=", "None", ",", "is_projection", "=", "False", ",", "band_indices", "=", "None", ",", "cutoff_frequency", "=",...
Calculate thermal properties at constant volume Parameters ---------- t_min, t_max, t_step : float, optional Minimum and maximum temperatures and the interval in this temperature range. Default values are 0, 1000, and 10. temperatures : array_like, optional ...
[ "Calculate", "thermal", "properties", "at", "constant", "volume" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1772-L1810
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.get_thermal_properties
def get_thermal_properties(self): """Return thermal properties Returns ------- (temperatures, free energy, entropy, heat capacity) """ warnings.warn("Phonopy.get_thermal_properties is deprecated. " "Use Phonopy.get_thermal_properties_dict.", ...
python
def get_thermal_properties(self): """Return thermal properties Returns ------- (temperatures, free energy, entropy, heat capacity) """ warnings.warn("Phonopy.get_thermal_properties is deprecated. " "Use Phonopy.get_thermal_properties_dict.", ...
[ "def", "get_thermal_properties", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"Phonopy.get_thermal_properties is deprecated. \"", "\"Use Phonopy.get_thermal_properties_dict.\"", ",", "DeprecationWarning", ")", "tp", "=", "self", ".", "get_thermal_properties_dict", "...
Return thermal properties Returns ------- (temperatures, free energy, entropy, heat capacity)
[ "Return", "thermal", "properties" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1856-L1872
train
atztogo/phonopy
phonopy/api_phonopy.py
Phonopy.run_thermal_displacements
def run_thermal_displacements(self, t_min=0, t_max=1000, t_step=10, temperatures=None, direction=None, freq_min=None...
python
def run_thermal_displacements(self, t_min=0, t_max=1000, t_step=10, temperatures=None, direction=None, freq_min=None...
[ "def", "run_thermal_displacements", "(", "self", ",", "t_min", "=", "0", ",", "t_max", "=", "1000", ",", "t_step", "=", "10", ",", "temperatures", "=", "None", ",", "direction", "=", "None", ",", "freq_min", "=", "None", ",", "freq_max", "=", "None", "...
Prepare thermal displacements calculation Parameters ---------- t_min, t_max, t_step : float, optional Minimum and maximum temperatures and the interval in this temperature range. Default valuues are 0, 1000, and 10. temperatures : array_like, optional ...
[ "Prepare", "thermal", "displacements", "calculation" ]
869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1897-L1959
train