repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client.update_item
def update_item(self, table_name, key_dict, condition_expression=None, update_expression=None, expression_attribute_names=None, expression_attribute_values=None, return_consumed_capacity=None, return_...
python
def update_item(self, table_name, key_dict, condition_expression=None, update_expression=None, expression_attribute_names=None, expression_attribute_values=None, return_consumed_capacity=None, return_...
[ "def", "update_item", "(", "self", ",", "table_name", ",", "key_dict", ",", "condition_expression", "=", "None", ",", "update_expression", "=", "None", ",", "expression_attribute_names", "=", "None", ",", "expression_attribute_values", "=", "None", ",", "return_cons...
Invoke the `UpdateItem`_ function. Edits an existing item's attributes, or adds a new item to the table if it does not already exist. You can put, delete, or add attribute values. You can also perform a conditional update on an existing item (insert a new attribute name-value pair if it...
[ "Invoke", "the", "UpdateItem", "_", "function", "." ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L333-L411
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client.query
def query(self, table_name, index_name=None, consistent_read=None, key_condition_expression=None, filter_expression=None, expression_attribute_names=None, expression_attribute_values=None, projection_expression=None, ...
python
def query(self, table_name, index_name=None, consistent_read=None, key_condition_expression=None, filter_expression=None, expression_attribute_names=None, expression_attribute_values=None, projection_expression=None, ...
[ "def", "query", "(", "self", ",", "table_name", ",", "index_name", "=", "None", ",", "consistent_read", "=", "None", ",", "key_condition_expression", "=", "None", ",", "filter_expression", "=", "None", ",", "expression_attribute_names", "=", "None", ",", "expres...
A `Query`_ operation uses the primary key of a table or a secondary index to directly access items from that table or index. :param str table_name: The name of the table containing the requested items. :param bool consistent_read: Determines the read consistency model: If ...
[ "A", "Query", "_", "operation", "uses", "the", "primary", "key", "of", "a", "table", "or", "a", "secondary", "index", "to", "directly", "access", "items", "from", "that", "table", "or", "index", "." ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L502-L653
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client.scan
def scan(self, table_name, index_name=None, consistent_read=None, projection_expression=None, filter_expression=None, expression_attribute_names=None, expression_attribute_values=None, segment=None, tota...
python
def scan(self, table_name, index_name=None, consistent_read=None, projection_expression=None, filter_expression=None, expression_attribute_names=None, expression_attribute_values=None, segment=None, tota...
[ "def", "scan", "(", "self", ",", "table_name", ",", "index_name", "=", "None", ",", "consistent_read", "=", "None", ",", "projection_expression", "=", "None", ",", "filter_expression", "=", "None", ",", "expression_attribute_names", "=", "None", ",", "expression...
The `Scan`_ operation returns one or more items and item attributes by accessing every item in a table or a secondary index. If the total number of scanned items exceeds the maximum data set size limit of 1 MB, the scan stops and results are returned to the user as a ``LastEvaluatedKey`...
[ "The", "Scan", "_", "operation", "returns", "one", "or", "more", "items", "and", "item", "attributes", "by", "accessing", "every", "item", "in", "a", "table", "or", "a", "secondary", "index", "." ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L655-L726
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client.execute
def execute(self, action, parameters): """ Execute a DynamoDB action with the given parameters. The method will retry requests that failed due to OS level errors or when being throttled by DynamoDB. :param str action: DynamoDB action to invoke :param dict parameters: par...
python
def execute(self, action, parameters): """ Execute a DynamoDB action with the given parameters. The method will retry requests that failed due to OS level errors or when being throttled by DynamoDB. :param str action: DynamoDB action to invoke :param dict parameters: par...
[ "def", "execute", "(", "self", ",", "action", ",", "parameters", ")", ":", "measurements", "=", "collections", ".", "deque", "(", "[", "]", ",", "self", ".", "_max_retries", ")", "for", "attempt", "in", "range", "(", "1", ",", "self", ".", "_max_retrie...
Execute a DynamoDB action with the given parameters. The method will retry requests that failed due to OS level errors or when being throttled by DynamoDB. :param str action: DynamoDB action to invoke :param dict parameters: parameters to send into the action :rtype: tornado.con...
[ "Execute", "a", "DynamoDB", "action", "with", "the", "given", "parameters", ".", "The", "method", "will", "retry", "requests", "that", "failed", "due", "to", "OS", "level", "errors", "or", "when", "being", "throttled", "by", "DynamoDB", "." ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L729-L790
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client.set_error_callback
def set_error_callback(self, callback): """Assign a method to invoke when a request has encountered an unrecoverable error in an action execution. :param method callback: The method to invoke """ self.logger.debug('Setting error callback: %r', callback) self._on_error =...
python
def set_error_callback(self, callback): """Assign a method to invoke when a request has encountered an unrecoverable error in an action execution. :param method callback: The method to invoke """ self.logger.debug('Setting error callback: %r', callback) self._on_error =...
[ "def", "set_error_callback", "(", "self", ",", "callback", ")", ":", "self", ".", "logger", ".", "debug", "(", "'Setting error callback: %r'", ",", "callback", ")", "self", ".", "_on_error", "=", "callback" ]
Assign a method to invoke when a request has encountered an unrecoverable error in an action execution. :param method callback: The method to invoke
[ "Assign", "a", "method", "to", "invoke", "when", "a", "request", "has", "encountered", "an", "unrecoverable", "error", "in", "an", "action", "execution", "." ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L792-L800
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client.set_instrumentation_callback
def set_instrumentation_callback(self, callback): """Assign a method to invoke when a request has completed gathering measurements. :param method callback: The method to invoke """ self.logger.debug('Setting instrumentation callback: %r', callback) self._instrumentation...
python
def set_instrumentation_callback(self, callback): """Assign a method to invoke when a request has completed gathering measurements. :param method callback: The method to invoke """ self.logger.debug('Setting instrumentation callback: %r', callback) self._instrumentation...
[ "def", "set_instrumentation_callback", "(", "self", ",", "callback", ")", ":", "self", ".", "logger", ".", "debug", "(", "'Setting instrumentation callback: %r'", ",", "callback", ")", "self", ".", "_instrumentation_callback", "=", "callback" ]
Assign a method to invoke when a request has completed gathering measurements. :param method callback: The method to invoke
[ "Assign", "a", "method", "to", "invoke", "when", "a", "request", "has", "completed", "gathering", "measurements", "." ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L802-L810
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client._execute
def _execute(self, action, parameters, attempt, measurements): """Invoke a DynamoDB action :param str action: DynamoDB action to invoke :param dict parameters: parameters to send into the action :param int attempt: Which attempt number this is :param list measurements: A list fo...
python
def _execute(self, action, parameters, attempt, measurements): """Invoke a DynamoDB action :param str action: DynamoDB action to invoke :param dict parameters: parameters to send into the action :param int attempt: Which attempt number this is :param list measurements: A list fo...
[ "def", "_execute", "(", "self", ",", "action", ",", "parameters", ",", "attempt", ",", "measurements", ")", ":", "future", "=", "concurrent", ".", "Future", "(", ")", "start", "=", "time", ".", "time", "(", ")", "def", "handle_response", "(", "request", ...
Invoke a DynamoDB action :param str action: DynamoDB action to invoke :param dict parameters: parameters to send into the action :param int attempt: Which attempt number this is :param list measurements: A list for accumulating request measurements :rtype: tornado.concurrent.Fut...
[ "Invoke", "a", "DynamoDB", "action" ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L812-L842
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client._on_response
def _on_response(self, action, table, attempt, start, response, future, measurements): """Invoked when the HTTP request to the DynamoDB has returned and is responsible for setting the future result or exception based upon the HTTP response provided. :param str actio...
python
def _on_response(self, action, table, attempt, start, response, future, measurements): """Invoked when the HTTP request to the DynamoDB has returned and is responsible for setting the future result or exception based upon the HTTP response provided. :param str actio...
[ "def", "_on_response", "(", "self", ",", "action", ",", "table", ",", "attempt", ",", "start", ",", "response", ",", "future", ",", "measurements", ")", ":", "self", ".", "logger", ".", "debug", "(", "'%s on %s request #%i = %r'", ",", "action", ",", "tabl...
Invoked when the HTTP request to the DynamoDB has returned and is responsible for setting the future result or exception based upon the HTTP response provided. :param str action: The action that was taken :param str table: The table name the action was made against :param int at...
[ "Invoked", "when", "the", "HTTP", "request", "to", "the", "DynamoDB", "has", "returned", "and", "is", "responsible", "for", "setting", "the", "future", "result", "or", "exception", "based", "upon", "the", "HTTP", "response", "provided", "." ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L855-L907
sprockets/sprockets-dynamodb
sprockets_dynamodb/client.py
Client._process_response
def _process_response(response): """Process the raw AWS response, returning either the mapped exception or deserialized response. :param tornado.concurrent.Future response: The request future :rtype: dict or list :raises: sprockets_dynamodb.exceptions.DynamoDBException ...
python
def _process_response(response): """Process the raw AWS response, returning either the mapped exception or deserialized response. :param tornado.concurrent.Future response: The request future :rtype: dict or list :raises: sprockets_dynamodb.exceptions.DynamoDBException ...
[ "def", "_process_response", "(", "response", ")", ":", "error", "=", "response", ".", "exception", "(", ")", "if", "error", ":", "if", "isinstance", "(", "error", ",", "aws_exceptions", ".", "AWSError", ")", ":", "if", "error", ".", "args", "[", "1", "...
Process the raw AWS response, returning either the mapped exception or deserialized response. :param tornado.concurrent.Future response: The request future :rtype: dict or list :raises: sprockets_dynamodb.exceptions.DynamoDBException
[ "Process", "the", "raw", "AWS", "response", "returning", "either", "the", "mapped", "exception", "or", "deserialized", "response", "." ]
train
https://github.com/sprockets/sprockets-dynamodb/blob/2e202bcb01f23f828f91299599311007054de4aa/sprockets_dynamodb/client.py#L910-L929
oceanprotocol/oceandb-bigchaindb-driver
oceandb_bigchaindb_driver/plugin.py
Plugin.write
def write(self, obj, resource_id=None): """Write and obj in bdb. :param obj: value to be written in bdb. :param resource_id: id to make possible read and search for an resource. :return: id of the transaction """ if resource_id is not None: if self.read(resou...
python
def write(self, obj, resource_id=None): """Write and obj in bdb. :param obj: value to be written in bdb. :param resource_id: id to make possible read and search for an resource. :return: id of the transaction """ if resource_id is not None: if self.read(resou...
[ "def", "write", "(", "self", ",", "obj", ",", "resource_id", "=", "None", ")", ":", "if", "resource_id", "is", "not", "None", ":", "if", "self", ".", "read", "(", "resource_id", ")", ":", "raise", "ValueError", "(", "\"There are one object already with this ...
Write and obj in bdb. :param obj: value to be written in bdb. :param resource_id: id to make possible read and search for an resource. :return: id of the transaction
[ "Write", "and", "obj", "in", "bdb", "." ]
train
https://github.com/oceanprotocol/oceandb-bigchaindb-driver/blob/82315bcc9f7ba8b01beb08014bdeb541546c6671/oceandb_bigchaindb_driver/plugin.py#L38-L68
oceanprotocol/oceandb-bigchaindb-driver
oceandb_bigchaindb_driver/plugin.py
Plugin._get
def _get(self, tx_id): """Read and obj in bdb using the tx_id. :param resource_id: id of the transaction to be read. :return: value with the data, transaction id and transaction. """ # tx_id=self._find_tx_id(resource_id) value = [ { 'data': tr...
python
def _get(self, tx_id): """Read and obj in bdb using the tx_id. :param resource_id: id of the transaction to be read. :return: value with the data, transaction id and transaction. """ # tx_id=self._find_tx_id(resource_id) value = [ { 'data': tr...
[ "def", "_get", "(", "self", ",", "tx_id", ")", ":", "# tx_id=self._find_tx_id(resource_id)", "value", "=", "[", "{", "'data'", ":", "transaction", "[", "'metadata'", "]", ",", "'id'", ":", "transaction", "[", "'id'", "]", "}", "for", "transaction", "in", "...
Read and obj in bdb using the tx_id. :param resource_id: id of the transaction to be read. :return: value with the data, transaction id and transaction.
[ "Read", "and", "obj", "in", "bdb", "using", "the", "tx_id", "." ]
train
https://github.com/oceanprotocol/oceandb-bigchaindb-driver/blob/82315bcc9f7ba8b01beb08014bdeb541546c6671/oceandb_bigchaindb_driver/plugin.py#L76-L94
oceanprotocol/oceandb-bigchaindb-driver
oceandb_bigchaindb_driver/plugin.py
Plugin._update
def _update(self, metadata, tx_id, resource_id): """Update and obj in bdb using the tx_id. :param metadata: new metadata for the transaction. :param tx_id: id of the transaction to be updated. :return: id of the transaction. """ try: if not tx_id: ...
python
def _update(self, metadata, tx_id, resource_id): """Update and obj in bdb using the tx_id. :param metadata: new metadata for the transaction. :param tx_id: id of the transaction to be updated. :return: id of the transaction. """ try: if not tx_id: ...
[ "def", "_update", "(", "self", ",", "metadata", ",", "tx_id", ",", "resource_id", ")", ":", "try", ":", "if", "not", "tx_id", ":", "sent_tx", "=", "self", ".", "write", "(", "metadata", ",", "resource_id", ")", "self", ".", "logger", ".", "debug", "(...
Update and obj in bdb using the tx_id. :param metadata: new metadata for the transaction. :param tx_id: id of the transaction to be updated. :return: id of the transaction.
[ "Update", "and", "obj", "in", "bdb", "using", "the", "tx_id", "." ]
train
https://github.com/oceanprotocol/oceandb-bigchaindb-driver/blob/82315bcc9f7ba8b01beb08014bdeb541546c6671/oceandb_bigchaindb_driver/plugin.py#L100-L120
oceanprotocol/oceandb-bigchaindb-driver
oceandb_bigchaindb_driver/plugin.py
Plugin.list
def list(self, search_from=None, search_to=None, limit=None): """List all the objects saved in the namespace. :param search_from: TBI :param search_to: TBI :param offset: TBI :param limit: max number of values to be shows. :return: list with transactions. "...
python
def list(self, search_from=None, search_to=None, limit=None): """List all the objects saved in the namespace. :param search_from: TBI :param search_to: TBI :param offset: TBI :param limit: max number of values to be shows. :return: list with transactions. "...
[ "def", "list", "(", "self", ",", "search_from", "=", "None", ",", "search_to", "=", "None", ",", "limit", "=", "None", ")", ":", "l", "=", "[", "]", "for", "i", "in", "self", ".", "_list", "(", ")", ":", "l", ".", "append", "(", "i", "[", "'d...
List all the objects saved in the namespace. :param search_from: TBI :param search_to: TBI :param offset: TBI :param limit: max number of values to be shows. :return: list with transactions.
[ "List", "all", "the", "objects", "saved", "in", "the", "namespace", "." ]
train
https://github.com/oceanprotocol/oceandb-bigchaindb-driver/blob/82315bcc9f7ba8b01beb08014bdeb541546c6671/oceandb_bigchaindb_driver/plugin.py#L122-L134
oceanprotocol/oceandb-bigchaindb-driver
oceandb_bigchaindb_driver/plugin.py
Plugin._list
def _list(self): """List all the objects saved in the namespace. :param search_from: TBI :param search_to: TBI :param offset: TBI :param limit: max number of values to be shows. :return: list with transactions. """ all = self.driver.instance.metadata.get(...
python
def _list(self): """List all the objects saved in the namespace. :param search_from: TBI :param search_to: TBI :param offset: TBI :param limit: max number of values to be shows. :return: list with transactions. """ all = self.driver.instance.metadata.get(...
[ "def", "_list", "(", "self", ")", ":", "all", "=", "self", ".", "driver", ".", "instance", ".", "metadata", ".", "get", "(", "search", "=", "self", ".", "namespace", ")", "list", "=", "[", "]", "for", "id", "in", "all", ":", "try", ":", "if", "...
List all the objects saved in the namespace. :param search_from: TBI :param search_to: TBI :param offset: TBI :param limit: max number of values to be shows. :return: list with transactions.
[ "List", "all", "the", "objects", "saved", "in", "the", "namespace", "." ]
train
https://github.com/oceanprotocol/oceandb-bigchaindb-driver/blob/82315bcc9f7ba8b01beb08014bdeb541546c6671/oceandb_bigchaindb_driver/plugin.py#L136-L154
oceanprotocol/oceandb-bigchaindb-driver
oceandb_bigchaindb_driver/plugin.py
Plugin.query
def query(self, search_model: QueryModel): """Query to bdb namespace. :param query_string: query in string format. :return: list of transactions that match with the query. """ self.logger.debug('bdb::get::{}'.format(search_model.query)) assets = json.loads(requests.post(...
python
def query(self, search_model: QueryModel): """Query to bdb namespace. :param query_string: query in string format. :return: list of transactions that match with the query. """ self.logger.debug('bdb::get::{}'.format(search_model.query)) assets = json.loads(requests.post(...
[ "def", "query", "(", "self", ",", "search_model", ":", "QueryModel", ")", ":", "self", ".", "logger", ".", "debug", "(", "'bdb::get::{}'", ".", "format", "(", "search_model", ".", "query", ")", ")", "assets", "=", "json", ".", "loads", "(", "requests", ...
Query to bdb namespace. :param query_string: query in string format. :return: list of transactions that match with the query.
[ "Query", "to", "bdb", "namespace", "." ]
train
https://github.com/oceanprotocol/oceandb-bigchaindb-driver/blob/82315bcc9f7ba8b01beb08014bdeb541546c6671/oceandb_bigchaindb_driver/plugin.py#L157-L172
oceanprotocol/oceandb-bigchaindb-driver
oceandb_bigchaindb_driver/plugin.py
Plugin._delete
def _delete(self, tx_id): """Delete a transaction. Read documentation about CRAB model in https://blog.bigchaindb.com/crab-create-retrieve-append-burn-b9f6d111f460. :param tx_id: transaction id :return: """ txs = self.driver.instance.transactions.get(asset_id=self.get_asset_id(t...
python
def _delete(self, tx_id): """Delete a transaction. Read documentation about CRAB model in https://blog.bigchaindb.com/crab-create-retrieve-append-burn-b9f6d111f460. :param tx_id: transaction id :return: """ txs = self.driver.instance.transactions.get(asset_id=self.get_asset_id(t...
[ "def", "_delete", "(", "self", ",", "tx_id", ")", ":", "txs", "=", "self", ".", "driver", ".", "instance", ".", "transactions", ".", "get", "(", "asset_id", "=", "self", ".", "get_asset_id", "(", "tx_id", ")", ")", "unspent", "=", "txs", "[", "-", ...
Delete a transaction. Read documentation about CRAB model in https://blog.bigchaindb.com/crab-create-retrieve-append-burn-b9f6d111f460. :param tx_id: transaction id :return:
[ "Delete", "a", "transaction", ".", "Read", "documentation", "about", "CRAB", "model", "in", "https", ":", "//", "blog", ".", "bigchaindb", ".", "com", "/", "crab", "-", "create", "-", "retrieve", "-", "append", "-", "burn", "-", "b9f6d111f460", "." ]
train
https://github.com/oceanprotocol/oceandb-bigchaindb-driver/blob/82315bcc9f7ba8b01beb08014bdeb541546c6671/oceandb_bigchaindb_driver/plugin.py#L204-L238
oceanprotocol/oceandb-bigchaindb-driver
oceandb_bigchaindb_driver/plugin.py
Plugin.get_asset_id
def get_asset_id(self, tx_id): """Return the tx_id of the first transaction. :param tx_id: Transaction id to start the recursive search. :return Transaction id parent. """ tx = self.driver.instance.transactions.retrieve(txid=tx_id) assert tx is not None return tx...
python
def get_asset_id(self, tx_id): """Return the tx_id of the first transaction. :param tx_id: Transaction id to start the recursive search. :return Transaction id parent. """ tx = self.driver.instance.transactions.retrieve(txid=tx_id) assert tx is not None return tx...
[ "def", "get_asset_id", "(", "self", ",", "tx_id", ")", ":", "tx", "=", "self", ".", "driver", ".", "instance", ".", "transactions", ".", "retrieve", "(", "txid", "=", "tx_id", ")", "assert", "tx", "is", "not", "None", "return", "tx", "[", "'id'", "]"...
Return the tx_id of the first transaction. :param tx_id: Transaction id to start the recursive search. :return Transaction id parent.
[ "Return", "the", "tx_id", "of", "the", "first", "transaction", "." ]
train
https://github.com/oceanprotocol/oceandb-bigchaindb-driver/blob/82315bcc9f7ba8b01beb08014bdeb541546c6671/oceandb_bigchaindb_driver/plugin.py#L240-L248
johntruckenbrodt/spatialist
spatialist/envi.py
hdr
def hdr(data, filename): """ write ENVI header files Parameters ---------- data: str or dict the file or dictionary to get the info from filename: str the HDR file to write Returns ------- """ hdrobj = data if isinstance(data, HDRobject) else HDRobject(data) ...
python
def hdr(data, filename): """ write ENVI header files Parameters ---------- data: str or dict the file or dictionary to get the info from filename: str the HDR file to write Returns ------- """ hdrobj = data if isinstance(data, HDRobject) else HDRobject(data) ...
[ "def", "hdr", "(", "data", ",", "filename", ")", ":", "hdrobj", "=", "data", "if", "isinstance", "(", "data", ",", "HDRobject", ")", "else", "HDRobject", "(", "data", ")", "hdrobj", ".", "write", "(", "filename", ")" ]
write ENVI header files Parameters ---------- data: str or dict the file or dictionary to get the info from filename: str the HDR file to write Returns -------
[ "write", "ENVI", "header", "files" ]
train
https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/envi.py#L12-L28
johntruckenbrodt/spatialist
spatialist/envi.py
HDRobject.__hdr2dict
def __hdr2dict(self): """ read a HDR file into a dictionary http://gis.stackexchange.com/questions/48618/how-to-read-write-envi-metadata-using-gdal Returns ------- dict the hdr file metadata attributes """ with open(self.filename, 'r') as infil...
python
def __hdr2dict(self): """ read a HDR file into a dictionary http://gis.stackexchange.com/questions/48618/how-to-read-write-envi-metadata-using-gdal Returns ------- dict the hdr file metadata attributes """ with open(self.filename, 'r') as infil...
[ "def", "__hdr2dict", "(", "self", ")", ":", "with", "open", "(", "self", ".", "filename", ",", "'r'", ")", "as", "infile", ":", "lines", "=", "infile", ".", "readlines", "(", ")", "i", "=", "0", "out", "=", "dict", "(", ")", "while", "i", "<", ...
read a HDR file into a dictionary http://gis.stackexchange.com/questions/48618/how-to-read-write-envi-metadata-using-gdal Returns ------- dict the hdr file metadata attributes
[ "read", "a", "HDR", "file", "into", "a", "dictionary", "http", ":", "//", "gis", ".", "stackexchange", ".", "com", "/", "questions", "/", "48618", "/", "how", "-", "to", "-", "read", "-", "write", "-", "envi", "-", "metadata", "-", "using", "-", "g...
train
https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/envi.py#L98-L126
johntruckenbrodt/spatialist
spatialist/envi.py
HDRobject.write
def write(self, filename='same'): """ write object to an ENVI header file """ if filename == 'same': filename = self.filename if not filename.endswith('.hdr'): filename += '.hdr' with open(filename, 'w') as out: out.write(self.__str__()...
python
def write(self, filename='same'): """ write object to an ENVI header file """ if filename == 'same': filename = self.filename if not filename.endswith('.hdr'): filename += '.hdr' with open(filename, 'w') as out: out.write(self.__str__()...
[ "def", "write", "(", "self", ",", "filename", "=", "'same'", ")", ":", "if", "filename", "==", "'same'", ":", "filename", "=", "self", ".", "filename", "if", "not", "filename", ".", "endswith", "(", "'.hdr'", ")", ":", "filename", "+=", "'.hdr'", "with...
write object to an ENVI header file
[ "write", "object", "to", "an", "ENVI", "header", "file" ]
train
https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/envi.py#L128-L137
MLAB-project/pymlab
examples/I2CSPI_HBSTEP_CAMPAP.py
axis.MaxSpeed
def MaxSpeed(self, speed): ' Setup of maximum speed ' spi.SPI_write_byte(self.CS, 0x07) # Max Speed setup spi.SPI_write_byte(self.CS, 0x00) spi.SPI_write_byte(self.CS, speed)
python
def MaxSpeed(self, speed): ' Setup of maximum speed ' spi.SPI_write_byte(self.CS, 0x07) # Max Speed setup spi.SPI_write_byte(self.CS, 0x00) spi.SPI_write_byte(self.CS, speed)
[ "def", "MaxSpeed", "(", "self", ",", "speed", ")", ":", "spi", ".", "SPI_write_byte", "(", "self", ".", "CS", ",", "0x07", ")", "# Max Speed setup ", "spi", ".", "SPI_write_byte", "(", "self", ".", "CS", ",", "0x00", ")", "spi", ".", "SPI_write_byte", ...
Setup of maximum speed
[ "Setup", "of", "maximum", "speed" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_HBSTEP_CAMPAP.py#L62-L66
MLAB-project/pymlab
examples/I2CSPI_HBSTEP_CAMPAP.py
axis.GoZero
def GoZero(self, speed): ' Go to Zero position ' self.ReleaseSW() spi.SPI_write_byte(self.CS, 0x82 | (self.Dir & 1)) # Go to Zero spi.SPI_write_byte(self.CS, 0x00) spi.SPI_write_byte(self.CS, speed) while self.IsBusy(): pass time.sleep(0.3) ...
python
def GoZero(self, speed): ' Go to Zero position ' self.ReleaseSW() spi.SPI_write_byte(self.CS, 0x82 | (self.Dir & 1)) # Go to Zero spi.SPI_write_byte(self.CS, 0x00) spi.SPI_write_byte(self.CS, speed) while self.IsBusy(): pass time.sleep(0.3) ...
[ "def", "GoZero", "(", "self", ",", "speed", ")", ":", "self", ".", "ReleaseSW", "(", ")", "spi", ".", "SPI_write_byte", "(", "self", ".", "CS", ",", "0x82", "|", "(", "self", ".", "Dir", "&", "1", ")", ")", "# Go to Zero", "spi", ".", "SPI_write_by...
Go to Zero position
[ "Go", "to", "Zero", "position" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_HBSTEP_CAMPAP.py#L76-L86
MLAB-project/pymlab
examples/I2CSPI_HBSTEP_CAMPAP.py
axis.Move
def Move(self, units): ' Move some distance units from current position ' steps = units * self.SPU # translate units to steps if steps > 0: # look for direction spi.SPI_write_byte(self.CS, 0x40 | (~self.Dir & 1)) else: ...
python
def Move(self, units): ' Move some distance units from current position ' steps = units * self.SPU # translate units to steps if steps > 0: # look for direction spi.SPI_write_byte(self.CS, 0x40 | (~self.Dir & 1)) else: ...
[ "def", "Move", "(", "self", ",", "units", ")", ":", "steps", "=", "units", "*", "self", ".", "SPU", "# translate units to steps ", "if", "steps", ">", "0", ":", "# look for direction", "spi", ".", "SPI_write_byte", "(", "self", ".", "CS", ",", "0x40", "|...
Move some distance units from current position
[ "Move", "some", "distance", "units", "from", "current", "position" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_HBSTEP_CAMPAP.py#L88-L98
MLAB-project/pymlab
examples/I2CSPI_HBSTEP_CAMPAP.py
axis.ReadStatusBit
def ReadStatusBit(self, bit): ' Report given status bit ' spi.SPI_write_byte(self.CS, 0x39) # Read from address 0x19 (STATUS) spi.SPI_write_byte(self.CS, 0x00) data0 = spi.SPI_read_byte() # 1st byte spi.SPI_write_byte(self.CS, 0x00) data1 = spi.SPI_read_byte()...
python
def ReadStatusBit(self, bit): ' Report given status bit ' spi.SPI_write_byte(self.CS, 0x39) # Read from address 0x19 (STATUS) spi.SPI_write_byte(self.CS, 0x00) data0 = spi.SPI_read_byte() # 1st byte spi.SPI_write_byte(self.CS, 0x00) data1 = spi.SPI_read_byte()...
[ "def", "ReadStatusBit", "(", "self", ",", "bit", ")", ":", "spi", ".", "SPI_write_byte", "(", "self", ".", "CS", ",", "0x39", ")", "# Read from address 0x19 (STATUS)", "spi", ".", "SPI_write_byte", "(", "self", ".", "CS", ",", "0x00", ")", "data0", "=", ...
Report given status bit
[ "Report", "given", "status", "bit" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_HBSTEP_CAMPAP.py#L110-L122
MLAB-project/pymlab
src/pymlab/sensors/bus_translators.py
I2CSPI.SPI_write_byte
def SPI_write_byte(self, chip_select, data): 'Writes a data to a SPI device selected by chipselect bit. ' self.bus.write_byte_data(self.address, chip_select, data)
python
def SPI_write_byte(self, chip_select, data): 'Writes a data to a SPI device selected by chipselect bit. ' self.bus.write_byte_data(self.address, chip_select, data)
[ "def", "SPI_write_byte", "(", "self", ",", "chip_select", ",", "data", ")", ":", "self", ".", "bus", ".", "write_byte_data", "(", "self", ".", "address", ",", "chip_select", ",", "data", ")" ]
Writes a data to a SPI device selected by chipselect bit.
[ "Writes", "a", "data", "to", "a", "SPI", "device", "selected", "by", "chipselect", "bit", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/bus_translators.py#L51-L53
MLAB-project/pymlab
src/pymlab/sensors/bus_translators.py
I2CSPI.SPI_write
def SPI_write(self, chip_select, data): 'Writes data to SPI device selected by chipselect bit. ' dat = list(data) dat.insert(0, chip_select) return self.bus.write_i2c_block(self.address, dat);
python
def SPI_write(self, chip_select, data): 'Writes data to SPI device selected by chipselect bit. ' dat = list(data) dat.insert(0, chip_select) return self.bus.write_i2c_block(self.address, dat);
[ "def", "SPI_write", "(", "self", ",", "chip_select", ",", "data", ")", ":", "dat", "=", "list", "(", "data", ")", "dat", ".", "insert", "(", "0", ",", "chip_select", ")", "return", "self", ".", "bus", ".", "write_i2c_block", "(", "self", ".", "addres...
Writes data to SPI device selected by chipselect bit.
[ "Writes", "data", "to", "SPI", "device", "selected", "by", "chipselect", "bit", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/bus_translators.py#L60-L64
MLAB-project/pymlab
src/pymlab/sensors/bus_translators.py
I2CSPI.SPI_config
def SPI_config(self,config): 'Configure SPI interface parameters.' self.bus.write_byte_data(self.address, 0xF0, config) return self.bus.read_byte_data(self.address, 0xF0)
python
def SPI_config(self,config): 'Configure SPI interface parameters.' self.bus.write_byte_data(self.address, 0xF0, config) return self.bus.read_byte_data(self.address, 0xF0)
[ "def", "SPI_config", "(", "self", ",", "config", ")", ":", "self", ".", "bus", ".", "write_byte_data", "(", "self", ".", "address", ",", "0xF0", ",", "config", ")", "return", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", ...
Configure SPI interface parameters.
[ "Configure", "SPI", "interface", "parameters", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/bus_translators.py#L70-L73
MLAB-project/pymlab
src/pymlab/sensors/bus_translators.py
I2CSPI.GPIO_read
def GPIO_read(self): 'Reads logic state on GPIO enabled slave-selects pins.' self.bus.write_byte_data(self.address, 0xF5, 0x0f) status = self.bus.read_byte(self.address) bits_values = dict([('SS0',status & 0x01 == 0x01),('SS1',status & 0x02 == 0x02),('SS2',status & 0x04 == 0x04),('SS3',s...
python
def GPIO_read(self): 'Reads logic state on GPIO enabled slave-selects pins.' self.bus.write_byte_data(self.address, 0xF5, 0x0f) status = self.bus.read_byte(self.address) bits_values = dict([('SS0',status & 0x01 == 0x01),('SS1',status & 0x02 == 0x02),('SS2',status & 0x04 == 0x04),('SS3',s...
[ "def", "GPIO_read", "(", "self", ")", ":", "self", ".", "bus", ".", "write_byte_data", "(", "self", ".", "address", ",", "0xF5", ",", "0x0f", ")", "status", "=", "self", ".", "bus", ".", "read_byte", "(", "self", ".", "address", ")", "bits_values", "...
Reads logic state on GPIO enabled slave-selects pins.
[ "Reads", "logic", "state", "on", "GPIO", "enabled", "slave", "-", "selects", "pins", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/bus_translators.py#L87-L92
MLAB-project/pymlab
src/pymlab/sensors/bus_translators.py
I2CSPI.GPIO_config
def GPIO_config(self, gpio_enable, gpio_config): 'Enable or disable slave-select pins as gpio.' self.bus.write_byte_data(self.address, 0xF6, gpio_enable) self.bus.write_byte_data(self.address, 0xF7, gpio_config) return
python
def GPIO_config(self, gpio_enable, gpio_config): 'Enable or disable slave-select pins as gpio.' self.bus.write_byte_data(self.address, 0xF6, gpio_enable) self.bus.write_byte_data(self.address, 0xF7, gpio_config) return
[ "def", "GPIO_config", "(", "self", ",", "gpio_enable", ",", "gpio_config", ")", ":", "self", ".", "bus", ".", "write_byte_data", "(", "self", ".", "address", ",", "0xF6", ",", "gpio_enable", ")", "self", ".", "bus", ".", "write_byte_data", "(", "self", "...
Enable or disable slave-select pins as gpio.
[ "Enable", "or", "disable", "slave", "-", "select", "pins", "as", "gpio", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/bus_translators.py#L94-L98
MLAB-project/pymlab
src/pymlab/sensors/rps.py
RPS01.get_address
def get_address(self): """ Returns sensors I2C address. """ LOGGER.debug("Reading RPS01A sensor's address.",) return self.bus.read_byte_data(self.address, self.address_reg)
python
def get_address(self): """ Returns sensors I2C address. """ LOGGER.debug("Reading RPS01A sensor's address.",) return self.bus.read_byte_data(self.address, self.address_reg)
[ "def", "get_address", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Reading RPS01A sensor's address.\"", ",", ")", "return", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "self", ".", "address_reg", ")" ]
Returns sensors I2C address.
[ "Returns", "sensors", "I2C", "address", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/rps.py#L34-L39
MLAB-project/pymlab
src/pymlab/sensors/rps.py
RPS01.get_zero_position
def get_zero_position(self): """ Returns programmed zero position in OTP memory. """ LSB = self.bus.read_byte_data(self.address, self.zero_position_MSB) MSB = self.bus.read_byte_data(self.address, self.zero_position_LSB) DATA = (MSB << 6) + LSB return DATA
python
def get_zero_position(self): """ Returns programmed zero position in OTP memory. """ LSB = self.bus.read_byte_data(self.address, self.zero_position_MSB) MSB = self.bus.read_byte_data(self.address, self.zero_position_LSB) DATA = (MSB << 6) + LSB return DATA
[ "def", "get_zero_position", "(", "self", ")", ":", "LSB", "=", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "self", ".", "zero_position_MSB", ")", "MSB", "=", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", ...
Returns programmed zero position in OTP memory.
[ "Returns", "programmed", "zero", "position", "in", "OTP", "memory", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/rps.py#L41-L49
MLAB-project/pymlab
src/pymlab/sensors/rps.py
RPS01.get_agc_value
def get_agc_value(self): """ Returns sensor's Automatic Gain Control actual value. 0 - Represents high magtetic field 0xFF - Represents low magnetic field """ LOGGER.debug("Reading RPS01A sensor's AGC settings",) return self.bus.read_byte_data(self.a...
python
def get_agc_value(self): """ Returns sensor's Automatic Gain Control actual value. 0 - Represents high magtetic field 0xFF - Represents low magnetic field """ LOGGER.debug("Reading RPS01A sensor's AGC settings",) return self.bus.read_byte_data(self.a...
[ "def", "get_agc_value", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Reading RPS01A sensor's AGC settings\"", ",", ")", "return", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "self", ".", "AGC_reg", ")" ]
Returns sensor's Automatic Gain Control actual value. 0 - Represents high magtetic field 0xFF - Represents low magnetic field
[ "Returns", "sensor", "s", "Automatic", "Gain", "Control", "actual", "value", ".", "0", "-", "Represents", "high", "magtetic", "field", "0xFF", "-", "Represents", "low", "magnetic", "field" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/rps.py#L75-L82
MLAB-project/pymlab
src/pymlab/sensors/rps.py
RPS01.get_diagnostics
def get_diagnostics(self): """ Reads diagnostic data from the sensor. OCF (Offset Compensation Finished) - logic high indicates the finished Offset Compensation Algorithm. After power up the flag remains always to logic high. COF (Cordic Overflow) - logic high indicates an out of range ...
python
def get_diagnostics(self): """ Reads diagnostic data from the sensor. OCF (Offset Compensation Finished) - logic high indicates the finished Offset Compensation Algorithm. After power up the flag remains always to logic high. COF (Cordic Overflow) - logic high indicates an out of range ...
[ "def", "get_diagnostics", "(", "self", ")", ":", "status", "=", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "self", ".", "diagnostics_reg", ")", "bits_values", "=", "dict", "(", "[", "(", "'OCF'", ",", "status", "&", "0...
Reads diagnostic data from the sensor. OCF (Offset Compensation Finished) - logic high indicates the finished Offset Compensation Algorithm. After power up the flag remains always to logic high. COF (Cordic Overflow) - logic high indicates an out of range error in the CORDIC part. When this bit is set,...
[ "Reads", "diagnostic", "data", "from", "the", "sensor", ".", "OCF", "(", "Offset", "Compensation", "Finished", ")", "-", "logic", "high", "indicates", "the", "finished", "Offset", "Compensation", "Algorithm", ".", "After", "power", "up", "the", "flag", "remain...
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/rps.py#L84-L101
MLAB-project/pymlab
src/pymlab/sensors/rps.py
RPS01.get_angle
def get_angle(self, verify = False): """ Retuns measured angle in degrees in range 0-360. """ LSB = self.bus.read_byte_data(self.address, self.angle_LSB) MSB = self.bus.read_byte_data(self.address, self.angle_MSB) DATA = (MSB << 6) + LSB if not verify: ...
python
def get_angle(self, verify = False): """ Retuns measured angle in degrees in range 0-360. """ LSB = self.bus.read_byte_data(self.address, self.angle_LSB) MSB = self.bus.read_byte_data(self.address, self.angle_MSB) DATA = (MSB << 6) + LSB if not verify: ...
[ "def", "get_angle", "(", "self", ",", "verify", "=", "False", ")", ":", "LSB", "=", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "self", ".", "angle_LSB", ")", "MSB", "=", "self", ".", "bus", ".", "read_byte_data", "("...
Retuns measured angle in degrees in range 0-360.
[ "Retuns", "measured", "angle", "in", "degrees", "in", "range", "0", "-", "360", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/rps.py#L110-L124
vladsaveliev/TargQC
scripts/annotate_bed.py
main
def main(input_bed, output_file, output_features=False, genome=None, only_canonical=False, short=False, extended=False, high_confidence=False, ambiguities_method=False, coding_only=False, collapse_exons=False, work_dir=False, is_debug=False): """ Annotating BED file based on reference features ann...
python
def main(input_bed, output_file, output_features=False, genome=None, only_canonical=False, short=False, extended=False, high_confidence=False, ambiguities_method=False, coding_only=False, collapse_exons=False, work_dir=False, is_debug=False): """ Annotating BED file based on reference features ann...
[ "def", "main", "(", "input_bed", ",", "output_file", ",", "output_features", "=", "False", ",", "genome", "=", "None", ",", "only_canonical", "=", "False", ",", "short", "=", "False", ",", "extended", "=", "False", ",", "high_confidence", "=", "False", ","...
Annotating BED file based on reference features annotations.
[ "Annotating", "BED", "file", "based", "on", "reference", "features", "annotations", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/scripts/annotate_bed.py#L33-L79
MLAB-project/pymlab
src/pymlab/sensors/lioncell.py
LIONCELL.StateOfCharge
def StateOfCharge(self): """ % of Full Charge """ return (self.bus.read_byte_data(self.address, 0x02) + self.bus.read_byte_data(self.address, 0x03) * 256)
python
def StateOfCharge(self): """ % of Full Charge """ return (self.bus.read_byte_data(self.address, 0x02) + self.bus.read_byte_data(self.address, 0x03) * 256)
[ "def", "StateOfCharge", "(", "self", ")", ":", "return", "(", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "0x02", ")", "+", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "0x03", ")", "*"...
% of Full Charge
[ "%", "of", "Full", "Charge" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/lioncell.py#L75-L77
MLAB-project/pymlab
src/pymlab/sensors/lioncell.py
LIONCELL.Chemistry
def Chemistry(self): ''' Get cells chemistry ''' length = self.bus.read_byte_data(self.address, 0x79) chem = [] for n in range(length): chem.append(self.bus.read_byte_data(self.address, 0x7A + n)) return chem
python
def Chemistry(self): ''' Get cells chemistry ''' length = self.bus.read_byte_data(self.address, 0x79) chem = [] for n in range(length): chem.append(self.bus.read_byte_data(self.address, 0x7A + n)) return chem
[ "def", "Chemistry", "(", "self", ")", ":", "length", "=", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "0x79", ")", "chem", "=", "[", "]", "for", "n", "in", "range", "(", "length", ")", ":", "chem", ".", "append", ...
Get cells chemistry
[ "Get", "cells", "chemistry" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/lioncell.py#L96-L102
RI-imaging/ODTbrain
odtbrain/_alg2d_int.py
integrate_2d
def integrate_2d(uSin, angles, res, nm, lD=0, coords=None, count=None, max_count=None, verbose=0): r"""(slow) 2D reconstruction with the Fourier diffraction theorem Two-dimensional diffraction tomography reconstruction algorithm for scattering of a plane wave :math:`u_0(\mathbf{r}) = u...
python
def integrate_2d(uSin, angles, res, nm, lD=0, coords=None, count=None, max_count=None, verbose=0): r"""(slow) 2D reconstruction with the Fourier diffraction theorem Two-dimensional diffraction tomography reconstruction algorithm for scattering of a plane wave :math:`u_0(\mathbf{r}) = u...
[ "def", "integrate_2d", "(", "uSin", ",", "angles", ",", "res", ",", "nm", ",", "lD", "=", "0", ",", "coords", "=", "None", ",", "count", "=", "None", ",", "max_count", "=", "None", ",", "verbose", "=", "0", ")", ":", "if", "coords", "is", "None",...
r"""(slow) 2D reconstruction with the Fourier diffraction theorem Two-dimensional diffraction tomography reconstruction algorithm for scattering of a plane wave :math:`u_0(\mathbf{r}) = u_0(x,z)` by a dielectric object with refractive index :math:`n(x,z)`. This function implements the solution...
[ "r", "(", "slow", ")", "2D", "reconstruction", "with", "the", "Fourier", "diffraction", "theorem" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg2d_int.py#L5-L271
RI-imaging/ODTbrain
odtbrain/_alg2d_bpp.py
backpropagate_2d
def backpropagate_2d(uSin, angles, res, nm, lD=0, coords=None, weight_angles=True, onlyreal=False, padding=True, padval=0, count=None, max_count=None, verbose=0): r"""2D backpropagation with the Fourier diffraction theorem Two-dimensional diffracti...
python
def backpropagate_2d(uSin, angles, res, nm, lD=0, coords=None, weight_angles=True, onlyreal=False, padding=True, padval=0, count=None, max_count=None, verbose=0): r"""2D backpropagation with the Fourier diffraction theorem Two-dimensional diffracti...
[ "def", "backpropagate_2d", "(", "uSin", ",", "angles", ",", "res", ",", "nm", ",", "lD", "=", "0", ",", "coords", "=", "None", ",", "weight_angles", "=", "True", ",", "onlyreal", "=", "False", ",", "padding", "=", "True", ",", "padval", "=", "0", "...
r"""2D backpropagation with the Fourier diffraction theorem Two-dimensional diffraction tomography reconstruction algorithm for scattering of a plane wave :math:`u_0(\mathbf{r}) = u_0(x,z)` by a dielectric object with refractive index :math:`n(x,z)`. This method implements the 2D backpropagati...
[ "r", "2D", "backpropagation", "with", "the", "Fourier", "diffraction", "theorem" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg2d_bpp.py#L8-L326
svenkreiss/databench
logo/create.py
color
def color(x, y): """triangles. Colors: - http://paletton.com/#uid=70l150klllletuehUpNoMgTsdcs shade 2 """ if (x-4) > (y-4) and -(y-4) <= (x-4): # right return "#CDB95B" elif (x-4) > (y-4) and -(y-4) > (x-4): # top return "#CD845B" elif (x-4) <= (y-4) and -(y...
python
def color(x, y): """triangles. Colors: - http://paletton.com/#uid=70l150klllletuehUpNoMgTsdcs shade 2 """ if (x-4) > (y-4) and -(y-4) <= (x-4): # right return "#CDB95B" elif (x-4) > (y-4) and -(y-4) > (x-4): # top return "#CD845B" elif (x-4) <= (y-4) and -(y...
[ "def", "color", "(", "x", ",", "y", ")", ":", "if", "(", "x", "-", "4", ")", ">", "(", "y", "-", "4", ")", "and", "-", "(", "y", "-", "4", ")", "<=", "(", "x", "-", "4", ")", ":", "# right", "return", "\"#CDB95B\"", "elif", "(", "x", "-...
triangles. Colors: - http://paletton.com/#uid=70l150klllletuehUpNoMgTsdcs shade 2
[ "triangles", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/logo/create.py#L19-L40
MLAB-project/pymlab
examples/I2CSPI_BRIDGEADC01.py
BRIDGEADC01.single_read
def single_read(self, register): ''' Reads data from desired register only once. ''' comm_reg = (0b00010 << 3) + register if register == self.AD7730_STATUS_REG: bytes_num = 1 elif register == self.AD7730_DATA_REG: bytes_num = 3 e...
python
def single_read(self, register): ''' Reads data from desired register only once. ''' comm_reg = (0b00010 << 3) + register if register == self.AD7730_STATUS_REG: bytes_num = 1 elif register == self.AD7730_DATA_REG: bytes_num = 3 e...
[ "def", "single_read", "(", "self", ",", "register", ")", ":", "comm_reg", "=", "(", "0b00010", "<<", "3", ")", "+", "register", "if", "register", "==", "self", ".", "AD7730_STATUS_REG", ":", "bytes_num", "=", "1", "elif", "register", "==", "self", ".", ...
Reads data from desired register only once.
[ "Reads", "data", "from", "desired", "register", "only", "once", "." ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_BRIDGEADC01.py#L160-L187
MLAB-project/pymlab
examples/I2CSPI_BRIDGEADC01.py
BRIDGEADC01.getStatus
def getStatus(self): """ RDY - Ready Bit. This bit provides the status of the RDY flag from the part. The status and function of this bit is the same as the RDY output pin. A number of events set the RDY bit high as indicated in Table XVIII in datasheet STDY - Steady Bit. This bit is updated w...
python
def getStatus(self): """ RDY - Ready Bit. This bit provides the status of the RDY flag from the part. The status and function of this bit is the same as the RDY output pin. A number of events set the RDY bit high as indicated in Table XVIII in datasheet STDY - Steady Bit. This bit is updated w...
[ "def", "getStatus", "(", "self", ")", ":", "status", "=", "self", ".", "single_read", "(", "self", ".", "AD7730_STATUS_REG", ")", "bits_values", "=", "dict", "(", "[", "(", "'NOREF'", ",", "status", "[", "0", "]", "&", "0x10", "==", "0x10", ")", ",",...
RDY - Ready Bit. This bit provides the status of the RDY flag from the part. The status and function of this bit is the same as the RDY output pin. A number of events set the RDY bit high as indicated in Table XVIII in datasheet STDY - Steady Bit. This bit is updated when the filter writes a result to the Data...
[ "RDY", "-", "Ready", "Bit", ".", "This", "bit", "provides", "the", "status", "of", "the", "RDY", "flag", "from", "the", "part", ".", "The", "status", "and", "function", "of", "this", "bit", "is", "the", "same", "as", "the", "RDY", "output", "pin", "....
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_BRIDGEADC01.py#L189-L219
MLAB-project/pymlab
examples/I2CSPI_BRIDGEADC01.py
BRIDGEADC01.setMode
def setMode(self ,mode ,polarity ,den ,iovalue ,data_length ,reference ,input_range ,clock_enable ,burn_out ,c...
python
def setMode(self ,mode ,polarity ,den ,iovalue ,data_length ,reference ,input_range ,clock_enable ,burn_out ,c...
[ "def", "setMode", "(", "self", ",", "mode", ",", "polarity", ",", "den", ",", "iovalue", ",", "data_length", ",", "reference", ",", "input_range", ",", "clock_enable", ",", "burn_out", ",", "channel", ")", ":", "mode_MSB", "=", "(", "mode", "<<", "5", ...
def setMode(self ,mode = self.AD7730_IDLE_MODE ,polarity = self.AD7730_UNIPOLAR_MODE ,den = self.AD7730_IODISABLE_MODE ,iovalue = 0b00 ,data_lenght = self.AD7730_24bitDATA_MODE ,reference = self.AD77...
[ "def", "setMode", "(", "self", "mode", "=", "self", ".", "AD7730_IDLE_MODE", "polarity", "=", "self", ".", "AD7730_UNIPOLAR_MODE", "den", "=", "self", ".", "AD7730_IODISABLE_MODE", "iovalue", "=", "0b00", "data_lenght", "=", "self", ".", "AD7730_24bitDATA_MODE", ...
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_BRIDGEADC01.py#L232-L260
vladsaveliev/TargQC
targqc/fastq.py
downsample
def downsample(work_dir, sample_name, fastq_left_fpath, fastq_right_fpath, downsample_to, num_pairs=None): """ get N random headers from a fastq file without reading the whole thing into memory modified from: http://www.biostars.org/p/6544/ """ sample_name = sample_name or splitext(''.join(lc if lc ...
python
def downsample(work_dir, sample_name, fastq_left_fpath, fastq_right_fpath, downsample_to, num_pairs=None): """ get N random headers from a fastq file without reading the whole thing into memory modified from: http://www.biostars.org/p/6544/ """ sample_name = sample_name or splitext(''.join(lc if lc ...
[ "def", "downsample", "(", "work_dir", ",", "sample_name", ",", "fastq_left_fpath", ",", "fastq_right_fpath", ",", "downsample_to", ",", "num_pairs", "=", "None", ")", ":", "sample_name", "=", "sample_name", "or", "splitext", "(", "''", ".", "join", "(", "lc", ...
get N random headers from a fastq file without reading the whole thing into memory modified from: http://www.biostars.org/p/6544/
[ "get", "N", "random", "headers", "from", "a", "fastq", "file", "without", "reading", "the", "whole", "thing", "into", "memory", "modified", "from", ":", "http", ":", "//", "www", ".", "biostars", ".", "org", "/", "p", "/", "6544", "/" ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/fastq.py#L112-L183
MLAB-project/pymlab
src/pymlab/sensors/sht.py
SHT25.get_hum
def get_hum(self, raw = False): """ The physical value RH given above corresponds to the relative humidity above liquid water according to World Meteorological Organization (WMO) """ self.bus.write_byte(self.address, self.TRIG_RH_noHOLD); # start humidity measurement ...
python
def get_hum(self, raw = False): """ The physical value RH given above corresponds to the relative humidity above liquid water according to World Meteorological Organization (WMO) """ self.bus.write_byte(self.address, self.TRIG_RH_noHOLD); # start humidity measurement ...
[ "def", "get_hum", "(", "self", ",", "raw", "=", "False", ")", ":", "self", ".", "bus", ".", "write_byte", "(", "self", ".", "address", ",", "self", ".", "TRIG_RH_noHOLD", ")", "# start humidity measurement", "time", ".", "sleep", "(", "0.1", ")", "data",...
The physical value RH given above corresponds to the relative humidity above liquid water according to World Meteorological Organization (WMO)
[ "The", "physical", "value", "RH", "given", "above", "corresponds", "to", "the", "relative", "humidity", "above", "liquid", "water", "according", "to", "World", "Meteorological", "Organization", "(", "WMO", ")" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/sht.py#L56-L81
MLAB-project/pymlab
src/pymlab/sensors/sht.py
SHT31._calculate_checksum
def _calculate_checksum(value): """4.12 Checksum Calculation from an unsigned short input""" # CRC polynomial = 0x131 # //P(x)=x^8+x^5+x^4+1 = 100110001 crc = 0xFF # calculates 8-Bit checksum with given polynomial for byteCtr in [ord(x) for x in struct.pack(">H", value)...
python
def _calculate_checksum(value): """4.12 Checksum Calculation from an unsigned short input""" # CRC polynomial = 0x131 # //P(x)=x^8+x^5+x^4+1 = 100110001 crc = 0xFF # calculates 8-Bit checksum with given polynomial for byteCtr in [ord(x) for x in struct.pack(">H", value)...
[ "def", "_calculate_checksum", "(", "value", ")", ":", "# CRC", "polynomial", "=", "0x131", "# //P(x)=x^8+x^5+x^4+1 = 100110001", "crc", "=", "0xFF", "# calculates 8-Bit checksum with given polynomial", "for", "byteCtr", "in", "[", "ord", "(", "x", ")", "for", "x", "...
4.12 Checksum Calculation from an unsigned short input
[ "4", ".", "12", "Checksum", "Calculation", "from", "an", "unsigned", "short", "input" ]
train
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/sht.py#L149-L163
svenkreiss/databench
databench/analyses_packaged/dummypi_py/analysis.py
Dummypi_Py.run
def run(self): """Run when button is pressed.""" inside = 0 for draws in range(1, self.data['samples']): # generate points and check whether they are inside the unit circle r1, r2 = (random(), random()) if r1 ** 2 + r2 ** 2 < 1.0: inside += 1 ...
python
def run(self): """Run when button is pressed.""" inside = 0 for draws in range(1, self.data['samples']): # generate points and check whether they are inside the unit circle r1, r2 = (random(), random()) if r1 ** 2 + r2 ** 2 < 1.0: inside += 1 ...
[ "def", "run", "(", "self", ")", ":", "inside", "=", "0", "for", "draws", "in", "range", "(", "1", ",", "self", ".", "data", "[", "'samples'", "]", ")", ":", "# generate points and check whether they are inside the unit circle", "r1", ",", "r2", "=", "(", "...
Run when button is pressed.
[ "Run", "when", "button", "is", "pressed", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/analyses_packaged/dummypi_py/analysis.py#L21-L47
svenkreiss/databench
databench/analysis.py
on
def on(f): """Decorator for action handlers. The action name is inferred from the function name. This also decorates the method with `tornado.gen.coroutine` so that `~tornado.concurrent.Future` can be yielded. """ action = f.__name__ f.action = action @wrapt.decorator @tornado.gen...
python
def on(f): """Decorator for action handlers. The action name is inferred from the function name. This also decorates the method with `tornado.gen.coroutine` so that `~tornado.concurrent.Future` can be yielded. """ action = f.__name__ f.action = action @wrapt.decorator @tornado.gen...
[ "def", "on", "(", "f", ")", ":", "action", "=", "f", ".", "__name__", "f", ".", "action", "=", "action", "@", "wrapt", ".", "decorator", "@", "tornado", ".", "gen", ".", "coroutine", "def", "_execute", "(", "wrapped", ",", "instance", ",", "args", ...
Decorator for action handlers. The action name is inferred from the function name. This also decorates the method with `tornado.gen.coroutine` so that `~tornado.concurrent.Future` can be yielded.
[ "Decorator", "for", "action", "handlers", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/analysis.py#L44-L60
svenkreiss/databench
databench/analysis.py
on_action
def on_action(action): """Decorator for action handlers. :param str action: explicit action name This also decorates the method with `tornado.gen.coroutine` so that `~tornado.concurrent.Future` can be yielded. """ @wrapt.decorator @tornado.gen.coroutine def _execute(wrapped, instance, ...
python
def on_action(action): """Decorator for action handlers. :param str action: explicit action name This also decorates the method with `tornado.gen.coroutine` so that `~tornado.concurrent.Future` can be yielded. """ @wrapt.decorator @tornado.gen.coroutine def _execute(wrapped, instance, ...
[ "def", "on_action", "(", "action", ")", ":", "@", "wrapt", ".", "decorator", "@", "tornado", ".", "gen", ".", "coroutine", "def", "_execute", "(", "wrapped", ",", "instance", ",", "args", ",", "kwargs", ")", ":", "return", "wrapped", "(", "*", "args", ...
Decorator for action handlers. :param str action: explicit action name This also decorates the method with `tornado.gen.coroutine` so that `~tornado.concurrent.Future` can be yielded.
[ "Decorator", "for", "action", "handlers", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/analysis.py#L63-L77
svenkreiss/databench
databench/analysis.py
Analysis.init_datastores
def init_datastores(self): """Initialize datastores for this analysis instance. This creates instances of :class:`.Datastore` at ``data`` and ``class_data`` with the datastore domains being the current id and the class name of this analysis respectively. Overwrite this method t...
python
def init_datastores(self): """Initialize datastores for this analysis instance. This creates instances of :class:`.Datastore` at ``data`` and ``class_data`` with the datastore domains being the current id and the class name of this analysis respectively. Overwrite this method t...
[ "def", "init_datastores", "(", "self", ")", ":", "self", ".", "data", "=", "Datastore", "(", "self", ".", "id_", ")", "self", ".", "data", ".", "subscribe", "(", "lambda", "data", ":", "self", ".", "emit", "(", "'data'", ",", "data", ")", ")", "sel...
Initialize datastores for this analysis instance. This creates instances of :class:`.Datastore` at ``data`` and ``class_data`` with the datastore domains being the current id and the class name of this analysis respectively. Overwrite this method to use other datastore backends.
[ "Initialize", "datastores", "for", "this", "analysis", "instance", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/analysis.py#L166-L178
svenkreiss/databench
databench/analysis.py
Analysis.emit
def emit(self, signal, message='__nomessagetoken__'): """Emit a signal to the frontend. :param str signal: name of the signal :param message: message to send :returns: return value from frontend emit function :rtype: tornado.concurrent.Future """ # call pre-emit ...
python
def emit(self, signal, message='__nomessagetoken__'): """Emit a signal to the frontend. :param str signal: name of the signal :param message: message to send :returns: return value from frontend emit function :rtype: tornado.concurrent.Future """ # call pre-emit ...
[ "def", "emit", "(", "self", ",", "signal", ",", "message", "=", "'__nomessagetoken__'", ")", ":", "# call pre-emit hooks", "if", "signal", "==", "'log'", ":", "self", ".", "log_backend", ".", "info", "(", "message", ")", "elif", "signal", "==", "'warn'", "...
Emit a signal to the frontend. :param str signal: name of the signal :param message: message to send :returns: return value from frontend emit function :rtype: tornado.concurrent.Future
[ "Emit", "a", "signal", "to", "the", "frontend", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/analysis.py#L189-L205
svenkreiss/databench
databench/datastore_legacy.py
DatastoreList.set
def set(self, i, value): """Set value at position i and return a Future. :rtype: tornado.concurrent.Future """ value_encoded = encode(value, self.get_change_trigger(i)) if i in self.data and self.data[i] == value_encoded: return self self.data[i] = value_en...
python
def set(self, i, value): """Set value at position i and return a Future. :rtype: tornado.concurrent.Future """ value_encoded = encode(value, self.get_change_trigger(i)) if i in self.data and self.data[i] == value_encoded: return self self.data[i] = value_en...
[ "def", "set", "(", "self", ",", "i", ",", "value", ")", ":", "value_encoded", "=", "encode", "(", "value", ",", "self", ".", "get_change_trigger", "(", "i", ")", ")", "if", "i", "in", "self", ".", "data", "and", "self", ".", "data", "[", "i", "]"...
Set value at position i and return a Future. :rtype: tornado.concurrent.Future
[ "Set", "value", "at", "position", "i", "and", "return", "a", "Future", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/datastore_legacy.py#L60-L71
svenkreiss/databench
databench/datastore_legacy.py
DatastoreDict.set
def set(self, key, value): """Set a value at key and return a Future. :rtype: tornado.concurrent.Future """ value_encoded = encode(value, self.get_change_trigger(key)) if key in self.data and self.data[key] == value_encoded: return self self.data[key] = val...
python
def set(self, key, value): """Set a value at key and return a Future. :rtype: tornado.concurrent.Future """ value_encoded = encode(value, self.get_change_trigger(key)) if key in self.data and self.data[key] == value_encoded: return self self.data[key] = val...
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "value_encoded", "=", "encode", "(", "value", ",", "self", ".", "get_change_trigger", "(", "key", ")", ")", "if", "key", "in", "self", ".", "data", "and", "self", ".", "data", "[", "key...
Set a value at key and return a Future. :rtype: tornado.concurrent.Future
[ "Set", "a", "value", "at", "key", "and", "return", "a", "Future", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/datastore_legacy.py#L136-L147
svenkreiss/databench
databench/datastore_legacy.py
DatastoreDict.update
def update(self, new_data): """Update.""" for k, v in new_data.items(): self[k] = v return self
python
def update(self, new_data): """Update.""" for k, v in new_data.items(): self[k] = v return self
[ "def", "update", "(", "self", ",", "new_data", ")", ":", "for", "k", ",", "v", "in", "new_data", ".", "items", "(", ")", ":", "self", "[", "k", "]", "=", "v", "return", "self" ]
Update.
[ "Update", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/datastore_legacy.py#L195-L200
svenkreiss/databench
databench/datastore_legacy.py
DatastoreLegacy.trigger_all_change_callbacks
def trigger_all_change_callbacks(self): """Trigger all callbacks that were set with on_change().""" return [ ret for key in DatastoreLegacy.store[self.domain].keys() for ret in self.trigger_change_callbacks(key) ]
python
def trigger_all_change_callbacks(self): """Trigger all callbacks that were set with on_change().""" return [ ret for key in DatastoreLegacy.store[self.domain].keys() for ret in self.trigger_change_callbacks(key) ]
[ "def", "trigger_all_change_callbacks", "(", "self", ")", ":", "return", "[", "ret", "for", "key", "in", "DatastoreLegacy", ".", "store", "[", "self", ".", "domain", "]", ".", "keys", "(", ")", "for", "ret", "in", "self", ".", "trigger_change_callbacks", "(...
Trigger all callbacks that were set with on_change().
[ "Trigger", "all", "callbacks", "that", "were", "set", "with", "on_change", "()", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/datastore_legacy.py#L257-L263
svenkreiss/databench
databench/datastore_legacy.py
DatastoreLegacy.set
def set(self, key, value): """Set value at key and return a Future :rtype: tornado.concurrent.Future """ return DatastoreLegacy.store[self.domain].set(key, value)
python
def set(self, key, value): """Set value at key and return a Future :rtype: tornado.concurrent.Future """ return DatastoreLegacy.store[self.domain].set(key, value)
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "return", "DatastoreLegacy", ".", "store", "[", "self", ".", "domain", "]", ".", "set", "(", "key", ",", "value", ")" ]
Set value at key and return a Future :rtype: tornado.concurrent.Future
[ "Set", "value", "at", "key", "and", "return", "a", "Future" ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/datastore_legacy.py#L265-L270
svenkreiss/databench
databench/datastore_legacy.py
DatastoreLegacy.init
def init(self, key_value_pairs): """Initialize datastore. Only sets values for keys that are not in the datastore already. :param dict key_value_pairs: A set of key value pairs to use to initialize the datastore. """ for k, v in key_value_pairs.items(): ...
python
def init(self, key_value_pairs): """Initialize datastore. Only sets values for keys that are not in the datastore already. :param dict key_value_pairs: A set of key value pairs to use to initialize the datastore. """ for k, v in key_value_pairs.items(): ...
[ "def", "init", "(", "self", ",", "key_value_pairs", ")", ":", "for", "k", ",", "v", "in", "key_value_pairs", ".", "items", "(", ")", ":", "if", "k", "not", "in", "DatastoreLegacy", ".", "store", "[", "self", ".", "domain", "]", ":", "DatastoreLegacy", ...
Initialize datastore. Only sets values for keys that are not in the datastore already. :param dict key_value_pairs: A set of key value pairs to use to initialize the datastore.
[ "Initialize", "datastore", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/datastore_legacy.py#L302-L312
svenkreiss/databench
databench/datastore_legacy.py
DatastoreLegacy.close
def close(self): """Close and delete instance.""" # remove callbacks DatastoreLegacy.datastores[self.domain].remove(self) # delete data after the last instance is gone if self.release_storage and \ not DatastoreLegacy.datastores[self.domain]: del Datastor...
python
def close(self): """Close and delete instance.""" # remove callbacks DatastoreLegacy.datastores[self.domain].remove(self) # delete data after the last instance is gone if self.release_storage and \ not DatastoreLegacy.datastores[self.domain]: del Datastor...
[ "def", "close", "(", "self", ")", ":", "# remove callbacks", "DatastoreLegacy", ".", "datastores", "[", "self", ".", "domain", "]", ".", "remove", "(", "self", ")", "# delete data after the last instance is gone", "if", "self", ".", "release_storage", "and", "not"...
Close and delete instance.
[ "Close", "and", "delete", "instance", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/datastore_legacy.py#L314-L325
vladsaveliev/TargQC
targqc/utilz/jsontemplate/datadict.py
AddIndex
def AddIndex(node, index=None): """ Recursively add the current index (with respect to a repeated section) in all data dictionaries. """ if isinstance(node, list): for i, item in enumerate(node): AddIndex(item, index=i) elif isinstance(node, dict): if index is not None: node['index'] = i...
python
def AddIndex(node, index=None): """ Recursively add the current index (with respect to a repeated section) in all data dictionaries. """ if isinstance(node, list): for i, item in enumerate(node): AddIndex(item, index=i) elif isinstance(node, dict): if index is not None: node['index'] = i...
[ "def", "AddIndex", "(", "node", ",", "index", "=", "None", ")", ":", "if", "isinstance", "(", "node", ",", "list", ")", ":", "for", "i", ",", "item", "in", "enumerate", "(", "node", ")", ":", "AddIndex", "(", "item", ",", "index", "=", "i", ")", ...
Recursively add the current index (with respect to a repeated section) in all data dictionaries.
[ "Recursively", "add", "the", "current", "index", "(", "with", "respect", "to", "a", "repeated", "section", ")", "in", "all", "data", "dictionaries", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/datadict.py#L15-L27
python-astrodynamics/spacetrack
shovel/docs.py
watch
def watch(): """Renerate documentation when it changes.""" # Start with a clean build sphinx_build['-b', 'html', '-E', 'docs', 'docs/_build/html'] & FG handler = ShellCommandTrick( shell_command='sphinx-build -b html docs docs/_build/html', patterns=['*.rst', '*.py'], ignore_pa...
python
def watch(): """Renerate documentation when it changes.""" # Start with a clean build sphinx_build['-b', 'html', '-E', 'docs', 'docs/_build/html'] & FG handler = ShellCommandTrick( shell_command='sphinx-build -b html docs docs/_build/html', patterns=['*.rst', '*.py'], ignore_pa...
[ "def", "watch", "(", ")", ":", "# Start with a clean build", "sphinx_build", "[", "'-b'", ",", "'html'", ",", "'-E'", ",", "'docs'", ",", "'docs/_build/html'", "]", "&", "FG", "handler", "=", "ShellCommandTrick", "(", "shell_command", "=", "'sphinx-build -b html d...
Renerate documentation when it changes.
[ "Renerate", "documentation", "when", "it", "changes", "." ]
train
https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/shovel/docs.py#L18-L31
python-astrodynamics/spacetrack
shovel/docs.py
gen
def gen(skipdirhtml=False): """Generate html and dirhtml output.""" docs_changelog = 'docs/changelog.rst' check_git_unchanged(docs_changelog) pandoc('--from=markdown', '--to=rst', '--output=' + docs_changelog, 'CHANGELOG.md') if not skipdirhtml: sphinx_build['-b', 'dirhtml', '-W', '-E', 'doc...
python
def gen(skipdirhtml=False): """Generate html and dirhtml output.""" docs_changelog = 'docs/changelog.rst' check_git_unchanged(docs_changelog) pandoc('--from=markdown', '--to=rst', '--output=' + docs_changelog, 'CHANGELOG.md') if not skipdirhtml: sphinx_build['-b', 'dirhtml', '-W', '-E', 'doc...
[ "def", "gen", "(", "skipdirhtml", "=", "False", ")", ":", "docs_changelog", "=", "'docs/changelog.rst'", "check_git_unchanged", "(", "docs_changelog", ")", "pandoc", "(", "'--from=markdown'", ",", "'--to=rst'", ",", "'--output='", "+", "docs_changelog", ",", "'CHANG...
Generate html and dirhtml output.
[ "Generate", "html", "and", "dirhtml", "output", "." ]
train
https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/shovel/docs.py#L35-L42
johntruckenbrodt/spatialist
spatialist/explorer.py
RasterViewer.__reset_crosshair
def __reset_crosshair(self): """ redraw the cross-hair on the horizontal slice plot Parameters ---------- x: int the x image coordinate y: int the y image coordinate Returns ------- """ self.lhor.set_ydata(self.y_c...
python
def __reset_crosshair(self): """ redraw the cross-hair on the horizontal slice plot Parameters ---------- x: int the x image coordinate y: int the y image coordinate Returns ------- """ self.lhor.set_ydata(self.y_c...
[ "def", "__reset_crosshair", "(", "self", ")", ":", "self", ".", "lhor", ".", "set_ydata", "(", "self", ".", "y_coord", ")", "self", ".", "lver", ".", "set_xdata", "(", "self", ".", "x_coord", ")" ]
redraw the cross-hair on the horizontal slice plot Parameters ---------- x: int the x image coordinate y: int the y image coordinate Returns -------
[ "redraw", "the", "cross", "-", "hair", "on", "the", "horizontal", "slice", "plot" ]
train
https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/explorer.py#L243-L258
johntruckenbrodt/spatialist
spatialist/explorer.py
RasterViewer.__init_vertical_plot
def __init_vertical_plot(self): """ set up the vertical profile plot Returns ------- """ # clear the plot if lines have already been drawn on it if len(self.ax2.lines) > 0: self.ax2.cla() # set up the vertical profile plot self.ax2.set...
python
def __init_vertical_plot(self): """ set up the vertical profile plot Returns ------- """ # clear the plot if lines have already been drawn on it if len(self.ax2.lines) > 0: self.ax2.cla() # set up the vertical profile plot self.ax2.set...
[ "def", "__init_vertical_plot", "(", "self", ")", ":", "# clear the plot if lines have already been drawn on it", "if", "len", "(", "self", ".", "ax2", ".", "lines", ")", ">", "0", ":", "self", ".", "ax2", ".", "cla", "(", ")", "# set up the vertical profile plot",...
set up the vertical profile plot Returns -------
[ "set", "up", "the", "vertical", "profile", "plot" ]
train
https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/explorer.py#L260-L276
johntruckenbrodt/spatialist
spatialist/explorer.py
RasterViewer.__onclick
def __onclick(self, event): """ respond to mouse clicks in the plot. This function responds to clicks on the first (horizontal slice) plot and updates the vertical profile and slice plots Parameters ---------- event: matplotlib.backend_bases.MouseEvent ...
python
def __onclick(self, event): """ respond to mouse clicks in the plot. This function responds to clicks on the first (horizontal slice) plot and updates the vertical profile and slice plots Parameters ---------- event: matplotlib.backend_bases.MouseEvent ...
[ "def", "__onclick", "(", "self", ",", "event", ")", ":", "# only do something if the first plot has been clicked on", "if", "event", ".", "inaxes", "==", "self", ".", "ax1", ":", "# retrieve the click coordinates", "self", ".", "x_coord", "=", "event", ".", "xdata",...
respond to mouse clicks in the plot. This function responds to clicks on the first (horizontal slice) plot and updates the vertical profile and slice plots Parameters ---------- event: matplotlib.backend_bases.MouseEvent the click event object containing image coordi...
[ "respond", "to", "mouse", "clicks", "in", "the", "plot", ".", "This", "function", "responds", "to", "clicks", "on", "the", "first", "(", "horizontal", "slice", ")", "plot", "and", "updates", "the", "vertical", "profile", "and", "slice", "plots" ]
train
https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/explorer.py#L278-L310
vladsaveliev/TargQC
targqc/utilz/jsontemplate/formatters.py
LookupChain
def LookupChain(lookup_func_list): """Returns a *function* suitable for passing as the more_formatters argument to Template. NOTE: In Java, this would be implemented using the 'Composite' pattern. A *list* of formatter lookup function behaves the same as a *single* formatter lookup funcion. Note the dist...
python
def LookupChain(lookup_func_list): """Returns a *function* suitable for passing as the more_formatters argument to Template. NOTE: In Java, this would be implemented using the 'Composite' pattern. A *list* of formatter lookup function behaves the same as a *single* formatter lookup funcion. Note the dist...
[ "def", "LookupChain", "(", "lookup_func_list", ")", ":", "def", "MoreFormatters", "(", "formatter_name", ")", ":", "for", "lookup_func", "in", "lookup_func_list", ":", "formatter_func", "=", "lookup_func", "(", "formatter_name", ")", "if", "formatter_func", "is", ...
Returns a *function* suitable for passing as the more_formatters argument to Template. NOTE: In Java, this would be implemented using the 'Composite' pattern. A *list* of formatter lookup function behaves the same as a *single* formatter lookup funcion. Note the distinction between formatter *lookup* funct...
[ "Returns", "a", "*", "function", "*", "suitable", "for", "passing", "as", "the", "more_formatters", "argument", "to", "Template", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/formatters.py#L31-L48
vladsaveliev/TargQC
targqc/utilz/jsontemplate/formatters.py
PythonPercentFormat
def PythonPercentFormat(format_str): """Use Python % format strings as template format specifiers.""" if format_str.startswith('printf '): fmt = format_str[len('printf '):] return lambda value: fmt % value else: return None
python
def PythonPercentFormat(format_str): """Use Python % format strings as template format specifiers.""" if format_str.startswith('printf '): fmt = format_str[len('printf '):] return lambda value: fmt % value else: return None
[ "def", "PythonPercentFormat", "(", "format_str", ")", ":", "if", "format_str", ".", "startswith", "(", "'printf '", ")", ":", "fmt", "=", "format_str", "[", "len", "(", "'printf '", ")", ":", "]", "return", "lambda", "value", ":", "fmt", "%", "value", "e...
Use Python % format strings as template format specifiers.
[ "Use", "Python", "%", "format", "strings", "as", "template", "format", "specifiers", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/formatters.py#L51-L58
vladsaveliev/TargQC
targqc/utilz/jsontemplate/formatters.py
Plural
def Plural(format_str): """Returns whether the value should be considered a plural value. Integers greater than 1 are plural, and lists with length greater than one are too. """ if format_str.startswith('plural?'): i = len('plural?') try: splitchar = format_str[i] # Usually a space, but could...
python
def Plural(format_str): """Returns whether the value should be considered a plural value. Integers greater than 1 are plural, and lists with length greater than one are too. """ if format_str.startswith('plural?'): i = len('plural?') try: splitchar = format_str[i] # Usually a space, but could...
[ "def", "Plural", "(", "format_str", ")", ":", "if", "format_str", ".", "startswith", "(", "'plural?'", ")", ":", "i", "=", "len", "(", "'plural?'", ")", "try", ":", "splitchar", "=", "format_str", "[", "i", "]", "# Usually a space, but could be something else"...
Returns whether the value should be considered a plural value. Integers greater than 1 are plural, and lists with length greater than one are too.
[ "Returns", "whether", "the", "value", "should", "be", "considered", "a", "plural", "value", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/formatters.py#L117-L147
vladsaveliev/TargQC
ensembl/__init__.py
get_merged_cds
def get_merged_cds(genome): """ Returns all CDS merged, used: - for TargQC general reports CDS coverage statistics for WGS - for Seq2C CNV calling when no capture BED available """ bed = get_all_features(genome) debug('Filtering BEDTool for high confidence CDS and stop codons') return be...
python
def get_merged_cds(genome): """ Returns all CDS merged, used: - for TargQC general reports CDS coverage statistics for WGS - for Seq2C CNV calling when no capture BED available """ bed = get_all_features(genome) debug('Filtering BEDTool for high confidence CDS and stop codons') return be...
[ "def", "get_merged_cds", "(", "genome", ")", ":", "bed", "=", "get_all_features", "(", "genome", ")", "debug", "(", "'Filtering BEDTool for high confidence CDS and stop codons'", ")", "return", "bed", ".", "filter", "(", "lambda", "r", ":", "r", ".", "fields", "...
Returns all CDS merged, used: - for TargQC general reports CDS coverage statistics for WGS - for Seq2C CNV calling when no capture BED available
[ "Returns", "all", "CDS", "merged", "used", ":", "-", "for", "TargQC", "general", "reports", "CDS", "coverage", "statistics", "for", "WGS", "-", "for", "Seq2C", "CNV", "calling", "when", "no", "capture", "BED", "available" ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/ensembl/__init__.py#L89-L100
vladsaveliev/TargQC
ensembl/__init__.py
_get
def _get(relative_path, genome=None): """ :param relative_path: relative path of the file inside the repository :param genome: genome name. Can contain chromosome name after comma, like hg19-chr20, in case of BED, the returning BedTool will be with added filter. :return: BedTools obje...
python
def _get(relative_path, genome=None): """ :param relative_path: relative path of the file inside the repository :param genome: genome name. Can contain chromosome name after comma, like hg19-chr20, in case of BED, the returning BedTool will be with added filter. :return: BedTools obje...
[ "def", "_get", "(", "relative_path", ",", "genome", "=", "None", ")", ":", "chrom", "=", "None", "if", "genome", ":", "if", "'-chr'", "in", "genome", ":", "genome", ",", "chrom", "=", "genome", ".", "split", "(", "'-'", ")", "check_genome", "(", "gen...
:param relative_path: relative path of the file inside the repository :param genome: genome name. Can contain chromosome name after comma, like hg19-chr20, in case of BED, the returning BedTool will be with added filter. :return: BedTools object if it's a BED file, or filepath
[ ":", "param", "relative_path", ":", "relative", "path", "of", "the", "file", "inside", "the", "repository", ":", "param", "genome", ":", "genome", "name", ".", "Can", "contain", "chromosome", "name", "after", "comma", "like", "hg19", "-", "chr20", "in", "c...
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/ensembl/__init__.py#L200-L234
vladsaveliev/TargQC
targqc/utilz/call_process.py
run
def run(cmd, output_fpath=None, input_fpath=None, checks=None, stdout_to_outputfile=True, stdout_tx=True, reuse=False, env_vars=None): """Run the provided command, logging details and checking for errors. """ if output_fpath and reuse: if verify_file(output_fpath, silent=True): i...
python
def run(cmd, output_fpath=None, input_fpath=None, checks=None, stdout_to_outputfile=True, stdout_tx=True, reuse=False, env_vars=None): """Run the provided command, logging details and checking for errors. """ if output_fpath and reuse: if verify_file(output_fpath, silent=True): i...
[ "def", "run", "(", "cmd", ",", "output_fpath", "=", "None", ",", "input_fpath", "=", "None", ",", "checks", "=", "None", ",", "stdout_to_outputfile", "=", "True", ",", "stdout_tx", "=", "True", ",", "reuse", "=", "False", ",", "env_vars", "=", "None", ...
Run the provided command, logging details and checking for errors.
[ "Run", "the", "provided", "command", "logging", "details", "and", "checking", "for", "errors", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/call_process.py#L15-L68
vladsaveliev/TargQC
targqc/summarize.py
_correct_qualimap_genome_results
def _correct_qualimap_genome_results(samples): """ fixing java.lang.Double.parseDouble error on entries like "6,082.49" """ for s in samples: if verify_file(s.qualimap_genome_results_fpath): correction_is_needed = False with open(s.qualimap_genome_results_fpath, 'r') as f: ...
python
def _correct_qualimap_genome_results(samples): """ fixing java.lang.Double.parseDouble error on entries like "6,082.49" """ for s in samples: if verify_file(s.qualimap_genome_results_fpath): correction_is_needed = False with open(s.qualimap_genome_results_fpath, 'r') as f: ...
[ "def", "_correct_qualimap_genome_results", "(", "samples", ")", ":", "for", "s", "in", "samples", ":", "if", "verify_file", "(", "s", ".", "qualimap_genome_results_fpath", ")", ":", "correction_is_needed", "=", "False", "with", "open", "(", "s", ".", "qualimap_g...
fixing java.lang.Double.parseDouble error on entries like "6,082.49"
[ "fixing", "java", ".", "lang", ".", "Double", ".", "parseDouble", "error", "on", "entries", "like", "6", "082", ".", "49" ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/summarize.py#L165-L190
vladsaveliev/TargQC
targqc/summarize.py
_correct_qualimap_insert_size_histogram
def _correct_qualimap_insert_size_histogram(work_dir, samples): """ replacing Qualimap insert size histogram with Picard one. """ for s in samples: qualimap1_dirname = dirname(s.qualimap_ins_size_hist_fpath).replace('raw_data_qualimapReport', 'raw_data') qualimap2_dirname = dirname(s.qualima...
python
def _correct_qualimap_insert_size_histogram(work_dir, samples): """ replacing Qualimap insert size histogram with Picard one. """ for s in samples: qualimap1_dirname = dirname(s.qualimap_ins_size_hist_fpath).replace('raw_data_qualimapReport', 'raw_data') qualimap2_dirname = dirname(s.qualima...
[ "def", "_correct_qualimap_insert_size_histogram", "(", "work_dir", ",", "samples", ")", ":", "for", "s", "in", "samples", ":", "qualimap1_dirname", "=", "dirname", "(", "s", ".", "qualimap_ins_size_hist_fpath", ")", ".", "replace", "(", "'raw_data_qualimapReport'", ...
replacing Qualimap insert size histogram with Picard one.
[ "replacing", "Qualimap", "insert", "size", "histogram", "with", "Picard", "one", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/summarize.py#L193-L223
RI-imaging/ODTbrain
odtbrain/_alg3d_bppt.py
norm_vec
def norm_vec(vector): """Normalize the length of a vector to one""" assert len(vector) == 3 v = np.array(vector) return v/np.sqrt(np.sum(v**2))
python
def norm_vec(vector): """Normalize the length of a vector to one""" assert len(vector) == 3 v = np.array(vector) return v/np.sqrt(np.sum(v**2))
[ "def", "norm_vec", "(", "vector", ")", ":", "assert", "len", "(", "vector", ")", "==", "3", "v", "=", "np", ".", "array", "(", "vector", ")", "return", "v", "/", "np", ".", "sqrt", "(", "np", ".", "sum", "(", "v", "**", "2", ")", ")" ]
Normalize the length of a vector to one
[ "Normalize", "the", "length", "of", "a", "vector", "to", "one" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg3d_bppt.py#L26-L30
RI-imaging/ODTbrain
odtbrain/_alg3d_bppt.py
rotate_points_to_axis
def rotate_points_to_axis(points, axis): """Rotate all points of a list, such that `axis==[0,1,0]` This is accomplished by rotating in the x-z-plane by phi into the y-z-plane, then rotation in the y-z-plane by theta up to [0,1,0], and finally rotating back in the x-z-plane by -phi. Parameters ...
python
def rotate_points_to_axis(points, axis): """Rotate all points of a list, such that `axis==[0,1,0]` This is accomplished by rotating in the x-z-plane by phi into the y-z-plane, then rotation in the y-z-plane by theta up to [0,1,0], and finally rotating back in the x-z-plane by -phi. Parameters ...
[ "def", "rotate_points_to_axis", "(", "points", ",", "axis", ")", ":", "axis", "=", "norm_vec", "(", "axis", ")", "u", ",", "v", ",", "w", "=", "axis", "points", "=", "np", ".", "array", "(", "points", ")", "# Determine the rotational angle in the x-z plane",...
Rotate all points of a list, such that `axis==[0,1,0]` This is accomplished by rotating in the x-z-plane by phi into the y-z-plane, then rotation in the y-z-plane by theta up to [0,1,0], and finally rotating back in the x-z-plane by -phi. Parameters ---------- points: list-like with elements o...
[ "Rotate", "all", "points", "of", "a", "list", "such", "that", "axis", "==", "[", "0", "1", "0", "]" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg3d_bppt.py#L33-L120
RI-imaging/ODTbrain
odtbrain/_alg3d_bppt.py
rotation_matrix_from_point
def rotation_matrix_from_point(point, ret_inv=False): """Compute rotation matrix to go from [0,0,1] to `point`. First, the matrix rotates to in the polar direction. Then, a rotation about the y-axis is performed to match the azimuthal angle in the x-z-plane. This rotation matrix is required for th...
python
def rotation_matrix_from_point(point, ret_inv=False): """Compute rotation matrix to go from [0,0,1] to `point`. First, the matrix rotates to in the polar direction. Then, a rotation about the y-axis is performed to match the azimuthal angle in the x-z-plane. This rotation matrix is required for th...
[ "def", "rotation_matrix_from_point", "(", "point", ",", "ret_inv", "=", "False", ")", ":", "x", ",", "y", ",", "z", "=", "point", "# azimuthal angle", "phi", "=", "np", ".", "arctan2", "(", "x", ",", "z", ")", "# angle in polar direction (negative)", "theta"...
Compute rotation matrix to go from [0,0,1] to `point`. First, the matrix rotates to in the polar direction. Then, a rotation about the y-axis is performed to match the azimuthal angle in the x-z-plane. This rotation matrix is required for the correct 3D orientation of the backpropagated projection...
[ "Compute", "rotation", "matrix", "to", "go", "from", "[", "0", "0", "1", "]", "to", "point", "." ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg3d_bppt.py#L123-L175
RI-imaging/ODTbrain
odtbrain/_alg3d_bppt.py
rotation_matrix_from_point_planerot
def rotation_matrix_from_point_planerot(point, plane_angle, ret_inv=False): """ Compute rotation matrix to go from [0,0,1] to `point`, while taking into account the tilted axis of rotation. First, the matrix rotates to in the polar direction. Then, a rotation about the y-axis is performed to match ...
python
def rotation_matrix_from_point_planerot(point, plane_angle, ret_inv=False): """ Compute rotation matrix to go from [0,0,1] to `point`, while taking into account the tilted axis of rotation. First, the matrix rotates to in the polar direction. Then, a rotation about the y-axis is performed to match ...
[ "def", "rotation_matrix_from_point_planerot", "(", "point", ",", "plane_angle", ",", "ret_inv", "=", "False", ")", ":", "# These matrices are correct if there is no tilt of the", "# rotational axis within the detector plane (x-y).", "D", ",", "Dinv", "=", "rotation_matrix_from_po...
Compute rotation matrix to go from [0,0,1] to `point`, while taking into account the tilted axis of rotation. First, the matrix rotates to in the polar direction. Then, a rotation about the y-axis is performed to match the azimuthal angle in the x-z-plane. This rotation matrix is required for the ...
[ "Compute", "rotation", "matrix", "to", "go", "from", "[", "0", "0", "1", "]", "to", "point", "while", "taking", "into", "account", "the", "tilted", "axis", "of", "rotation", "." ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg3d_bppt.py#L178-L227
RI-imaging/ODTbrain
odtbrain/_alg3d_bppt.py
sphere_points_from_angles_and_tilt
def sphere_points_from_angles_and_tilt(angles, tilted_axis): """ For a given tilt of the rotational axis `tilted_axis`, compute the points on a unit sphere that correspond to the distribution `angles` along the great circle about this axis. Parameters ---------- angles: 1d ndarray T...
python
def sphere_points_from_angles_and_tilt(angles, tilted_axis): """ For a given tilt of the rotational axis `tilted_axis`, compute the points on a unit sphere that correspond to the distribution `angles` along the great circle about this axis. Parameters ---------- angles: 1d ndarray T...
[ "def", "sphere_points_from_angles_and_tilt", "(", "angles", ",", "tilted_axis", ")", ":", "assert", "len", "(", "angles", ".", "shape", ")", "==", "1", "# Normalize tilted axis.", "tilted_axis", "=", "norm_vec", "(", "tilted_axis", ")", "[", "u", ",", "v", ","...
For a given tilt of the rotational axis `tilted_axis`, compute the points on a unit sphere that correspond to the distribution `angles` along the great circle about this axis. Parameters ---------- angles: 1d ndarray The angles that will be distributed on the great circle. tilted_axis: ...
[ "For", "a", "given", "tilt", "of", "the", "rotational", "axis", "tilted_axis", "compute", "the", "points", "on", "a", "unit", "sphere", "that", "correspond", "to", "the", "distribution", "angles", "along", "the", "great", "circle", "about", "this", "axis", "...
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg3d_bppt.py#L230-L371
RI-imaging/ODTbrain
odtbrain/_alg3d_bppt.py
backpropagate_3d_tilted
def backpropagate_3d_tilted(uSin, angles, res, nm, lD=0, tilted_axis=[0, 1, 0], coords=None, weight_angles=True, onlyreal=False, padding=(True, True), padfac=1.75, padval=None, intp_order=2, dtype=None, ...
python
def backpropagate_3d_tilted(uSin, angles, res, nm, lD=0, tilted_axis=[0, 1, 0], coords=None, weight_angles=True, onlyreal=False, padding=(True, True), padfac=1.75, padval=None, intp_order=2, dtype=None, ...
[ "def", "backpropagate_3d_tilted", "(", "uSin", ",", "angles", ",", "res", ",", "nm", ",", "lD", "=", "0", ",", "tilted_axis", "=", "[", "0", ",", "1", ",", "0", "]", ",", "coords", "=", "None", ",", "weight_angles", "=", "True", ",", "onlyreal", "=...
r"""3D backpropagation with a tilted axis of rotation Three-dimensional diffraction tomography reconstruction algorithm for scattering of a plane wave :math:`u_0(\mathbf{r}) = u_0(x,y,z)` by a dielectric object with refractive index :math:`n(x,y,z)`. This method implements the 3D backpropagati...
[ "r", "3D", "backpropagation", "with", "a", "tilted", "axis", "of", "rotation" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg3d_bppt.py#L374-L942
vladsaveliev/TargQC
tab_utils/support.py
filenames_to_uniq
def filenames_to_uniq(names,new_delim='.'): ''' Given a set of file names, produce a list of names consisting of the uniq parts of the names. This works from the end of the name. Chunks of the name are split on '.' and '-'. For example: A.foo.bar.txt B.foo.bar.txt retur...
python
def filenames_to_uniq(names,new_delim='.'): ''' Given a set of file names, produce a list of names consisting of the uniq parts of the names. This works from the end of the name. Chunks of the name are split on '.' and '-'. For example: A.foo.bar.txt B.foo.bar.txt retur...
[ "def", "filenames_to_uniq", "(", "names", ",", "new_delim", "=", "'.'", ")", ":", "name_words", "=", "[", "]", "maxlen", "=", "0", "for", "name", "in", "names", ":", "name_words", ".", "append", "(", "name", ".", "replace", "(", "'.'", ",", "' '", ")...
Given a set of file names, produce a list of names consisting of the uniq parts of the names. This works from the end of the name. Chunks of the name are split on '.' and '-'. For example: A.foo.bar.txt B.foo.bar.txt returns: ['A','B'] AA.BB.foo.txt CC.foo....
[ "Given", "a", "set", "of", "file", "names", "produce", "a", "list", "of", "names", "consisting", "of", "the", "uniq", "parts", "of", "the", "names", ".", "This", "works", "from", "the", "end", "of", "the", "name", ".", "Chunks", "of", "the", "name", ...
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/tab_utils/support.py#L52-L100
svenkreiss/databench
databench/meta_zmq.py
MetaZMQ.run_process
def run_process(self, analysis, action_name, message='__nomessagetoken__'): """Executes an process in the analysis with the given message. It also handles the start and stop signals in case a process_id is given. """ if action_name == 'connect': analysis.on_connect(...
python
def run_process(self, analysis, action_name, message='__nomessagetoken__'): """Executes an process in the analysis with the given message. It also handles the start and stop signals in case a process_id is given. """ if action_name == 'connect': analysis.on_connect(...
[ "def", "run_process", "(", "self", ",", "analysis", ",", "action_name", ",", "message", "=", "'__nomessagetoken__'", ")", ":", "if", "action_name", "==", "'connect'", ":", "analysis", ".", "on_connect", "(", "self", ".", "executable", ",", "self", ".", "zmq_...
Executes an process in the analysis with the given message. It also handles the start and stop signals in case a process_id is given.
[ "Executes", "an", "process", "in", "the", "analysis", "with", "the", "given", "message", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/meta_zmq.py#L27-L46
python-astrodynamics/spacetrack
shovel/_helpers.py
check_git_unchanged
def check_git_unchanged(filename, yes=False): """Check git to avoid overwriting user changes.""" if check_staged(filename): s = 'There are staged changes in {}, overwrite? [y/n] '.format(filename) if yes or input(s) in ('y', 'yes'): return else: raise RuntimeError...
python
def check_git_unchanged(filename, yes=False): """Check git to avoid overwriting user changes.""" if check_staged(filename): s = 'There are staged changes in {}, overwrite? [y/n] '.format(filename) if yes or input(s) in ('y', 'yes'): return else: raise RuntimeError...
[ "def", "check_git_unchanged", "(", "filename", ",", "yes", "=", "False", ")", ":", "if", "check_staged", "(", "filename", ")", ":", "s", "=", "'There are staged changes in {}, overwrite? [y/n] '", ".", "format", "(", "filename", ")", "if", "yes", "or", "input", ...
Check git to avoid overwriting user changes.
[ "Check", "git", "to", "avoid", "overwriting", "user", "changes", "." ]
train
https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/shovel/_helpers.py#L7-L22
python-astrodynamics/spacetrack
shovel/_helpers.py
check_staged
def check_staged(filename=None): """Check if there are 'changes to be committed' in the index.""" retcode, _, stdout = git['diff-index', '--quiet', '--cached', 'HEAD', filename].run(retcode=None) if retcode == 1: return True elif retcode == 0: return False ...
python
def check_staged(filename=None): """Check if there are 'changes to be committed' in the index.""" retcode, _, stdout = git['diff-index', '--quiet', '--cached', 'HEAD', filename].run(retcode=None) if retcode == 1: return True elif retcode == 0: return False ...
[ "def", "check_staged", "(", "filename", "=", "None", ")", ":", "retcode", ",", "_", ",", "stdout", "=", "git", "[", "'diff-index'", ",", "'--quiet'", ",", "'--cached'", ",", "'HEAD'", ",", "filename", "]", ".", "run", "(", "retcode", "=", "None", ")", ...
Check if there are 'changes to be committed' in the index.
[ "Check", "if", "there", "are", "changes", "to", "be", "committed", "in", "the", "index", "." ]
train
https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/shovel/_helpers.py#L25-L34
svenkreiss/databench
databench/meta.py
Meta.run_process
def run_process(analysis, action_name, message='__nomessagetoken__'): """Executes an action in the analysis with the given message. It also handles the start and stop signals in the case that message is a `dict` with a key ``__process_id``. :param str action_name: Name of the action to...
python
def run_process(analysis, action_name, message='__nomessagetoken__'): """Executes an action in the analysis with the given message. It also handles the start and stop signals in the case that message is a `dict` with a key ``__process_id``. :param str action_name: Name of the action to...
[ "def", "run_process", "(", "analysis", ",", "action_name", ",", "message", "=", "'__nomessagetoken__'", ")", ":", "if", "analysis", "is", "None", ":", "return", "# detect process_id", "process_id", "=", "None", "if", "isinstance", "(", "message", ",", "dict", ...
Executes an action in the analysis with the given message. It also handles the start and stop signals in the case that message is a `dict` with a key ``__process_id``. :param str action_name: Name of the action to trigger. :param message: Message. :param callback: A...
[ "Executes", "an", "action", "in", "the", "analysis", "with", "the", "given", "message", "." ]
train
https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/meta.py#L109-L168
RI-imaging/ODTbrain
examples/example_helper.py
dl_file
def dl_file(url, dest, chunk_size=6553): """Download `url` to `dest`""" import urllib3 http = urllib3.PoolManager() r = http.request('GET', url, preload_content=False) with dest.open('wb') as out: while True: data = r.read(chunk_size) if data is None or len(data) == 0...
python
def dl_file(url, dest, chunk_size=6553): """Download `url` to `dest`""" import urllib3 http = urllib3.PoolManager() r = http.request('GET', url, preload_content=False) with dest.open('wb') as out: while True: data = r.read(chunk_size) if data is None or len(data) == 0...
[ "def", "dl_file", "(", "url", ",", "dest", ",", "chunk_size", "=", "6553", ")", ":", "import", "urllib3", "http", "=", "urllib3", ".", "PoolManager", "(", ")", "r", "=", "http", ".", "request", "(", "'GET'", ",", "url", ",", "preload_content", "=", "...
Download `url` to `dest`
[ "Download", "url", "to", "dest" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/examples/example_helper.py#L17-L28
RI-imaging/ODTbrain
examples/example_helper.py
extract_lzma
def extract_lzma(path): """Extract an lzma file and return the temporary file name""" tlfile = pathlib.Path(path) # open lzma file with tlfile.open("rb") as td: data = lzma.decompress(td.read()) # write temporary tar file fd, tmpname = tempfile.mkstemp(prefix="odt_ex_", suffix=".tar") ...
python
def extract_lzma(path): """Extract an lzma file and return the temporary file name""" tlfile = pathlib.Path(path) # open lzma file with tlfile.open("rb") as td: data = lzma.decompress(td.read()) # write temporary tar file fd, tmpname = tempfile.mkstemp(prefix="odt_ex_", suffix=".tar") ...
[ "def", "extract_lzma", "(", "path", ")", ":", "tlfile", "=", "pathlib", ".", "Path", "(", "path", ")", "# open lzma file", "with", "tlfile", ".", "open", "(", "\"rb\"", ")", "as", "td", ":", "data", "=", "lzma", ".", "decompress", "(", "td", ".", "re...
Extract an lzma file and return the temporary file name
[ "Extract", "an", "lzma", "file", "and", "return", "the", "temporary", "file", "name" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/examples/example_helper.py#L31-L41
RI-imaging/ODTbrain
examples/example_helper.py
get_file
def get_file(fname, datapath=datapath): """Return path of an example data file Return the full path to an example data file name. If the file does not exist in the `datapath` directory, tries to download it from the ODTbrain GitHub repository. """ # download location datapath = pathlib.Path...
python
def get_file(fname, datapath=datapath): """Return path of an example data file Return the full path to an example data file name. If the file does not exist in the `datapath` directory, tries to download it from the ODTbrain GitHub repository. """ # download location datapath = pathlib.Path...
[ "def", "get_file", "(", "fname", ",", "datapath", "=", "datapath", ")", ":", "# download location", "datapath", "=", "pathlib", ".", "Path", "(", "datapath", ")", "datapath", ".", "mkdir", "(", "parents", "=", "True", ",", "exist_ok", "=", "True", ")", "...
Return path of an example data file Return the full path to an example data file name. If the file does not exist in the `datapath` directory, tries to download it from the ODTbrain GitHub repository.
[ "Return", "path", "of", "an", "example", "data", "file" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/examples/example_helper.py#L44-L64
RI-imaging/ODTbrain
examples/example_helper.py
load_data
def load_data(fname, **kwargs): """Load example data""" fname = get_file(fname) if fname.suffix == ".lzma": return load_tar_lzma_data(fname) elif fname.suffix == ".zip": return load_zip_data(fname, **kwargs)
python
def load_data(fname, **kwargs): """Load example data""" fname = get_file(fname) if fname.suffix == ".lzma": return load_tar_lzma_data(fname) elif fname.suffix == ".zip": return load_zip_data(fname, **kwargs)
[ "def", "load_data", "(", "fname", ",", "*", "*", "kwargs", ")", ":", "fname", "=", "get_file", "(", "fname", ")", "if", "fname", ".", "suffix", "==", "\".lzma\"", ":", "return", "load_tar_lzma_data", "(", "fname", ")", "elif", "fname", ".", "suffix", "...
Load example data
[ "Load", "example", "data" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/examples/example_helper.py#L67-L73
RI-imaging/ODTbrain
examples/example_helper.py
load_tar_lzma_data
def load_tar_lzma_data(tlfile): """Load example sinogram data from a .tar.lzma file""" tmpname = extract_lzma(tlfile) # open tar file fields_real = [] fields_imag = [] phantom = [] parms = {} with tarfile.open(tmpname, "r") as t: members = t.getmembers() members.sort(ke...
python
def load_tar_lzma_data(tlfile): """Load example sinogram data from a .tar.lzma file""" tmpname = extract_lzma(tlfile) # open tar file fields_real = [] fields_imag = [] phantom = [] parms = {} with tarfile.open(tmpname, "r") as t: members = t.getmembers() members.sort(ke...
[ "def", "load_tar_lzma_data", "(", "tlfile", ")", ":", "tmpname", "=", "extract_lzma", "(", "tlfile", ")", "# open tar file", "fields_real", "=", "[", "]", "fields_imag", "=", "[", "]", "phantom", "=", "[", "]", "parms", "=", "{", "}", "with", "tarfile", ...
Load example sinogram data from a .tar.lzma file
[ "Load", "example", "sinogram", "data", "from", "a", ".", "tar", ".", "lzma", "file" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/examples/example_helper.py#L76-L116
RI-imaging/ODTbrain
examples/example_helper.py
load_zip_data
def load_zip_data(zipname, f_sino_real, f_sino_imag, f_angles=None, f_phantom=None, f_info=None): """Load example sinogram data from a .zip file""" ret = [] with zipfile.ZipFile(str(zipname)) as arc: sino_real = np.loadtxt(arc.open(f_sino_real)) sino_imag = np.loadtxt(arc.o...
python
def load_zip_data(zipname, f_sino_real, f_sino_imag, f_angles=None, f_phantom=None, f_info=None): """Load example sinogram data from a .zip file""" ret = [] with zipfile.ZipFile(str(zipname)) as arc: sino_real = np.loadtxt(arc.open(f_sino_real)) sino_imag = np.loadtxt(arc.o...
[ "def", "load_zip_data", "(", "zipname", ",", "f_sino_real", ",", "f_sino_imag", ",", "f_angles", "=", "None", ",", "f_phantom", "=", "None", ",", "f_info", "=", "None", ")", ":", "ret", "=", "[", "]", "with", "zipfile", ".", "ZipFile", "(", "str", "(",...
Load example sinogram data from a .zip file
[ "Load", "example", "sinogram", "data", "from", "a", ".", "zip", "file" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/examples/example_helper.py#L119-L143
RI-imaging/ODTbrain
odtbrain/_alg2d_fmp.py
fourier_map_2d
def fourier_map_2d(uSin, angles, res, nm, lD=0, semi_coverage=False, coords=None, count=None, max_count=None, verbose=0): r"""2D Fourier mapping with the Fourier diffraction theorem Two-dimensional diffraction tomography reconstruction algorithm for scattering of a plane wave :math:`...
python
def fourier_map_2d(uSin, angles, res, nm, lD=0, semi_coverage=False, coords=None, count=None, max_count=None, verbose=0): r"""2D Fourier mapping with the Fourier diffraction theorem Two-dimensional diffraction tomography reconstruction algorithm for scattering of a plane wave :math:`...
[ "def", "fourier_map_2d", "(", "uSin", ",", "angles", ",", "res", ",", "nm", ",", "lD", "=", "0", ",", "semi_coverage", "=", "False", ",", "coords", "=", "None", ",", "count", "=", "None", ",", "max_count", "=", "None", ",", "verbose", "=", "0", ")"...
r"""2D Fourier mapping with the Fourier diffraction theorem Two-dimensional diffraction tomography reconstruction algorithm for scattering of a plane wave :math:`u_0(\mathbf{r}) = u_0(x,z)` by a dielectric object with refractive index :math:`n(x,z)`. This function implements the solution by in...
[ "r", "2D", "Fourier", "mapping", "with", "the", "Fourier", "diffraction", "theorem" ]
train
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg2d_fmp.py#L6-L261
vladsaveliev/TargQC
targqc/utilz/file_utils.py
transform_to
def transform_to(ext): """ Decorator to create an output filename from an output filename with the specified extension. Changes the extension, in_file is transformed to a new type. Takes functions like this to decorate: f(in_file, out_dir=None, out_file=None) or, f(in_file=in_file, out_dir=...
python
def transform_to(ext): """ Decorator to create an output filename from an output filename with the specified extension. Changes the extension, in_file is transformed to a new type. Takes functions like this to decorate: f(in_file, out_dir=None, out_file=None) or, f(in_file=in_file, out_dir=...
[ "def", "transform_to", "(", "ext", ")", ":", "def", "decor", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "out_file", "=", "kwargs", ".", "get", "(", "...
Decorator to create an output filename from an output filename with the specified extension. Changes the extension, in_file is transformed to a new type. Takes functions like this to decorate: f(in_file, out_dir=None, out_file=None) or, f(in_file=in_file, out_dir=None, out_file=None) examples:...
[ "Decorator", "to", "create", "an", "output", "filename", "from", "an", "output", "filename", "with", "the", "specified", "extension", ".", "Changes", "the", "extension", "in_file", "is", "transformed", "to", "a", "new", "type", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L59-L95
vladsaveliev/TargQC
targqc/utilz/file_utils.py
filter_to
def filter_to(word): """ Decorator to create an output filename from an input filename by adding a word onto the stem. in_file is filtered by the function and the results are written to out_file. You would want to use this over transform_to if you don't know the extension of the file going in. T...
python
def filter_to(word): """ Decorator to create an output filename from an input filename by adding a word onto the stem. in_file is filtered by the function and the results are written to out_file. You would want to use this over transform_to if you don't know the extension of the file going in. T...
[ "def", "filter_to", "(", "word", ")", ":", "def", "decor", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "out_file", "=", "kwargs", ".", "get", "(", "\"...
Decorator to create an output filename from an input filename by adding a word onto the stem. in_file is filtered by the function and the results are written to out_file. You would want to use this over transform_to if you don't know the extension of the file going in. This also memoizes the output file...
[ "Decorator", "to", "create", "an", "output", "filename", "from", "an", "input", "filename", "by", "adding", "a", "word", "onto", "the", "stem", ".", "in_file", "is", "filtered", "by", "the", "function", "and", "the", "results", "are", "written", "to", "out...
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L98-L136
vladsaveliev/TargQC
targqc/utilz/file_utils.py
chdir
def chdir(new_dir): """Context manager to temporarily change to a new directory. http://lucentbeing.com/blog/context-managers-and-the-with-statement-in-python/ """ cur_dir = os.getcwd() safe_mkdir(new_dir) os.chdir(new_dir) try: yield finally: os.chdir(cur_dir)
python
def chdir(new_dir): """Context manager to temporarily change to a new directory. http://lucentbeing.com/blog/context-managers-and-the-with-statement-in-python/ """ cur_dir = os.getcwd() safe_mkdir(new_dir) os.chdir(new_dir) try: yield finally: os.chdir(cur_dir)
[ "def", "chdir", "(", "new_dir", ")", ":", "cur_dir", "=", "os", ".", "getcwd", "(", ")", "safe_mkdir", "(", "new_dir", ")", "os", ".", "chdir", "(", "new_dir", ")", "try", ":", "yield", "finally", ":", "os", ".", "chdir", "(", "cur_dir", ")" ]
Context manager to temporarily change to a new directory. http://lucentbeing.com/blog/context-managers-and-the-with-statement-in-python/
[ "Context", "manager", "to", "temporarily", "change", "to", "a", "new", "directory", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L152-L163
vladsaveliev/TargQC
targqc/utilz/file_utils.py
file_uptodate
def file_uptodate(fname, cmp_fname): """Check if a file exists, is non-empty and is more recent than cmp_fname. """ try: return (file_exists(fname) and file_exists(cmp_fname) and getmtime(fname) >= getmtime(cmp_fname)) except OSError: return False
python
def file_uptodate(fname, cmp_fname): """Check if a file exists, is non-empty and is more recent than cmp_fname. """ try: return (file_exists(fname) and file_exists(cmp_fname) and getmtime(fname) >= getmtime(cmp_fname)) except OSError: return False
[ "def", "file_uptodate", "(", "fname", ",", "cmp_fname", ")", ":", "try", ":", "return", "(", "file_exists", "(", "fname", ")", "and", "file_exists", "(", "cmp_fname", ")", "and", "getmtime", "(", "fname", ")", ">=", "getmtime", "(", "cmp_fname", ")", ")"...
Check if a file exists, is non-empty and is more recent than cmp_fname.
[ "Check", "if", "a", "file", "exists", "is", "non", "-", "empty", "and", "is", "more", "recent", "than", "cmp_fname", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L165-L172
vladsaveliev/TargQC
targqc/utilz/file_utils.py
save_diskspace
def save_diskspace(fname, reason, config): """Overwrite a file in place with a short message to save disk. This keeps files as a sanity check on processes working, but saves disk by replacing them with a short message. """ if config["algorithm"].get("save_diskspace", False): with open(fname...
python
def save_diskspace(fname, reason, config): """Overwrite a file in place with a short message to save disk. This keeps files as a sanity check on processes working, but saves disk by replacing them with a short message. """ if config["algorithm"].get("save_diskspace", False): with open(fname...
[ "def", "save_diskspace", "(", "fname", ",", "reason", ",", "config", ")", ":", "if", "config", "[", "\"algorithm\"", "]", ".", "get", "(", "\"save_diskspace\"", ",", "False", ")", ":", "with", "open", "(", "fname", ",", "\"w\"", ")", "as", "out_handle", ...
Overwrite a file in place with a short message to save disk. This keeps files as a sanity check on processes working, but saves disk by replacing them with a short message.
[ "Overwrite", "a", "file", "in", "place", "with", "a", "short", "message", "to", "save", "disk", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L181-L189
vladsaveliev/TargQC
targqc/utilz/file_utils.py
symlink_plus
def symlink_plus(orig, new): """Create relative symlinks and handle associated biological index files. """ for ext in ["", ".idx", ".gbi", ".tbi", ".bai"]: if os.path.exists(orig + ext) and not os.path.lexists(new + ext): with chdir(os.path.dirname(new)): os.symlink(os.pa...
python
def symlink_plus(orig, new): """Create relative symlinks and handle associated biological index files. """ for ext in ["", ".idx", ".gbi", ".tbi", ".bai"]: if os.path.exists(orig + ext) and not os.path.lexists(new + ext): with chdir(os.path.dirname(new)): os.symlink(os.pa...
[ "def", "symlink_plus", "(", "orig", ",", "new", ")", ":", "for", "ext", "in", "[", "\"\"", ",", "\".idx\"", ",", "\".gbi\"", ",", "\".tbi\"", ",", "\".bai\"", "]", ":", "if", "os", ".", "path", ".", "exists", "(", "orig", "+", "ext", ")", "and", ...
Create relative symlinks and handle associated biological index files.
[ "Create", "relative", "symlinks", "and", "handle", "associated", "biological", "index", "files", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L198-L210
vladsaveliev/TargQC
targqc/utilz/file_utils.py
partition
def partition(pred, iterable): 'Use a predicate to partition entries into false entries and true entries' # partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9 t1, t2 = itertools.tee(iterable) try: return itertools.ifilterfalse(pred, t1), itertools.ifilter(pred, t2) except: r...
python
def partition(pred, iterable): 'Use a predicate to partition entries into false entries and true entries' # partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9 t1, t2 = itertools.tee(iterable) try: return itertools.ifilterfalse(pred, t1), itertools.ifilter(pred, t2) except: r...
[ "def", "partition", "(", "pred", ",", "iterable", ")", ":", "# partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9", "t1", ",", "t2", "=", "itertools", ".", "tee", "(", "iterable", ")", "try", ":", "return", "itertools", ".", "ifilterfalse", "(", "pred", ...
Use a predicate to partition entries into false entries and true entries
[ "Use", "a", "predicate", "to", "partition", "entries", "into", "false", "entries", "and", "true", "entries" ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L290-L297
vladsaveliev/TargQC
targqc/utilz/file_utils.py
get_in
def get_in(d, t, default=None): """ look up if you can get a tuple of values from a nested dictionary, each item in the tuple a deeper layer example: get_in({1: {2: 3}}, (1, 2)) -> 3 example: get_in({1: {2: 3}}, (2, 3)) -> {} """ result = reduce(lambda d, t: d.get(t, {}), t, d) if not r...
python
def get_in(d, t, default=None): """ look up if you can get a tuple of values from a nested dictionary, each item in the tuple a deeper layer example: get_in({1: {2: 3}}, (1, 2)) -> 3 example: get_in({1: {2: 3}}, (2, 3)) -> {} """ result = reduce(lambda d, t: d.get(t, {}), t, d) if not r...
[ "def", "get_in", "(", "d", ",", "t", ",", "default", "=", "None", ")", ":", "result", "=", "reduce", "(", "lambda", "d", ",", "t", ":", "d", ".", "get", "(", "t", ",", "{", "}", ")", ",", "t", ",", "d", ")", "if", "not", "result", ":", "r...
look up if you can get a tuple of values from a nested dictionary, each item in the tuple a deeper layer example: get_in({1: {2: 3}}, (1, 2)) -> 3 example: get_in({1: {2: 3}}, (2, 3)) -> {}
[ "look", "up", "if", "you", "can", "get", "a", "tuple", "of", "values", "from", "a", "nested", "dictionary", "each", "item", "in", "the", "tuple", "a", "deeper", "layer" ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L320-L332
vladsaveliev/TargQC
targqc/utilz/file_utils.py
which
def which(program): """ returns the path to an executable or None if it can't be found """ def is_exe(_fpath): return os.path.isfile(_fpath) and os.access(_fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: ...
python
def which(program): """ returns the path to an executable or None if it can't be found """ def is_exe(_fpath): return os.path.isfile(_fpath) and os.access(_fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: ...
[ "def", "which", "(", "program", ")", ":", "def", "is_exe", "(", "_fpath", ")", ":", "return", "os", ".", "path", ".", "isfile", "(", "_fpath", ")", "and", "os", ".", "access", "(", "_fpath", ",", "os", ".", "X_OK", ")", "fpath", ",", "fname", "="...
returns the path to an executable or None if it can't be found
[ "returns", "the", "path", "to", "an", "executable", "or", "None", "if", "it", "can", "t", "be", "found" ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L439-L455
vladsaveliev/TargQC
targqc/utilz/file_utils.py
expanduser
def expanduser(path): """Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] not in '/\\': i = i + 1 if 'HOME' in os.environ: userhome = os.environ['HOME'] elif 'USERP...
python
def expanduser(path): """Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing.""" if path[:1] != '~': return path i, n = 1, len(path) while i < n and path[i] not in '/\\': i = i + 1 if 'HOME' in os.environ: userhome = os.environ['HOME'] elif 'USERP...
[ "def", "expanduser", "(", "path", ")", ":", "if", "path", "[", ":", "1", "]", "!=", "'~'", ":", "return", "path", "i", ",", "n", "=", "1", ",", "len", "(", "path", ")", "while", "i", "<", "n", "and", "path", "[", "i", "]", "not", "in", "'/\...
Expand ~ and ~user constructs. If user or $HOME is unknown, do nothing.
[ "Expand", "~", "and", "~user", "constructs", "." ]
train
https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/file_utils.py#L542-L568