partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
is_valid_superset
Returns True if the actual index is a valid superset of the expected index
bloop/session.py
def is_valid_superset(actual_projection, index): """Returns True if the actual index is a valid superset of the expected index""" projection_type = actual_projection["ProjectionType"] if projection_type == "ALL": return True meta = index.model.Meta # all index types provide index keys and mo...
def is_valid_superset(actual_projection, index): """Returns True if the actual index is a valid superset of the expected index""" projection_type = actual_projection["ProjectionType"] if projection_type == "ALL": return True meta = index.model.Meta # all index types provide index keys and mo...
[ "Returns", "True", "if", "the", "actual", "index", "is", "a", "valid", "superset", "of", "the", "expected", "index" ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L664-L685
[ "def", "is_valid_superset", "(", "actual_projection", ",", "index", ")", ":", "projection_type", "=", "actual_projection", "[", "\"ProjectionType\"", "]", "if", "projection_type", "==", "\"ALL\"", ":", "return", "True", "meta", "=", "index", ".", "model", ".", "...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.save_item
Save an object to DynamoDB. :param item: Unpacked into kwargs for :func:`boto3.DynamoDB.Client.update_item`. :raises bloop.exceptions.ConstraintViolation: if the condition (or atomic) is not met.
bloop/session.py
def save_item(self, item): """Save an object to DynamoDB. :param item: Unpacked into kwargs for :func:`boto3.DynamoDB.Client.update_item`. :raises bloop.exceptions.ConstraintViolation: if the condition (or atomic) is not met. """ try: self.dynamodb_client.update_item...
def save_item(self, item): """Save an object to DynamoDB. :param item: Unpacked into kwargs for :func:`boto3.DynamoDB.Client.update_item`. :raises bloop.exceptions.ConstraintViolation: if the condition (or atomic) is not met. """ try: self.dynamodb_client.update_item...
[ "Save", "an", "object", "to", "DynamoDB", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L60-L69
[ "def", "save_item", "(", "self", ",", "item", ")", ":", "try", ":", "self", ".", "dynamodb_client", ".", "update_item", "(", "*", "*", "item", ")", "except", "botocore", ".", "exceptions", ".", "ClientError", "as", "error", ":", "handle_constraint_violation"...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.delete_item
Delete an object in DynamoDB. :param item: Unpacked into kwargs for :func:`boto3.DynamoDB.Client.delete_item`. :raises bloop.exceptions.ConstraintViolation: if the condition (or atomic) is not met.
bloop/session.py
def delete_item(self, item): """Delete an object in DynamoDB. :param item: Unpacked into kwargs for :func:`boto3.DynamoDB.Client.delete_item`. :raises bloop.exceptions.ConstraintViolation: if the condition (or atomic) is not met. """ try: self.dynamodb_client.delete_...
def delete_item(self, item): """Delete an object in DynamoDB. :param item: Unpacked into kwargs for :func:`boto3.DynamoDB.Client.delete_item`. :raises bloop.exceptions.ConstraintViolation: if the condition (or atomic) is not met. """ try: self.dynamodb_client.delete_...
[ "Delete", "an", "object", "in", "DynamoDB", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L71-L80
[ "def", "delete_item", "(", "self", ",", "item", ")", ":", "try", ":", "self", ".", "dynamodb_client", ".", "delete_item", "(", "*", "*", "item", ")", "except", "botocore", ".", "exceptions", ".", "ClientError", "as", "error", ":", "handle_constraint_violatio...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.load_items
Loads any number of items in chunks, handling continuation tokens. :param items: Unpacked in chunks into "RequestItems" for :func:`boto3.DynamoDB.Client.batch_get_item`.
bloop/session.py
def load_items(self, items): """Loads any number of items in chunks, handling continuation tokens. :param items: Unpacked in chunks into "RequestItems" for :func:`boto3.DynamoDB.Client.batch_get_item`. """ loaded_items = {} requests = collections.deque(create_batch_get_chunks(it...
def load_items(self, items): """Loads any number of items in chunks, handling continuation tokens. :param items: Unpacked in chunks into "RequestItems" for :func:`boto3.DynamoDB.Client.batch_get_item`. """ loaded_items = {} requests = collections.deque(create_batch_get_chunks(it...
[ "Loads", "any", "number", "of", "items", "in", "chunks", "handling", "continuation", "tokens", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L82-L104
[ "def", "load_items", "(", "self", ",", "items", ")", ":", "loaded_items", "=", "{", "}", "requests", "=", "collections", ".", "deque", "(", "create_batch_get_chunks", "(", "items", ")", ")", "while", "requests", ":", "request", "=", "requests", ".", "pop",...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.search_items
Invoke query/scan by name. Response always includes "Count" and "ScannedCount" :param str mode: "query" or "scan" :param request: Unpacked into :func:`boto3.DynamoDB.Client.query` or :func:`boto3.DynamoDB.Client.scan`
bloop/session.py
def search_items(self, mode, request): """Invoke query/scan by name. Response always includes "Count" and "ScannedCount" :param str mode: "query" or "scan" :param request: Unpacked into :func:`boto3.DynamoDB.Client.query` or :func:`boto3.DynamoDB.Client.scan` """ valida...
def search_items(self, mode, request): """Invoke query/scan by name. Response always includes "Count" and "ScannedCount" :param str mode: "query" or "scan" :param request: Unpacked into :func:`boto3.DynamoDB.Client.query` or :func:`boto3.DynamoDB.Client.scan` """ valida...
[ "Invoke", "query", "/", "scan", "by", "name", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L124-L139
[ "def", "search_items", "(", "self", ",", "mode", ",", "request", ")", ":", "validate_search_mode", "(", "mode", ")", "method", "=", "getattr", "(", "self", ".", "dynamodb_client", ",", "mode", ")", "try", ":", "response", "=", "method", "(", "*", "*", ...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.create_table
Create the model's table. Returns True if the table is being created, False otherwise. Does not wait for the table to create, and does not validate an existing table. Will not raise "ResourceInUseException" if the table exists or is being created. :param str table_name: The name of the table ...
bloop/session.py
def create_table(self, table_name, model): """Create the model's table. Returns True if the table is being created, False otherwise. Does not wait for the table to create, and does not validate an existing table. Will not raise "ResourceInUseException" if the table exists or is being created. ...
def create_table(self, table_name, model): """Create the model's table. Returns True if the table is being created, False otherwise. Does not wait for the table to create, and does not validate an existing table. Will not raise "ResourceInUseException" if the table exists or is being created. ...
[ "Create", "the", "model", "s", "table", ".", "Returns", "True", "if", "the", "table", "is", "being", "created", "False", "otherwise", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L141-L159
[ "def", "create_table", "(", "self", ",", "table_name", ",", "model", ")", ":", "table", "=", "create_table_request", "(", "table_name", ",", "model", ")", "try", ":", "self", ".", "dynamodb_client", ".", "create_table", "(", "*", "*", "table", ")", "is_cre...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.describe_table
Polls until the table is ready, then returns the first result when the table was ready. The returned dict is standardized to ensure all fields are present, even when empty or across different DynamoDB API versions. TTL information is also inserted. :param table_name: The name of the ta...
bloop/session.py
def describe_table(self, table_name): """ Polls until the table is ready, then returns the first result when the table was ready. The returned dict is standardized to ensure all fields are present, even when empty or across different DynamoDB API versions. TTL information is als...
def describe_table(self, table_name): """ Polls until the table is ready, then returns the first result when the table was ready. The returned dict is standardized to ensure all fields are present, even when empty or across different DynamoDB API versions. TTL information is als...
[ "Polls", "until", "the", "table", "is", "ready", "then", "returns", "the", "first", "result", "when", "the", "table", "was", "ready", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L161-L204
[ "def", "describe_table", "(", "self", ",", "table_name", ")", ":", "if", "table_name", "in", "self", ".", "_tables", ":", "return", "self", ".", "_tables", "[", "table_name", "]", "status", ",", "description", "=", "None", ",", "{", "}", "calls", "=", ...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.validate_table
Polls until a creating table is ready, then verifies the description against the model's requirements. The model may have a subset of all GSIs and LSIs on the table, but the key structure must be exactly the same. The table must have a stream if the model expects one, but not the other way around. Wh...
bloop/session.py
def validate_table(self, table_name, model): """Polls until a creating table is ready, then verifies the description against the model's requirements. The model may have a subset of all GSIs and LSIs on the table, but the key structure must be exactly the same. The table must have a stream if ...
def validate_table(self, table_name, model): """Polls until a creating table is ready, then verifies the description against the model's requirements. The model may have a subset of all GSIs and LSIs on the table, but the key structure must be exactly the same. The table must have a stream if ...
[ "Polls", "until", "a", "creating", "table", "is", "ready", "then", "verifies", "the", "description", "against", "the", "model", "s", "requirements", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L206-L269
[ "def", "validate_table", "(", "self", ",", "table_name", ",", "model", ")", ":", "actual", "=", "self", ".", "describe_table", "(", "table_name", ")", "if", "not", "compare_tables", "(", "model", ",", "actual", ")", ":", "raise", "TableMismatch", "(", "\"T...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.enable_ttl
Calls UpdateTimeToLive on the table according to model.Meta["ttl"] :param table_name: The name of the table to enable the TTL setting on :param model: The model to get TTL settings from
bloop/session.py
def enable_ttl(self, table_name, model): """Calls UpdateTimeToLive on the table according to model.Meta["ttl"] :param table_name: The name of the table to enable the TTL setting on :param model: The model to get TTL settings from """ self._tables.pop(table_name, None) tt...
def enable_ttl(self, table_name, model): """Calls UpdateTimeToLive on the table according to model.Meta["ttl"] :param table_name: The name of the table to enable the TTL setting on :param model: The model to get TTL settings from """ self._tables.pop(table_name, None) tt...
[ "Calls", "UpdateTimeToLive", "on", "the", "table", "according", "to", "model", ".", "Meta", "[", "ttl", "]" ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L271-L286
[ "def", "enable_ttl", "(", "self", ",", "table_name", ",", "model", ")", ":", "self", ".", "_tables", ".", "pop", "(", "table_name", ",", "None", ")", "ttl_name", "=", "model", ".", "Meta", ".", "ttl", "[", "\"column\"", "]", ".", "dynamo_name", "reques...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.enable_backups
Calls UpdateContinuousBackups on the table according to model.Meta["continuous_backups"] :param table_name: The name of the table to enable Continuous Backups on :param model: The model to get Continuous Backups settings from
bloop/session.py
def enable_backups(self, table_name, model): """Calls UpdateContinuousBackups on the table according to model.Meta["continuous_backups"] :param table_name: The name of the table to enable Continuous Backups on :param model: The model to get Continuous Backups settings from """ s...
def enable_backups(self, table_name, model): """Calls UpdateContinuousBackups on the table according to model.Meta["continuous_backups"] :param table_name: The name of the table to enable Continuous Backups on :param model: The model to get Continuous Backups settings from """ s...
[ "Calls", "UpdateContinuousBackups", "on", "the", "table", "according", "to", "model", ".", "Meta", "[", "continuous_backups", "]" ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L288-L302
[ "def", "enable_backups", "(", "self", ",", "table_name", ",", "model", ")", ":", "self", ".", "_tables", ".", "pop", "(", "table_name", ",", "None", ")", "request", "=", "{", "\"TableName\"", ":", "table_name", ",", "\"PointInTimeRecoverySpecification\"", ":",...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.describe_stream
Wraps :func:`boto3.DynamoDBStreams.Client.describe_stream`, handling continuation tokens. :param str stream_arn: Stream arn, usually from the model's ``Meta.stream["arn"]``. :param str first_shard: *(Optional)* If provided, only shards after this shard id will be returned. :return: All shards i...
bloop/session.py
def describe_stream(self, stream_arn, first_shard=None): """Wraps :func:`boto3.DynamoDBStreams.Client.describe_stream`, handling continuation tokens. :param str stream_arn: Stream arn, usually from the model's ``Meta.stream["arn"]``. :param str first_shard: *(Optional)* If provided, only shards...
def describe_stream(self, stream_arn, first_shard=None): """Wraps :func:`boto3.DynamoDBStreams.Client.describe_stream`, handling continuation tokens. :param str stream_arn: Stream arn, usually from the model's ``Meta.stream["arn"]``. :param str first_shard: *(Optional)* If provided, only shards...
[ "Wraps", ":", "func", ":", "boto3", ".", "DynamoDBStreams", ".", "Client", ".", "describe_stream", "handling", "continuation", "tokens", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L304-L332
[ "def", "describe_stream", "(", "self", ",", "stream_arn", ",", "first_shard", "=", "None", ")", ":", "description", "=", "{", "\"Shards\"", ":", "[", "]", "}", "request", "=", "{", "\"StreamArn\"", ":", "stream_arn", ",", "\"ExclusiveStartShardId\"", ":", "f...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.get_shard_iterator
Wraps :func:`boto3.DynamoDBStreams.Client.get_shard_iterator`. :param str stream_arn: Stream arn. Usually :data:`Shard.stream_arn <bloop.stream.shard.Shard.stream_arn>`. :param str shard_id: Shard identifier. Usually :data:`Shard.shard_id <bloop.stream.shard.Shard.shard_id>`. :param str itera...
bloop/session.py
def get_shard_iterator(self, *, stream_arn, shard_id, iterator_type, sequence_number=None): """Wraps :func:`boto3.DynamoDBStreams.Client.get_shard_iterator`. :param str stream_arn: Stream arn. Usually :data:`Shard.stream_arn <bloop.stream.shard.Shard.stream_arn>`. :param str shard_id: Shard id...
def get_shard_iterator(self, *, stream_arn, shard_id, iterator_type, sequence_number=None): """Wraps :func:`boto3.DynamoDBStreams.Client.get_shard_iterator`. :param str stream_arn: Stream arn. Usually :data:`Shard.stream_arn <bloop.stream.shard.Shard.stream_arn>`. :param str shard_id: Shard id...
[ "Wraps", ":", "func", ":", "boto3", ".", "DynamoDBStreams", ".", "Client", ".", "get_shard_iterator", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L334-L360
[ "def", "get_shard_iterator", "(", "self", ",", "*", ",", "stream_arn", ",", "shard_id", ",", "iterator_type", ",", "sequence_number", "=", "None", ")", ":", "real_iterator_type", "=", "validate_stream_iterator_type", "(", "iterator_type", ")", "request", "=", "{",...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.get_stream_records
Wraps :func:`boto3.DynamoDBStreams.Client.get_records`. :param iterator_id: Iterator id. Usually :data:`Shard.iterator_id <bloop.stream.shard.Shard.iterator_id>`. :return: Dict with "Records" list (may be empty) and "NextShardIterator" str (may not exist). :rtype: dict :raises bloop.ex...
bloop/session.py
def get_stream_records(self, iterator_id): """Wraps :func:`boto3.DynamoDBStreams.Client.get_records`. :param iterator_id: Iterator id. Usually :data:`Shard.iterator_id <bloop.stream.shard.Shard.iterator_id>`. :return: Dict with "Records" list (may be empty) and "NextShardIterator" str (may not...
def get_stream_records(self, iterator_id): """Wraps :func:`boto3.DynamoDBStreams.Client.get_records`. :param iterator_id: Iterator id. Usually :data:`Shard.iterator_id <bloop.stream.shard.Shard.iterator_id>`. :return: Dict with "Records" list (may be empty) and "NextShardIterator" str (may not...
[ "Wraps", ":", "func", ":", "boto3", ".", "DynamoDBStreams", ".", "Client", ".", "get_records", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L362-L378
[ "def", "get_stream_records", "(", "self", ",", "iterator_id", ")", ":", "try", ":", "return", "self", ".", "stream_client", ".", "get_records", "(", "ShardIterator", "=", "iterator_id", ")", "except", "botocore", ".", "exceptions", ".", "ClientError", "as", "e...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.transaction_read
Wraps :func:`boto3.DynamoDB.Client.db.transact_get_items`. :param items: Unpacked into "TransactionItems" for :func:`boto3.DynamoDB.Client.transact_get_items` :raises bloop.exceptions.TransactionCanceled: if the transaction was canceled. :return: Dict with "Records" list
bloop/session.py
def transaction_read(self, items): """ Wraps :func:`boto3.DynamoDB.Client.db.transact_get_items`. :param items: Unpacked into "TransactionItems" for :func:`boto3.DynamoDB.Client.transact_get_items` :raises bloop.exceptions.TransactionCanceled: if the transaction was canceled. :r...
def transaction_read(self, items): """ Wraps :func:`boto3.DynamoDB.Client.db.transact_get_items`. :param items: Unpacked into "TransactionItems" for :func:`boto3.DynamoDB.Client.transact_get_items` :raises bloop.exceptions.TransactionCanceled: if the transaction was canceled. :r...
[ "Wraps", ":", "func", ":", "boto3", ".", "DynamoDB", ".", "Client", ".", "db", ".", "transact_get_items", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L380-L393
[ "def", "transaction_read", "(", "self", ",", "items", ")", ":", "try", ":", "return", "self", ".", "dynamodb_client", ".", "transact_get_items", "(", "TransactItems", "=", "items", ")", "except", "botocore", ".", "exceptions", ".", "ClientError", "as", "error"...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SessionWrapper.transaction_write
Wraps :func:`boto3.DynamoDB.Client.db.transact_write_items`. :param items: Unpacked into "TransactionItems" for :func:`boto3.DynamoDB.Client.transact_write_items` :param client_request_token: Idempotency token valid for 10 minutes from first use. Unpacked into "ClientRequestToken" :...
bloop/session.py
def transaction_write(self, items, client_request_token): """ Wraps :func:`boto3.DynamoDB.Client.db.transact_write_items`. :param items: Unpacked into "TransactionItems" for :func:`boto3.DynamoDB.Client.transact_write_items` :param client_request_token: Idempotency token valid for 10 mi...
def transaction_write(self, items, client_request_token): """ Wraps :func:`boto3.DynamoDB.Client.db.transact_write_items`. :param items: Unpacked into "TransactionItems" for :func:`boto3.DynamoDB.Client.transact_write_items` :param client_request_token: Idempotency token valid for 10 mi...
[ "Wraps", ":", "func", ":", "boto3", ".", "DynamoDB", ".", "Client", ".", "db", ".", "transact_write_items", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/session.py#L395-L412
[ "def", "transaction_write", "(", "self", ",", "items", ",", "client_request_token", ")", ":", "try", ":", "self", ".", "dynamodb_client", ".", "transact_write_items", "(", "TransactItems", "=", "items", ",", "ClientRequestToken", "=", "client_request_token", ")", ...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
check_hash_key
Only allows == against query_on.hash_key
bloop/search.py
def check_hash_key(query_on, key): """Only allows == against query_on.hash_key""" return ( isinstance(key, BaseCondition) and (key.operation == "==") and (key.column is query_on.hash_key) )
def check_hash_key(query_on, key): """Only allows == against query_on.hash_key""" return ( isinstance(key, BaseCondition) and (key.operation == "==") and (key.column is query_on.hash_key) )
[ "Only", "allows", "==", "against", "query_on", ".", "hash_key" ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L131-L137
[ "def", "check_hash_key", "(", "query_on", ",", "key", ")", ":", "return", "(", "isinstance", "(", "key", ",", "BaseCondition", ")", "and", "(", "key", ".", "operation", "==", "\"==\"", ")", "and", "(", "key", ".", "column", "is", "query_on", ".", "hash...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
check_range_key
BeginsWith, Between, or any Comparison except '!=' against query_on.range_key
bloop/search.py
def check_range_key(query_on, key): """BeginsWith, Between, or any Comparison except '!=' against query_on.range_key""" return ( isinstance(key, BaseCondition) and key.operation in ("begins_with", "between", "<", ">", "<=", ">=", "==") and key.column is query_on.range_key )
def check_range_key(query_on, key): """BeginsWith, Between, or any Comparison except '!=' against query_on.range_key""" return ( isinstance(key, BaseCondition) and key.operation in ("begins_with", "between", "<", ">", "<=", ">=", "==") and key.column is query_on.range_key )
[ "BeginsWith", "Between", "or", "any", "Comparison", "except", "!", "=", "against", "query_on", ".", "range_key" ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L140-L146
[ "def", "check_range_key", "(", "query_on", ",", "key", ")", ":", "return", "(", "isinstance", "(", "key", ",", "BaseCondition", ")", "and", "key", ".", "operation", "in", "(", "\"begins_with\"", ",", "\"between\"", ",", "\"<\"", ",", "\">\"", ",", "\"<=\""...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
Search.prepare
Constructs a :class:`~bloop.search.PreparedSearch`.
bloop/search.py
def prepare(self): """Constructs a :class:`~bloop.search.PreparedSearch`.""" p = PreparedSearch() p.prepare( engine=self.engine, mode=self.mode, model=self.model, index=self.index, key=self.key, filter=self.filter, ...
def prepare(self): """Constructs a :class:`~bloop.search.PreparedSearch`.""" p = PreparedSearch() p.prepare( engine=self.engine, mode=self.mode, model=self.model, index=self.index, key=self.key, filter=self.filter, ...
[ "Constructs", "a", ":", "class", ":", "~bloop", ".", "search", ".", "PreparedSearch", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L200-L215
[ "def", "prepare", "(", "self", ")", ":", "p", "=", "PreparedSearch", "(", ")", "p", ".", "prepare", "(", "engine", "=", "self", ".", "engine", ",", "mode", "=", "self", ".", "mode", ",", "model", "=", "self", ".", "model", ",", "index", "=", "sel...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
PreparedSearch.prepare
Validates the search parameters and builds the base request dict for each Query/Scan call.
bloop/search.py
def prepare( self, engine=None, mode=None, model=None, index=None, key=None, filter=None, projection=None, consistent=None, forward=None, parallel=None): """Validates the search parameters and builds the base request dict for each Query/Scan call.""" self.prepare_iterator_cls(en...
def prepare( self, engine=None, mode=None, model=None, index=None, key=None, filter=None, projection=None, consistent=None, forward=None, parallel=None): """Validates the search parameters and builds the base request dict for each Query/Scan call.""" self.prepare_iterator_cls(en...
[ "Validates", "the", "search", "parameters", "and", "builds", "the", "base", "request", "dict", "for", "each", "Query", "/", "Scan", "call", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L245-L257
[ "def", "prepare", "(", "self", ",", "engine", "=", "None", ",", "mode", "=", "None", ",", "model", "=", "None", ",", "index", "=", "None", ",", "key", "=", "None", ",", "filter", "=", "None", ",", "projection", "=", "None", ",", "consistent", "=", ...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SearchIterator.count
Number of items that have been loaded from DynamoDB so far, including buffered items.
bloop/search.py
def count(self): """Number of items that have been loaded from DynamoDB so far, including buffered items.""" if self.request["Select"] == "COUNT": while not self.exhausted: next(self, None) return self._count
def count(self): """Number of items that have been loaded from DynamoDB so far, including buffered items.""" if self.request["Select"] == "COUNT": while not self.exhausted: next(self, None) return self._count
[ "Number", "of", "items", "that", "have", "been", "loaded", "from", "DynamoDB", "so", "far", "including", "buffered", "items", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L366-L371
[ "def", "count", "(", "self", ")", ":", "if", "self", ".", "request", "[", "\"Select\"", "]", "==", "\"COUNT\"", ":", "while", "not", "self", ".", "exhausted", ":", "next", "(", "self", ",", "None", ")", "return", "self", ".", "_count" ]
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SearchIterator.scanned
Number of items that DynamoDB evaluated, before any filter was applied.
bloop/search.py
def scanned(self): """Number of items that DynamoDB evaluated, before any filter was applied.""" if self.request["Select"] == "COUNT": while not self.exhausted: next(self, None) return self._scanned
def scanned(self): """Number of items that DynamoDB evaluated, before any filter was applied.""" if self.request["Select"] == "COUNT": while not self.exhausted: next(self, None) return self._scanned
[ "Number", "of", "items", "that", "DynamoDB", "evaluated", "before", "any", "filter", "was", "applied", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L374-L379
[ "def", "scanned", "(", "self", ")", ":", "if", "self", ".", "request", "[", "\"Select\"", "]", "==", "\"COUNT\"", ":", "while", "not", "self", ".", "exhausted", ":", "next", "(", "self", ",", "None", ")", "return", "self", ".", "_scanned" ]
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SearchIterator.first
Return the first result. If there are no results, raises :exc:`~bloop.exceptions.ConstraintViolation`. :return: The first result. :raises bloop.exceptions.ConstraintViolation: No results.
bloop/search.py
def first(self): """Return the first result. If there are no results, raises :exc:`~bloop.exceptions.ConstraintViolation`. :return: The first result. :raises bloop.exceptions.ConstraintViolation: No results. """ self.reset() value = next(self, None) if value is ...
def first(self): """Return the first result. If there are no results, raises :exc:`~bloop.exceptions.ConstraintViolation`. :return: The first result. :raises bloop.exceptions.ConstraintViolation: No results. """ self.reset() value = next(self, None) if value is ...
[ "Return", "the", "first", "result", ".", "If", "there", "are", "no", "results", "raises", ":", "exc", ":", "~bloop", ".", "exceptions", ".", "ConstraintViolation", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L389-L399
[ "def", "first", "(", "self", ")", ":", "self", ".", "reset", "(", ")", "value", "=", "next", "(", "self", ",", "None", ")", "if", "value", "is", "None", ":", "raise", "ConstraintViolation", "(", "\"{} did not find any results.\"", ".", "format", "(", "se...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SearchIterator.one
Return the unique result. If there is not exactly one result, raises :exc:`~bloop.exceptions.ConstraintViolation`. :return: The unique result. :raises bloop.exceptions.ConstraintViolation: Not exactly one result.
bloop/search.py
def one(self): """Return the unique result. If there is not exactly one result, raises :exc:`~bloop.exceptions.ConstraintViolation`. :return: The unique result. :raises bloop.exceptions.ConstraintViolation: Not exactly one result. """ first = self.first() second...
def one(self): """Return the unique result. If there is not exactly one result, raises :exc:`~bloop.exceptions.ConstraintViolation`. :return: The unique result. :raises bloop.exceptions.ConstraintViolation: Not exactly one result. """ first = self.first() second...
[ "Return", "the", "unique", "result", ".", "If", "there", "is", "not", "exactly", "one", "result", "raises", ":", "exc", ":", "~bloop", ".", "exceptions", ".", "ConstraintViolation", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L401-L412
[ "def", "one", "(", "self", ")", ":", "first", "=", "self", ".", "first", "(", ")", "second", "=", "next", "(", "self", ",", "None", ")", "if", "second", "is", "not", "None", ":", "raise", "ConstraintViolation", "(", "\"{} found more than one result.\"", ...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
SearchIterator.reset
Reset to the initial state, clearing the buffer and zeroing count and scanned.
bloop/search.py
def reset(self): """Reset to the initial state, clearing the buffer and zeroing count and scanned.""" self.buffer.clear() self._count = 0 self._scanned = 0 self._exhausted = False self.request.pop("ExclusiveStartKey", None)
def reset(self): """Reset to the initial state, clearing the buffer and zeroing count and scanned.""" self.buffer.clear() self._count = 0 self._scanned = 0 self._exhausted = False self.request.pop("ExclusiveStartKey", None)
[ "Reset", "to", "the", "initial", "state", "clearing", "the", "buffer", "and", "zeroing", "count", "and", "scanned", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L414-L420
[ "def", "reset", "(", "self", ")", ":", "self", ".", "buffer", ".", "clear", "(", ")", "self", ".", "_count", "=", "0", "self", ".", "_scanned", "=", "0", "self", ".", "_exhausted", "=", "False", "self", ".", "request", ".", "pop", "(", "\"Exclusive...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
TxType.by_alias
get a type by the common bloop operation name: get/check/delete/save
bloop/transactions.py
def by_alias(cls, name: str) -> "TxType": """get a type by the common bloop operation name: get/check/delete/save""" return { "get": TxType.Get, "check": TxType.Check, "delete": TxType.Delete, "save": TxType.Update, }[name]
def by_alias(cls, name: str) -> "TxType": """get a type by the common bloop operation name: get/check/delete/save""" return { "get": TxType.Get, "check": TxType.Check, "delete": TxType.Delete, "save": TxType.Update, }[name]
[ "get", "a", "type", "by", "the", "common", "bloop", "operation", "name", ":", "get", "/", "check", "/", "delete", "/", "save" ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/transactions.py#L36-L43
[ "def", "by_alias", "(", "cls", ",", "name", ":", "str", ")", "->", "\"TxType\"", ":", "return", "{", "\"get\"", ":", "TxType", ".", "Get", ",", "\"check\"", ":", "TxType", ".", "Check", ",", "\"delete\"", ":", "TxType", ".", "Delete", ",", "\"save\"", ...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
Transaction.prepare
Create a new PreparedTransaction that can be committed. This is called automatically when exiting the transaction as a context: .. code-block:: python >>> engine = Engine() >>> tx = WriteTransaction(engine) >>> prepared = tx.prepare() >>> prepared.commi...
bloop/transactions.py
def prepare(self): """ Create a new PreparedTransaction that can be committed. This is called automatically when exiting the transaction as a context: .. code-block:: python >>> engine = Engine() >>> tx = WriteTransaction(engine) >>> prepared = tx.p...
def prepare(self): """ Create a new PreparedTransaction that can be committed. This is called automatically when exiting the transaction as a context: .. code-block:: python >>> engine = Engine() >>> tx = WriteTransaction(engine) >>> prepared = tx.p...
[ "Create", "a", "new", "PreparedTransaction", "that", "can", "be", "committed", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/transactions.py#L135-L162
[ "def", "prepare", "(", "self", ")", ":", "tx", "=", "PreparedTransaction", "(", ")", "tx", ".", "prepare", "(", "engine", "=", "self", ".", "engine", ",", "mode", "=", "self", ".", "mode", ",", "items", "=", "self", ".", "_items", ",", ")", "return...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
PreparedTransaction.prepare
Create a unique transaction id and dumps the items into a cached request object.
bloop/transactions.py
def prepare(self, engine, mode, items) -> None: """ Create a unique transaction id and dumps the items into a cached request object. """ self.tx_id = str(uuid.uuid4()).replace("-", "") self.engine = engine self.mode = mode self.items = items self._prepare_...
def prepare(self, engine, mode, items) -> None: """ Create a unique transaction id and dumps the items into a cached request object. """ self.tx_id = str(uuid.uuid4()).replace("-", "") self.engine = engine self.mode = mode self.items = items self._prepare_...
[ "Create", "a", "unique", "transaction", "id", "and", "dumps", "the", "items", "into", "a", "cached", "request", "object", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/transactions.py#L186-L194
[ "def", "prepare", "(", "self", ",", "engine", ",", "mode", ",", "items", ")", "->", "None", ":", "self", ".", "tx_id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", ".", "replace", "(", "\"-\"", ",", "\"\"", ")", "self", ".", "engine", ...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
PreparedTransaction.commit
Commit the transaction with a fixed transaction id. A read transaction can call commit() any number of times, while a write transaction can only use the same tx_id for 10 minutes from the first call.
bloop/transactions.py
def commit(self) -> None: """ Commit the transaction with a fixed transaction id. A read transaction can call commit() any number of times, while a write transaction can only use the same tx_id for 10 minutes from the first call. """ now = datetime.now(timezone.utc) ...
def commit(self) -> None: """ Commit the transaction with a fixed transaction id. A read transaction can call commit() any number of times, while a write transaction can only use the same tx_id for 10 minutes from the first call. """ now = datetime.now(timezone.utc) ...
[ "Commit", "the", "transaction", "with", "a", "fixed", "transaction", "id", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/transactions.py#L213-L233
[ "def", "commit", "(", "self", ")", "->", "None", ":", "now", "=", "datetime", ".", "now", "(", "timezone", ".", "utc", ")", "if", "self", ".", "first_commit_at", "is", "None", ":", "self", ".", "first_commit_at", "=", "now", "if", "self", ".", "mode"...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
ReadTransaction.load
Add one or more objects to be loaded in this transaction. At most 10 items can be loaded in the same transaction. All objects will be loaded each time you call commit(). :param objs: Objects to add to the set that are loaded in this transaction. :return: this transaction for chaining...
bloop/transactions.py
def load(self, *objs) -> "ReadTransaction": """ Add one or more objects to be loaded in this transaction. At most 10 items can be loaded in the same transaction. All objects will be loaded each time you call commit(). :param objs: Objects to add to the set that are loaded in ...
def load(self, *objs) -> "ReadTransaction": """ Add one or more objects to be loaded in this transaction. At most 10 items can be loaded in the same transaction. All objects will be loaded each time you call commit(). :param objs: Objects to add to the set that are loaded in ...
[ "Add", "one", "or", "more", "objects", "to", "be", "loaded", "in", "this", "transaction", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/transactions.py#L267-L280
[ "def", "load", "(", "self", ",", "*", "objs", ")", "->", "\"ReadTransaction\"", ":", "self", ".", "_extend", "(", "[", "TxItem", ".", "new", "(", "\"get\"", ",", "obj", ")", "for", "obj", "in", "objs", "]", ")", "return", "self" ]
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
WriteTransaction.check
Add a condition which must be met for the transaction to commit. While the condition is checked against the provided object, that object will not be modified. It is only used to provide the hash and range key to apply the condition to. At most 10 items can be checked, saved, or deleted in the...
bloop/transactions.py
def check(self, obj, condition) -> "WriteTransaction": """ Add a condition which must be met for the transaction to commit. While the condition is checked against the provided object, that object will not be modified. It is only used to provide the hash and range key to apply the condi...
def check(self, obj, condition) -> "WriteTransaction": """ Add a condition which must be met for the transaction to commit. While the condition is checked against the provided object, that object will not be modified. It is only used to provide the hash and range key to apply the condi...
[ "Add", "a", "condition", "which", "must", "be", "met", "for", "the", "transaction", "to", "commit", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/transactions.py#L300-L317
[ "def", "check", "(", "self", ",", "obj", ",", "condition", ")", "->", "\"WriteTransaction\"", ":", "self", ".", "_extend", "(", "[", "TxItem", ".", "new", "(", "\"check\"", ",", "obj", ",", "condition", ")", "]", ")", "return", "self" ]
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
WriteTransaction.save
Add one or more objects to be saved in this transaction. At most 10 items can be checked, saved, or deleted in the same transaction. The same idempotency token will be used for a single prepared transaction, which allows you to safely call commit on the PreparedCommit object multiple times. ...
bloop/transactions.py
def save(self, *objs, condition=None, atomic=False) -> "WriteTransaction": """ Add one or more objects to be saved in this transaction. At most 10 items can be checked, saved, or deleted in the same transaction. The same idempotency token will be used for a single prepared transaction,...
def save(self, *objs, condition=None, atomic=False) -> "WriteTransaction": """ Add one or more objects to be saved in this transaction. At most 10 items can be checked, saved, or deleted in the same transaction. The same idempotency token will be used for a single prepared transaction,...
[ "Add", "one", "or", "more", "objects", "to", "be", "saved", "in", "this", "transaction", "." ]
numberoverzero/bloop
python
https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/transactions.py#L319-L333
[ "def", "save", "(", "self", ",", "*", "objs", ",", "condition", "=", "None", ",", "atomic", "=", "False", ")", "->", "\"WriteTransaction\"", ":", "self", ".", "_extend", "(", "[", "TxItem", ".", "new", "(", "\"save\"", ",", "obj", ",", "condition", "...
4c95f5a0ff0802443a1c258bfaccecd1758363e7
train
CubeDimensionTranscoder.encode
Produces a numpy array of integers which encode the supplied cube dimensions.
montblanc/impl/rime/tensorflow/cube_dim_transcoder.py
def encode(self, cube_dimensions): """ Produces a numpy array of integers which encode the supplied cube dimensions. """ return np.asarray([getattr(cube_dimensions[d], s) for d in self._dimensions for s in self._schema], dtype=np.int32)
def encode(self, cube_dimensions): """ Produces a numpy array of integers which encode the supplied cube dimensions. """ return np.asarray([getattr(cube_dimensions[d], s) for d in self._dimensions for s in self._schema], dtype=np.int32)
[ "Produces", "a", "numpy", "array", "of", "integers", "which", "encode", "the", "supplied", "cube", "dimensions", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/cube_dim_transcoder.py#L43-L51
[ "def", "encode", "(", "self", ",", "cube_dimensions", ")", ":", "return", "np", ".", "asarray", "(", "[", "getattr", "(", "cube_dimensions", "[", "d", "]", ",", "s", ")", "for", "d", "in", "self", ".", "_dimensions", "for", "s", "in", "self", ".", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
CubeDimensionTranscoder.decode
Produce a list of dictionaries for each dimension in this transcoder
montblanc/impl/rime/tensorflow/cube_dim_transcoder.py
def decode(self, descriptor): """ Produce a list of dictionaries for each dimension in this transcoder """ i = iter(descriptor) n = len(self._schema) # Add the name key to our schema schema = self._schema + ('name',) # For each dimensions, generator takes n items off ite...
def decode(self, descriptor): """ Produce a list of dictionaries for each dimension in this transcoder """ i = iter(descriptor) n = len(self._schema) # Add the name key to our schema schema = self._schema + ('name',) # For each dimensions, generator takes n items off ite...
[ "Produce", "a", "list", "of", "dictionaries", "for", "each", "dimension", "in", "this", "transcoder" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/cube_dim_transcoder.py#L53-L67
[ "def", "decode", "(", "self", ",", "descriptor", ")", ":", "i", "=", "iter", "(", "descriptor", ")", "n", "=", "len", "(", "self", ".", "_schema", ")", "# Add the name key to our schema", "schema", "=", "self", ".", "_schema", "+", "(", "'name'", ",", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
dl_cub
Download cub archive from cub_url and store it in cub_archive_name
install/cub.py
def dl_cub(cub_url, cub_archive_name): """ Download cub archive from cub_url and store it in cub_archive_name """ with open(cub_archive_name, 'wb') as f: remote_file = urllib2.urlopen(cub_url) meta = remote_file.info() # The server may provide us with the size of the file. cl_he...
def dl_cub(cub_url, cub_archive_name): """ Download cub archive from cub_url and store it in cub_archive_name """ with open(cub_archive_name, 'wb') as f: remote_file = urllib2.urlopen(cub_url) meta = remote_file.info() # The server may provide us with the size of the file. cl_he...
[ "Download", "cub", "archive", "from", "cub_url", "and", "store", "it", "in", "cub_archive_name" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/cub.py#L33-L63
[ "def", "dl_cub", "(", "cub_url", ",", "cub_archive_name", ")", ":", "with", "open", "(", "cub_archive_name", ",", "'wb'", ")", "as", "f", ":", "remote_file", "=", "urllib2", ".", "urlopen", "(", "cub_url", ")", "meta", "=", "remote_file", ".", "info", "(...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
sha_hash_file
Compute the SHA1 hash of filename
install/cub.py
def sha_hash_file(filename): """ Compute the SHA1 hash of filename """ hash_sha = hashlib.sha1() with open(filename, 'rb') as f: for chunk in iter(lambda: f.read(1024*1024), b""): hash_sha.update(chunk) return hash_sha.hexdigest()
def sha_hash_file(filename): """ Compute the SHA1 hash of filename """ hash_sha = hashlib.sha1() with open(filename, 'rb') as f: for chunk in iter(lambda: f.read(1024*1024), b""): hash_sha.update(chunk) return hash_sha.hexdigest()
[ "Compute", "the", "SHA1", "hash", "of", "filename" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/cub.py#L65-L73
[ "def", "sha_hash_file", "(", "filename", ")", ":", "hash_sha", "=", "hashlib", ".", "sha1", "(", ")", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "for", "chunk", "in", "iter", "(", "lambda", ":", "f", ".", "read", "(", "1024"...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
install_cub
Downloads and installs cub into mb_inc_path
install/cub.py
def install_cub(mb_inc_path): """ Downloads and installs cub into mb_inc_path """ cub_url = 'https://github.com/NVlabs/cub/archive/1.6.4.zip' cub_sha_hash = '0d5659200132c2576be0b3959383fa756de6105d' cub_version_str = 'Current release: v1.6.4 (12/06/2016)' cub_zip_file = 'cub.zip' cub_zip_dir = ...
def install_cub(mb_inc_path): """ Downloads and installs cub into mb_inc_path """ cub_url = 'https://github.com/NVlabs/cub/archive/1.6.4.zip' cub_sha_hash = '0d5659200132c2576be0b3959383fa756de6105d' cub_version_str = 'Current release: v1.6.4 (12/06/2016)' cub_zip_file = 'cub.zip' cub_zip_dir = ...
[ "Downloads", "and", "installs", "cub", "into", "mb_inc_path" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/cub.py#L97-L161
[ "def", "install_cub", "(", "mb_inc_path", ")", ":", "cub_url", "=", "'https://github.com/NVlabs/cub/archive/1.6.4.zip'", "cub_sha_hash", "=", "'0d5659200132c2576be0b3959383fa756de6105d'", "cub_version_str", "=", "'Current release: v1.6.4 (12/06/2016)'", "cub_zip_file", "=", "'cub.z...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
cuda_architecture_flags
Emit a list of architecture flags for each CUDA device found ['--gpu-architecture=sm_30', '--gpu-architecture=sm_52']
install/tensorflow_ops_ext.py
def cuda_architecture_flags(device_info): """ Emit a list of architecture flags for each CUDA device found ['--gpu-architecture=sm_30', '--gpu-architecture=sm_52'] """ # Figure out the necessary device architectures if len(device_info['devices']) == 0: archs = ['--gpu-architecture=sm_30'...
def cuda_architecture_flags(device_info): """ Emit a list of architecture flags for each CUDA device found ['--gpu-architecture=sm_30', '--gpu-architecture=sm_52'] """ # Figure out the necessary device architectures if len(device_info['devices']) == 0: archs = ['--gpu-architecture=sm_30'...
[ "Emit", "a", "list", "of", "architecture", "flags", "for", "each", "CUDA", "device", "found", "[", "--", "gpu", "-", "architecture", "=", "sm_30", "--", "gpu", "-", "architecture", "=", "sm_52", "]" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/tensorflow_ops_ext.py#L63-L80
[ "def", "cuda_architecture_flags", "(", "device_info", ")", ":", "# Figure out the necessary device architectures", "if", "len", "(", "device_info", "[", "'devices'", "]", ")", "==", "0", ":", "archs", "=", "[", "'--gpu-architecture=sm_30'", "]", "log", ".", "info", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
create_tensorflow_extension
Create an extension that builds the custom tensorflow ops
install/tensorflow_ops_ext.py
def create_tensorflow_extension(nvcc_settings, device_info): """ Create an extension that builds the custom tensorflow ops """ import tensorflow as tf import glob use_cuda = (bool(nvcc_settings['cuda_available']) and tf.test.is_built_with_cuda()) # Source and includes source_path = os....
def create_tensorflow_extension(nvcc_settings, device_info): """ Create an extension that builds the custom tensorflow ops """ import tensorflow as tf import glob use_cuda = (bool(nvcc_settings['cuda_available']) and tf.test.is_built_with_cuda()) # Source and includes source_path = os....
[ "Create", "an", "extension", "that", "builds", "the", "custom", "tensorflow", "ops" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/tensorflow_ops_ext.py#L82-L152
[ "def", "create_tensorflow_extension", "(", "nvcc_settings", ",", "device_info", ")", ":", "import", "tensorflow", "as", "tf", "import", "glob", "use_cuda", "=", "(", "bool", "(", "nvcc_settings", "[", "'cuda_available'", "]", ")", "and", "tf", ".", "test", "."...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
CustomSourceProvider.updated_dimensions
Inform montblanc about dimension sizes
montblanc/examples/standalone.py
def updated_dimensions(self): """ Inform montblanc about dimension sizes """ return [("ntime", args.ntime), # Timesteps ("nchan", args.nchan), # Channels ("na", args.na), # Antenna ("npsrc", len(lm_coords))]
def updated_dimensions(self): """ Inform montblanc about dimension sizes """ return [("ntime", args.ntime), # Timesteps ("nchan", args.nchan), # Channels ("na", args.na), # Antenna ("npsrc", len(lm_coords))]
[ "Inform", "montblanc", "about", "dimension", "sizes" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/examples/standalone.py#L45-L50
[ "def", "updated_dimensions", "(", "self", ")", ":", "return", "[", "(", "\"ntime\"", ",", "args", ".", "ntime", ")", ",", "# Timesteps", "(", "\"nchan\"", ",", "args", ".", "nchan", ")", ",", "# Channels", "(", "\"na\"", ",", "args", ".", "na", ")", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
CustomSourceProvider.point_lm
Supply point source lm coordinates to montblanc
montblanc/examples/standalone.py
def point_lm(self, context): """ Supply point source lm coordinates to montblanc """ # Shape (npsrc, 2) (ls, us), _ = context.array_extents(context.name) return np.asarray(lm_coords[ls:us], dtype=context.dtype)
def point_lm(self, context): """ Supply point source lm coordinates to montblanc """ # Shape (npsrc, 2) (ls, us), _ = context.array_extents(context.name) return np.asarray(lm_coords[ls:us], dtype=context.dtype)
[ "Supply", "point", "source", "lm", "coordinates", "to", "montblanc" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/examples/standalone.py#L52-L57
[ "def", "point_lm", "(", "self", ",", "context", ")", ":", "# Shape (npsrc, 2)", "(", "ls", ",", "us", ")", ",", "_", "=", "context", ".", "array_extents", "(", "context", ".", "name", ")", "return", "np", ".", "asarray", "(", "lm_coords", "[", "ls", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
CustomSourceProvider.point_stokes
Supply point source stokes parameters to montblanc
montblanc/examples/standalone.py
def point_stokes(self, context): """ Supply point source stokes parameters to montblanc """ # Shape (npsrc, ntime, 4) (ls, us), (lt, ut), (l, u) = context.array_extents(context.name) data = np.empty(context.shape, context.dtype) data[ls:us,:,l:u] = np.asarray(lm_stokes)[ls:us,N...
def point_stokes(self, context): """ Supply point source stokes parameters to montblanc """ # Shape (npsrc, ntime, 4) (ls, us), (lt, ut), (l, u) = context.array_extents(context.name) data = np.empty(context.shape, context.dtype) data[ls:us,:,l:u] = np.asarray(lm_stokes)[ls:us,N...
[ "Supply", "point", "source", "stokes", "parameters", "to", "montblanc" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/examples/standalone.py#L59-L67
[ "def", "point_stokes", "(", "self", ",", "context", ")", ":", "# Shape (npsrc, ntime, 4)", "(", "ls", ",", "us", ")", ",", "(", "lt", ",", "ut", ")", ",", "(", "l", ",", "u", ")", "=", "context", ".", "array_extents", "(", "context", ".", "name", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
CustomSourceProvider.uvw
Supply UVW antenna coordinates to montblanc
montblanc/examples/standalone.py
def uvw(self, context): """ Supply UVW antenna coordinates to montblanc """ # Shape (ntime, na, 3) (lt, ut), (la, ua), (l, u) = context.array_extents(context.name) # Create empty UVW coordinates data = np.empty(context.shape, context.dtype) data[:,:,0] = np.arange(la+1,...
def uvw(self, context): """ Supply UVW antenna coordinates to montblanc """ # Shape (ntime, na, 3) (lt, ut), (la, ua), (l, u) = context.array_extents(context.name) # Create empty UVW coordinates data = np.empty(context.shape, context.dtype) data[:,:,0] = np.arange(la+1,...
[ "Supply", "UVW", "antenna", "coordinates", "to", "montblanc" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/examples/standalone.py#L69-L81
[ "def", "uvw", "(", "self", ",", "context", ")", ":", "# Shape (ntime, na, 3)", "(", "lt", ",", "ut", ")", ",", "(", "la", ",", "ua", ")", ",", "(", "l", ",", "u", ")", "=", "context", ".", "array_extents", "(", "context", ".", "name", ")", "# Cre...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
reinitialize_command
Monkeypatch distutils.Distribution.reinitialize_command() to match behavior of Distribution.get_command_obj() This fixes a problem where 'pip install -e' does not reinitialise options using the setup(options={...}) variable for the build_ext command. This also effects other option sourcs such as setup.c...
setup.py
def reinitialize_command(self, command, reinit_subcommands): """ Monkeypatch distutils.Distribution.reinitialize_command() to match behavior of Distribution.get_command_obj() This fixes a problem where 'pip install -e' does not reinitialise options using the setup(options={...}) variable for the bui...
def reinitialize_command(self, command, reinit_subcommands): """ Monkeypatch distutils.Distribution.reinitialize_command() to match behavior of Distribution.get_command_obj() This fixes a problem where 'pip install -e' does not reinitialise options using the setup(options={...}) variable for the bui...
[ "Monkeypatch", "distutils", ".", "Distribution", ".", "reinitialize_command", "()", "to", "match", "behavior", "of", "Distribution", ".", "get_command_obj", "()", "This", "fixes", "a", "problem", "where", "pip", "install", "-", "e", "does", "not", "reinitialise", ...
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/setup.py#L64-L79
[ "def", "reinitialize_command", "(", "self", ",", "command", ",", "reinit_subcommands", ")", ":", "cmd_obj", "=", "_DISTUTILS_REINIT", "(", "self", ",", "command", ",", "reinit_subcommands", ")", "options", "=", "self", ".", "command_options", ".", "get", "(", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
nr_of_baselines
Compute the number of baselines for the given number of antenna. Can specify whether auto-correlations should be taken into account
montblanc/util/__init__.py
def nr_of_baselines(na, auto_correlations=False): """ Compute the number of baselines for the given number of antenna. Can specify whether auto-correlations should be taken into account """ m = (na-1) if auto_correlations is False else (na+1) return (na*m)//2
def nr_of_baselines(na, auto_correlations=False): """ Compute the number of baselines for the given number of antenna. Can specify whether auto-correlations should be taken into account """ m = (na-1) if auto_correlations is False else (na+1) return (na*m)//2
[ "Compute", "the", "number", "of", "baselines", "for", "the", "given", "number", "of", "antenna", ".", "Can", "specify", "whether", "auto", "-", "correlations", "should", "be", "taken", "into", "account" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L43-L51
[ "def", "nr_of_baselines", "(", "na", ",", "auto_correlations", "=", "False", ")", ":", "m", "=", "(", "na", "-", "1", ")", "if", "auto_correlations", "is", "False", "else", "(", "na", "+", "1", ")", "return", "(", "na", "*", "m", ")", "//", "2" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
nr_of_antenna
Compute the number of antenna for the given number of baselines. Can specify whether auto-correlations should be taken into account
montblanc/util/__init__.py
def nr_of_antenna(nbl, auto_correlations=False): """ Compute the number of antenna for the given number of baselines. Can specify whether auto-correlations should be taken into account """ t = 1 if auto_correlations is False else -1 return int(t + math.sqrt(1 + 8*nbl)) // 2
def nr_of_antenna(nbl, auto_correlations=False): """ Compute the number of antenna for the given number of baselines. Can specify whether auto-correlations should be taken into account """ t = 1 if auto_correlations is False else -1 return int(t + math.sqrt(1 + 8*nbl)) // 2
[ "Compute", "the", "number", "of", "antenna", "for", "the", "given", "number", "of", "baselines", ".", "Can", "specify", "whether", "auto", "-", "correlations", "should", "be", "taken", "into", "account" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L53-L61
[ "def", "nr_of_antenna", "(", "nbl", ",", "auto_correlations", "=", "False", ")", ":", "t", "=", "1", "if", "auto_correlations", "is", "False", "else", "-", "1", "return", "int", "(", "t", "+", "math", ".", "sqrt", "(", "1", "+", "8", "*", "nbl", ")...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
array_bytes
Estimates the memory in bytes required for an array of the supplied shape and dtype
montblanc/util/__init__.py
def array_bytes(shape, dtype): """ Estimates the memory in bytes required for an array of the supplied shape and dtype """ return np.product(shape)*np.dtype(dtype).itemsize
def array_bytes(shape, dtype): """ Estimates the memory in bytes required for an array of the supplied shape and dtype """ return np.product(shape)*np.dtype(dtype).itemsize
[ "Estimates", "the", "memory", "in", "bytes", "required", "for", "an", "array", "of", "the", "supplied", "shape", "and", "dtype" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L79-L81
[ "def", "array_bytes", "(", "shape", ",", "dtype", ")", ":", "return", "np", ".", "product", "(", "shape", ")", "*", "np", ".", "dtype", "(", "dtype", ")", ".", "itemsize" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
random_like
Returns a random array of the same shape and type as the supplied array argument, or the supplied shape and dtype
montblanc/util/__init__.py
def random_like(ary=None, shape=None, dtype=None): """ Returns a random array of the same shape and type as the supplied array argument, or the supplied shape and dtype """ if ary is not None: shape, dtype = ary.shape, ary.dtype elif shape is None or dtype is None: raise ValueErr...
def random_like(ary=None, shape=None, dtype=None): """ Returns a random array of the same shape and type as the supplied array argument, or the supplied shape and dtype """ if ary is not None: shape, dtype = ary.shape, ary.dtype elif shape is None or dtype is None: raise ValueErr...
[ "Returns", "a", "random", "array", "of", "the", "same", "shape", "and", "type", "as", "the", "supplied", "array", "argument", "or", "the", "supplied", "shape", "and", "dtype" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L96-L113
[ "def", "random_like", "(", "ary", "=", "None", ",", "shape", "=", "None", ",", "dtype", "=", "None", ")", ":", "if", "ary", "is", "not", "None", ":", "shape", ",", "dtype", "=", "ary", ".", "shape", ",", "ary", ".", "dtype", "elif", "shape", "is"...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
flatten
Return a flatten version of the nested argument
montblanc/util/__init__.py
def flatten(nested): """ Return a flatten version of the nested argument """ flat_return = list() def __inner_flat(nested,flat): for i in nested: __inner_flat(i, flat) if isinstance(i, list) else flat.append(i) return flat __inner_flat(nested,flat_return) return flat_r...
def flatten(nested): """ Return a flatten version of the nested argument """ flat_return = list() def __inner_flat(nested,flat): for i in nested: __inner_flat(i, flat) if isinstance(i, list) else flat.append(i) return flat __inner_flat(nested,flat_return) return flat_r...
[ "Return", "a", "flatten", "version", "of", "the", "nested", "argument" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L115-L126
[ "def", "flatten", "(", "nested", ")", ":", "flat_return", "=", "list", "(", ")", "def", "__inner_flat", "(", "nested", ",", "flat", ")", ":", "for", "i", "in", "nested", ":", "__inner_flat", "(", "i", ",", "flat", ")", "if", "isinstance", "(", "i", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
dict_array_bytes
Return the number of bytes required by an array Arguments --------------- ary : dict Dictionary representation of an array template : dict A dictionary of key-values, used to replace any string values in the array with concrete integral values Returns ----------...
montblanc/util/__init__.py
def dict_array_bytes(ary, template): """ Return the number of bytes required by an array Arguments --------------- ary : dict Dictionary representation of an array template : dict A dictionary of key-values, used to replace any string values in the array with concrete in...
def dict_array_bytes(ary, template): """ Return the number of bytes required by an array Arguments --------------- ary : dict Dictionary representation of an array template : dict A dictionary of key-values, used to replace any string values in the array with concrete in...
[ "Return", "the", "number", "of", "bytes", "required", "by", "an", "array" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L128-L149
[ "def", "dict_array_bytes", "(", "ary", ",", "template", ")", ":", "shape", "=", "shape_from_str_tuple", "(", "ary", "[", "'shape'", "]", ",", "template", ")", "dtype", "=", "dtype_from_str", "(", "ary", "[", "'dtype'", "]", ",", "template", ")", "return", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
dict_array_bytes_required
Return the number of bytes required by a dictionary of arrays. Arguments --------------- arrays : list A list of dictionaries defining the arrays template : dict A dictionary of key-values, used to replace any string values in the arrays with concrete integral values...
montblanc/util/__init__.py
def dict_array_bytes_required(arrays, template): """ Return the number of bytes required by a dictionary of arrays. Arguments --------------- arrays : list A list of dictionaries defining the arrays template : dict A dictionary of key-values, used to replace any stri...
def dict_array_bytes_required(arrays, template): """ Return the number of bytes required by a dictionary of arrays. Arguments --------------- arrays : list A list of dictionaries defining the arrays template : dict A dictionary of key-values, used to replace any stri...
[ "Return", "the", "number", "of", "bytes", "required", "by", "a", "dictionary", "of", "arrays", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L151-L171
[ "def", "dict_array_bytes_required", "(", "arrays", ",", "template", ")", ":", "return", "np", ".", "sum", "(", "[", "dict_array_bytes", "(", "ary", ",", "template", ")", "for", "ary", "in", "arrays", "]", ")" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
viable_dim_config
Returns the number of timesteps possible, given the registered arrays and a memory budget defined by bytes_available Arguments ---------------- bytes_available : int The memory budget, or available number of bytes for solving the problem. arrays : list List of dictionaries d...
montblanc/util/__init__.py
def viable_dim_config(bytes_available, arrays, template, dim_ord, nsolvers=1): """ Returns the number of timesteps possible, given the registered arrays and a memory budget defined by bytes_available Arguments ---------------- bytes_available : int The memory budget, or availabl...
def viable_dim_config(bytes_available, arrays, template, dim_ord, nsolvers=1): """ Returns the number of timesteps possible, given the registered arrays and a memory budget defined by bytes_available Arguments ---------------- bytes_available : int The memory budget, or availabl...
[ "Returns", "the", "number", "of", "timesteps", "possible", "given", "the", "registered", "arrays", "and", "a", "memory", "budget", "defined", "by", "bytes_available" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L180-L299
[ "def", "viable_dim_config", "(", "bytes_available", ",", "arrays", ",", "template", ",", "dim_ord", ",", "nsolvers", "=", "1", ")", ":", "if", "not", "isinstance", "(", "dim_ord", ",", "list", ")", ":", "raise", "TypeError", "(", "'dim_ord should be a list'", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
shape_from_str_tuple
Substitutes string values in the supplied shape parameter with integer variables stored in a dictionary Parameters ---------- sshape : tuple/string composed of integers and strings. The strings should related to integral properties registered with this Solver object variables : dict...
montblanc/util/__init__.py
def shape_from_str_tuple(sshape, variables, ignore=None): """ Substitutes string values in the supplied shape parameter with integer variables stored in a dictionary Parameters ---------- sshape : tuple/string composed of integers and strings. The strings should related to integral prop...
def shape_from_str_tuple(sshape, variables, ignore=None): """ Substitutes string values in the supplied shape parameter with integer variables stored in a dictionary Parameters ---------- sshape : tuple/string composed of integers and strings. The strings should related to integral prop...
[ "Substitutes", "string", "values", "in", "the", "supplied", "shape", "parameter", "with", "integer", "variables", "stored", "in", "a", "dictionary" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L324-L352
[ "def", "shape_from_str_tuple", "(", "sshape", ",", "variables", ",", "ignore", "=", "None", ")", ":", "if", "ignore", "is", "None", ":", "ignore", "=", "[", "]", "if", "not", "isinstance", "(", "sshape", ",", "tuple", ")", "and", "not", "isinstance", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
shape_list
Shape a list of lists into the appropriate shape and data type
montblanc/util/__init__.py
def shape_list(l,shape,dtype): """ Shape a list of lists into the appropriate shape and data type """ return np.array(l, dtype=dtype).reshape(shape)
def shape_list(l,shape,dtype): """ Shape a list of lists into the appropriate shape and data type """ return np.array(l, dtype=dtype).reshape(shape)
[ "Shape", "a", "list", "of", "lists", "into", "the", "appropriate", "shape", "and", "data", "type" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L354-L356
[ "def", "shape_list", "(", "l", ",", "shape", ",", "dtype", ")", ":", "return", "np", ".", "array", "(", "l", ",", "dtype", "=", "dtype", ")", ".", "reshape", "(", "shape", ")" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
array_convert_function
Return a function defining the conversion process between two NumPy arrays of different shapes
montblanc/util/__init__.py
def array_convert_function(sshape_one, sshape_two, variables): """ Return a function defining the conversion process between two NumPy arrays of different shapes """ if not isinstance(sshape_one, tuple): sshape_one = (sshape_one,) if not isinstance(sshape_two, tuple): sshape_two = (sshape_two,) s_o...
def array_convert_function(sshape_one, sshape_two, variables): """ Return a function defining the conversion process between two NumPy arrays of different shapes """ if not isinstance(sshape_one, tuple): sshape_one = (sshape_one,) if not isinstance(sshape_two, tuple): sshape_two = (sshape_two,) s_o...
[ "Return", "a", "function", "defining", "the", "conversion", "process", "between", "two", "NumPy", "arrays", "of", "different", "shapes" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L358-L385
[ "def", "array_convert_function", "(", "sshape_one", ",", "sshape_two", ",", "variables", ")", ":", "if", "not", "isinstance", "(", "sshape_one", ",", "tuple", ")", ":", "sshape_one", "=", "(", "sshape_one", ",", ")", "if", "not", "isinstance", "(", "sshape_t...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
redistribute_threads
Redistribute threads from the Z dimension towards the X dimension. Also clamp number of threads to the problem dimension size, if necessary
montblanc/util/__init__.py
def redistribute_threads(blockdimx, blockdimy, blockdimz, dimx, dimy, dimz): """ Redistribute threads from the Z dimension towards the X dimension. Also clamp number of threads to the problem dimension size, if necessary """ # Shift threads from the z dimension # into the y dimension ...
def redistribute_threads(blockdimx, blockdimy, blockdimz, dimx, dimy, dimz): """ Redistribute threads from the Z dimension towards the X dimension. Also clamp number of threads to the problem dimension size, if necessary """ # Shift threads from the z dimension # into the y dimension ...
[ "Redistribute", "threads", "from", "the", "Z", "dimension", "towards", "the", "X", "dimension", ".", "Also", "clamp", "number", "of", "threads", "to", "the", "problem", "dimension", "size", "if", "necessary" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L387-L426
[ "def", "redistribute_threads", "(", "blockdimx", ",", "blockdimy", ",", "blockdimz", ",", "dimx", ",", "dimy", ",", "dimz", ")", ":", "# Shift threads from the z dimension", "# into the y dimension", "while", "blockdimz", ">", "dimz", ":", "tmp", "=", "blockdimz", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
register_default_dimensions
Register the default dimensions for a RIME solver
montblanc/util/__init__.py
def register_default_dimensions(cube, slvr_cfg): """ Register the default dimensions for a RIME solver """ import montblanc.src_types as mbs # Pull out the configuration options for the basics autocor = slvr_cfg['auto_correlations'] ntime = 10 na = 7 nbands = 1 nchan = 16 npol = 4...
def register_default_dimensions(cube, slvr_cfg): """ Register the default dimensions for a RIME solver """ import montblanc.src_types as mbs # Pull out the configuration options for the basics autocor = slvr_cfg['auto_correlations'] ntime = 10 na = 7 nbands = 1 nchan = 16 npol = 4...
[ "Register", "the", "default", "dimensions", "for", "a", "RIME", "solver" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/__init__.py#L429-L482
[ "def", "register_default_dimensions", "(", "cube", ",", "slvr_cfg", ")", ":", "import", "montblanc", ".", "src_types", "as", "mbs", "# Pull out the configuration options for the basics", "autocor", "=", "slvr_cfg", "[", "'auto_correlations'", "]", "ntime", "=", "10", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
get_ip_address
Hack to get IP address from the interface
montblanc/impl/rime/tensorflow/helpers/cluster_gen.py
def get_ip_address(ifname): """ Hack to get IP address from the interface """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24])
def get_ip_address(ifname): """ Hack to get IP address from the interface """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24])
[ "Hack", "to", "get", "IP", "address", "from", "the", "interface" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/helpers/cluster_gen.py#L26-L34
[ "def", "get_ip_address", "(", "ifname", ")", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ")", "return", "socket", ".", "inet_ntoa", "(", "fcntl", ".", "ioctl", "(", "s", ".", "fileno", "(", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
nvcc_compiler_settings
Find nvcc and the CUDA installation
install/cuda.py
def nvcc_compiler_settings(): """ Find nvcc and the CUDA installation """ search_paths = os.environ.get('PATH', '').split(os.pathsep) nvcc_path = find_in_path('nvcc', search_paths) default_cuda_path = os.path.join('usr', 'local', 'cuda') cuda_path = os.environ.get('CUDA_PATH', default_cuda_path) ...
def nvcc_compiler_settings(): """ Find nvcc and the CUDA installation """ search_paths = os.environ.get('PATH', '').split(os.pathsep) nvcc_path = find_in_path('nvcc', search_paths) default_cuda_path = os.path.join('usr', 'local', 'cuda') cuda_path = os.environ.get('CUDA_PATH', default_cuda_path) ...
[ "Find", "nvcc", "and", "the", "CUDA", "installation" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/cuda.py#L48-L115
[ "def", "nvcc_compiler_settings", "(", ")", ":", "search_paths", "=", "os", ".", "environ", ".", "get", "(", "'PATH'", ",", "''", ")", ".", "split", "(", "os", ".", "pathsep", ")", "nvcc_path", "=", "find_in_path", "(", "'nvcc'", ",", "search_paths", ")",...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
inspect_cuda_version_and_devices
Poor mans deviceQuery. Returns CUDA_VERSION information and CUDA device information in JSON format
install/cuda.py
def inspect_cuda_version_and_devices(compiler, settings): """ Poor mans deviceQuery. Returns CUDA_VERSION information and CUDA device information in JSON format """ try: output = build_and_run(compiler, ''' #include <cuda.h> #include <stdio.h> __device__ ...
def inspect_cuda_version_and_devices(compiler, settings): """ Poor mans deviceQuery. Returns CUDA_VERSION information and CUDA device information in JSON format """ try: output = build_and_run(compiler, ''' #include <cuda.h> #include <stdio.h> __device__ ...
[ "Poor", "mans", "deviceQuery", ".", "Returns", "CUDA_VERSION", "information", "and", "CUDA", "device", "information", "in", "JSON", "format" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/cuda.py#L117-L176
[ "def", "inspect_cuda_version_and_devices", "(", "compiler", ",", "settings", ")", ":", "try", ":", "output", "=", "build_and_run", "(", "compiler", ",", "'''\n #include <cuda.h>\n #include <stdio.h>\n\n __device__ void test(int * in, int * out)\n ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
customize_compiler_for_nvcc
inject deep into distutils to customize gcc/nvcc dispatch
install/cuda.py
def customize_compiler_for_nvcc(compiler, nvcc_settings): """inject deep into distutils to customize gcc/nvcc dispatch """ # tell the compiler it can process .cu files compiler.src_extensions.append('.cu') # save references to the default compiler_so and _compile methods default_compiler_so = comp...
def customize_compiler_for_nvcc(compiler, nvcc_settings): """inject deep into distutils to customize gcc/nvcc dispatch """ # tell the compiler it can process .cu files compiler.src_extensions.append('.cu') # save references to the default compiler_so and _compile methods default_compiler_so = comp...
[ "inject", "deep", "into", "distutils", "to", "customize", "gcc", "/", "nvcc", "dispatch" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/cuda.py#L215-L238
[ "def", "customize_compiler_for_nvcc", "(", "compiler", ",", "nvcc_settings", ")", ":", "# tell the compiler it can process .cu files", "compiler", ".", "src_extensions", ".", "append", "(", "'.cu'", ")", "# save references to the default compiler_so and _compile methods", "defaul...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
inspect_cuda
Return cuda device information and nvcc/cuda setup
install/cuda.py
def inspect_cuda(): """ Return cuda device information and nvcc/cuda setup """ nvcc_settings = nvcc_compiler_settings() sysconfig.get_config_vars() nvcc_compiler = ccompiler.new_compiler() sysconfig.customize_compiler(nvcc_compiler) customize_compiler_for_nvcc(nvcc_compiler, nvcc_settings) ...
def inspect_cuda(): """ Return cuda device information and nvcc/cuda setup """ nvcc_settings = nvcc_compiler_settings() sysconfig.get_config_vars() nvcc_compiler = ccompiler.new_compiler() sysconfig.customize_compiler(nvcc_compiler) customize_compiler_for_nvcc(nvcc_compiler, nvcc_settings) ...
[ "Return", "cuda", "device", "information", "and", "nvcc", "/", "cuda", "setup" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/install/cuda.py#L241-L251
[ "def", "inspect_cuda", "(", ")", ":", "nvcc_settings", "=", "nvcc_compiler_settings", "(", ")", "sysconfig", ".", "get_config_vars", "(", ")", "nvcc_compiler", "=", "ccompiler", ".", "new_compiler", "(", ")", "sysconfig", ".", "customize_compiler", "(", "nvcc_comp...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
RIMESolver.template_dict
Returns a dictionary suitable for templating strings with properties and dimensions related to this Solver object. Used in templated GPU kernels.
montblanc/solvers/rime_solver.py
def template_dict(self): """ Returns a dictionary suitable for templating strings with properties and dimensions related to this Solver object. Used in templated GPU kernels. """ slvr = self D = { # Constants 'LIGHTSPEED': montblanc.const...
def template_dict(self): """ Returns a dictionary suitable for templating strings with properties and dimensions related to this Solver object. Used in templated GPU kernels. """ slvr = self D = { # Constants 'LIGHTSPEED': montblanc.const...
[ "Returns", "a", "dictionary", "suitable", "for", "templating", "strings", "with", "properties", "and", "dimensions", "related", "to", "this", "Solver", "object", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/solvers/rime_solver.py#L84-L108
[ "def", "template_dict", "(", "self", ")", ":", "slvr", "=", "self", "D", "=", "{", "# Constants", "'LIGHTSPEED'", ":", "montblanc", ".", "constants", ".", "C", ",", "}", "# Map any types", "D", ".", "update", "(", "self", ".", "type_dict", "(", ")", ")...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
rime_solver
Factory function that produces a RIME solver
montblanc/factory.py
def rime_solver(slvr_cfg): """ Factory function that produces a RIME solver """ from montblanc.impl.rime.tensorflow.RimeSolver import RimeSolver return RimeSolver(slvr_cfg)
def rime_solver(slvr_cfg): """ Factory function that produces a RIME solver """ from montblanc.impl.rime.tensorflow.RimeSolver import RimeSolver return RimeSolver(slvr_cfg)
[ "Factory", "function", "that", "produces", "a", "RIME", "solver" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/factory.py#L21-L24
[ "def", "rime_solver", "(", "slvr_cfg", ")", ":", "from", "montblanc", ".", "impl", ".", "rime", ".", "tensorflow", ".", "RimeSolver", "import", "RimeSolver", "return", "RimeSolver", "(", "slvr_cfg", ")" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
find_sources
Returns a dictionary of source methods found on this object, keyed on method name. Source methods are identified.by argspec, a list of argument specifiers. So for e.g. an argpsec of :code:`[['self', 'context'], ['s', 'c']]` would match methods looking like: .. code-block:: python def f(sel...
montblanc/impl/rime/tensorflow/sources/source_provider.py
def find_sources(obj, argspec=None): """ Returns a dictionary of source methods found on this object, keyed on method name. Source methods are identified.by argspec, a list of argument specifiers. So for e.g. an argpsec of :code:`[['self', 'context'], ['s', 'c']]` would match methods looking lik...
def find_sources(obj, argspec=None): """ Returns a dictionary of source methods found on this object, keyed on method name. Source methods are identified.by argspec, a list of argument specifiers. So for e.g. an argpsec of :code:`[['self', 'context'], ['s', 'c']]` would match methods looking lik...
[ "Returns", "a", "dictionary", "of", "source", "methods", "found", "on", "this", "object", "keyed", "on", "method", "name", ".", "Source", "methods", "are", "identified", ".", "by", "argspec", "a", "list", "of", "argument", "specifiers", ".", "So", "for", "...
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/source_provider.py#L59-L92
[ "def", "find_sources", "(", "obj", ",", "argspec", "=", "None", ")", ":", "if", "argspec", "is", "None", ":", "argspec", "=", "[", "DEFAULT_ARGSPEC", "]", "return", "{", "n", ":", "m", "for", "n", ",", "m", "in", "inspect", ".", "getmembers", "(", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
SourceProvider.sources
Returns a dictionary of source methods found on this object, keyed on method name. Source methods are identified by (self, context) arguments on this object. For example: .. code-block:: python def f(self, context): ... is a source method, but ...
montblanc/impl/rime/tensorflow/sources/source_provider.py
def sources(self): """ Returns a dictionary of source methods found on this object, keyed on method name. Source methods are identified by (self, context) arguments on this object. For example: .. code-block:: python def f(self, context): ... ...
def sources(self): """ Returns a dictionary of source methods found on this object, keyed on method name. Source methods are identified by (self, context) arguments on this object. For example: .. code-block:: python def f(self, context): ... ...
[ "Returns", "a", "dictionary", "of", "source", "methods", "found", "on", "this", "object", "keyed", "on", "method", "name", ".", "Source", "methods", "are", "identified", "by", "(", "self", "context", ")", "arguments", "on", "this", "object", ".", "For", "e...
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/source_provider.py#L113-L140
[ "def", "sources", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_sources", "except", "AttributeError", ":", "self", ".", "_sources", "=", "find_sources", "(", "self", ")", "return", "self", ".", "_sources" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
parallactic_angles
Computes parallactic angles per timestep for the given reference antenna position and field centre. Arguments: times: ndarray Array of unique times with shape (ntime,), obtained from TIME column of MS table antenna_positions: ndarray of shape (na, 3) Antenna ...
montblanc/util/parallactic_angles.py
def parallactic_angles(times, antenna_positions, field_centre): """ Computes parallactic angles per timestep for the given reference antenna position and field centre. Arguments: times: ndarray Array of unique times with shape (ntime,), obtained from TIME column of MS ta...
def parallactic_angles(times, antenna_positions, field_centre): """ Computes parallactic angles per timestep for the given reference antenna position and field centre. Arguments: times: ndarray Array of unique times with shape (ntime,), obtained from TIME column of MS ta...
[ "Computes", "parallactic", "angles", "per", "timestep", "for", "the", "given", "reference", "antenna", "position", "and", "field", "centre", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/util/parallactic_angles.py#L34-L83
[ "def", "parallactic_angles", "(", "times", ",", "antenna_positions", ",", "field_centre", ")", ":", "import", "pyrap", ".", "quanta", "as", "pq", "try", ":", "# Create direction measure for the zenith", "zenith", "=", "pm", ".", "direction", "(", "'AZEL'", ",", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
setup_logging
Setup logging configuration
montblanc/logsetup.py
def setup_logging(): """ Setup logging configuration """ # Console formatter, mention name cfmt = logging.Formatter(('%(name)s - %(levelname)s - %(message)s')) # File formatter, mention time ffmt = logging.Formatter(('%(asctime)s - %(levelname)s - %(message)s')) # Console handler ch = log...
def setup_logging(): """ Setup logging configuration """ # Console formatter, mention name cfmt = logging.Formatter(('%(name)s - %(levelname)s - %(message)s')) # File formatter, mention time ffmt = logging.Formatter(('%(asctime)s - %(levelname)s - %(message)s')) # Console handler ch = log...
[ "Setup", "logging", "configuration" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/logsetup.py#L24-L58
[ "def", "setup_logging", "(", ")", ":", "# Console formatter, mention name", "cfmt", "=", "logging", ".", "Formatter", "(", "(", "'%(name)s - %(levelname)s - %(message)s'", ")", ")", "# File formatter, mention time", "ffmt", "=", "logging", ".", "Formatter", "(", "(", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
constant_cache
Caches constant arrays associated with an array name. The intent of this decorator is to avoid the cost of recreating and storing many arrays of constant data, especially data created by np.zeros or np.ones. Instead, a single array of the first given shape is created and any further requests for co...
montblanc/impl/rime/tensorflow/sources/defaults_source_provider.py
def constant_cache(method): """ Caches constant arrays associated with an array name. The intent of this decorator is to avoid the cost of recreating and storing many arrays of constant data, especially data created by np.zeros or np.ones. Instead, a single array of the first given shape is cre...
def constant_cache(method): """ Caches constant arrays associated with an array name. The intent of this decorator is to avoid the cost of recreating and storing many arrays of constant data, especially data created by np.zeros or np.ones. Instead, a single array of the first given shape is cre...
[ "Caches", "constant", "arrays", "associated", "with", "an", "array", "name", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/defaults_source_provider.py#L30-L77
[ "def", "constant_cache", "(", "method", ")", ":", "@", "functools", ".", "wraps", "(", "method", ")", "def", "wrapper", "(", "self", ",", "context", ")", ":", "# Defer to method if no caching is enabled", "if", "not", "self", ".", "_is_cached", ":", "return", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
chunk_cache
Caches chunks of default data. This decorator caches generated default data so as to avoid recomputing it on a subsequent queries to the provider.
montblanc/impl/rime/tensorflow/sources/defaults_source_provider.py
def chunk_cache(method): """ Caches chunks of default data. This decorator caches generated default data so as to avoid recomputing it on a subsequent queries to the provider. """ @functools.wraps(method) def wrapper(self, context): # Defer to the method if no caching is enable...
def chunk_cache(method): """ Caches chunks of default data. This decorator caches generated default data so as to avoid recomputing it on a subsequent queries to the provider. """ @functools.wraps(method) def wrapper(self, context): # Defer to the method if no caching is enable...
[ "Caches", "chunks", "of", "default", "data", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/defaults_source_provider.py#L79-L109
[ "def", "chunk_cache", "(", "method", ")", ":", "@", "functools", ".", "wraps", "(", "method", ")", "def", "wrapper", "(", "self", ",", "context", ")", ":", "# Defer to the method if no caching is enabled", "if", "not", "self", ".", "_is_cached", ":", "return",...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_create_defaults_source_provider
Create a DefaultsSourceProvider object. This provides default data sources for each array defined on the hypercube. The data sources may either by obtained from the arrays 'default' data source or the 'test' data source.
montblanc/impl/rime/tensorflow/RimeSolver.py
def _create_defaults_source_provider(cube, data_source): """ Create a DefaultsSourceProvider object. This provides default data sources for each array defined on the hypercube. The data sources may either by obtained from the arrays 'default' data source or the 'test' data source. """ from m...
def _create_defaults_source_provider(cube, data_source): """ Create a DefaultsSourceProvider object. This provides default data sources for each array defined on the hypercube. The data sources may either by obtained from the arrays 'default' data source or the 'test' data source. """ from m...
[ "Create", "a", "DefaultsSourceProvider", "object", ".", "This", "provides", "default", "data", "sources", "for", "each", "array", "defined", "on", "the", "hypercube", ".", "The", "data", "sources", "may", "either", "by", "obtained", "from", "the", "arrays", "d...
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L758-L812
[ "def", "_create_defaults_source_provider", "(", "cube", ",", "data_source", ")", ":", "from", "montblanc", ".", "impl", ".", "rime", ".", "tensorflow", ".", "sources", "import", "(", "find_sources", ",", "DEFAULT_ARGSPEC", ")", "from", "montblanc", ".", "impl", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_construct_tensorflow_expression
Constructs a tensorflow expression for computing the RIME
montblanc/impl/rime/tensorflow/RimeSolver.py
def _construct_tensorflow_expression(slvr_cfg, feed_data, device, shard): """ Constructs a tensorflow expression for computing the RIME """ zero = tf.constant(0) src_count = zero src_ph_vars = feed_data.src_ph_vars LSA = feed_data.local polarisation_type = slvr_cfg['polarisation_type'] # ...
def _construct_tensorflow_expression(slvr_cfg, feed_data, device, shard): """ Constructs a tensorflow expression for computing the RIME """ zero = tf.constant(0) src_count = zero src_ph_vars = feed_data.src_ph_vars LSA = feed_data.local polarisation_type = slvr_cfg['polarisation_type'] # ...
[ "Constructs", "a", "tensorflow", "expression", "for", "computing", "the", "RIME" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L924-L1104
[ "def", "_construct_tensorflow_expression", "(", "slvr_cfg", ",", "feed_data", ",", "device", ",", "shard", ")", ":", "zero", "=", "tf", ".", "constant", "(", "0", ")", "src_count", "=", "zero", "src_ph_vars", "=", "feed_data", ".", "src_ph_vars", "LSA", "=",...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_get_data
Get data from the data source, checking the return values
montblanc/impl/rime/tensorflow/RimeSolver.py
def _get_data(data_source, context): """ Get data from the data source, checking the return values """ try: # Get data from the data source data = data_source.source(context) # Complain about None values if data is None: raise ValueError("'None' returned from " ...
def _get_data(data_source, context): """ Get data from the data source, checking the return values """ try: # Get data from the data source data = data_source.source(context) # Complain about None values if data is None: raise ValueError("'None' returned from " ...
[ "Get", "data", "from", "the", "data", "source", "checking", "the", "return", "values" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L1106-L1138
[ "def", "_get_data", "(", "data_source", ",", "context", ")", ":", "try", ":", "# Get data from the data source", "data", "=", "data_source", ".", "source", "(", "context", ")", "# Complain about None values", "if", "data", "is", "None", ":", "raise", "ValueError",...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_supply_data
Supply data to the data sink
montblanc/impl/rime/tensorflow/RimeSolver.py
def _supply_data(data_sink, context): """ Supply data to the data sink """ try: data_sink.sink(context) except Exception as e: ex = ValueError("An exception occurred while " "supplying data to data sink '{ds}'\n\n" "{e}\n\n" "{help}".format(ds=context.name...
def _supply_data(data_sink, context): """ Supply data to the data sink """ try: data_sink.sink(context) except Exception as e: ex = ValueError("An exception occurred while " "supplying data to data sink '{ds}'\n\n" "{e}\n\n" "{help}".format(ds=context.name...
[ "Supply", "data", "to", "the", "data", "sink" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L1140-L1151
[ "def", "_supply_data", "(", "data_sink", ",", "context", ")", ":", "try", ":", "data_sink", ".", "sink", "(", "context", ")", "except", "Exception", "as", "e", ":", "ex", "=", "ValueError", "(", "\"An exception occurred while \"", "\"supplying data to data sink '{...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_apply_source_provider_dim_updates
Given a list of source_providers, apply the list of suggested dimension updates given in provider.updated_dimensions() to the supplied hypercube. Dimension global_sizes are always updated with the supplied sizes and lower_extent is always set to 0. upper_extent is set to any reductions (current upp...
montblanc/impl/rime/tensorflow/RimeSolver.py
def _apply_source_provider_dim_updates(cube, source_providers, budget_dims): """ Given a list of source_providers, apply the list of suggested dimension updates given in provider.updated_dimensions() to the supplied hypercube. Dimension global_sizes are always updated with the supplied sizes and ...
def _apply_source_provider_dim_updates(cube, source_providers, budget_dims): """ Given a list of source_providers, apply the list of suggested dimension updates given in provider.updated_dimensions() to the supplied hypercube. Dimension global_sizes are always updated with the supplied sizes and ...
[ "Given", "a", "list", "of", "source_providers", "apply", "the", "list", "of", "suggested", "dimension", "updates", "given", "in", "provider", ".", "updated_dimensions", "()", "to", "the", "supplied", "hypercube", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L1234-L1317
[ "def", "_apply_source_provider_dim_updates", "(", "cube", ",", "source_providers", ",", "budget_dims", ")", ":", "# Create a mapping between a dimension and a", "# list of (global_size, provider_name) tuples", "update_map", "=", "collections", ".", "defaultdict", "(", "list", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_setup_hypercube
Sets up the hypercube given a solver configuration
montblanc/impl/rime/tensorflow/RimeSolver.py
def _setup_hypercube(cube, slvr_cfg): """ Sets up the hypercube given a solver configuration """ mbu.register_default_dimensions(cube, slvr_cfg) # Configure the dimensions of the beam cube cube.register_dimension('beam_lw', 2, description='E Beam cube l width') cube.reg...
def _setup_hypercube(cube, slvr_cfg): """ Sets up the hypercube given a solver configuration """ mbu.register_default_dimensions(cube, slvr_cfg) # Configure the dimensions of the beam cube cube.register_dimension('beam_lw', 2, description='E Beam cube l width') cube.reg...
[ "Sets", "up", "the", "hypercube", "given", "a", "solver", "configuration" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L1319-L1357
[ "def", "_setup_hypercube", "(", "cube", ",", "slvr_cfg", ")", ":", "mbu", ".", "register_default_dimensions", "(", "cube", ",", "slvr_cfg", ")", "# Configure the dimensions of the beam cube", "cube", ".", "register_dimension", "(", "'beam_lw'", ",", "2", ",", "descr...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_partition
Partition data sources into 1. Dictionary of data sources associated with radio sources. 2. List of data sources to feed multiple times. 3. List of data sources to feed once.
montblanc/impl/rime/tensorflow/RimeSolver.py
def _partition(iter_dims, data_sources): """ Partition data sources into 1. Dictionary of data sources associated with radio sources. 2. List of data sources to feed multiple times. 3. List of data sources to feed once. """ src_nr_vars = set(source_var_types().values()) iter_dims = set...
def _partition(iter_dims, data_sources): """ Partition data sources into 1. Dictionary of data sources associated with radio sources. 2. List of data sources to feed multiple times. 3. List of data sources to feed once. """ src_nr_vars = set(source_var_types().values()) iter_dims = set...
[ "Partition", "data", "sources", "into" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L1359-L1397
[ "def", "_partition", "(", "iter_dims", ",", "data_sources", ")", ":", "src_nr_vars", "=", "set", "(", "source_var_types", "(", ")", ".", "values", "(", ")", ")", "iter_dims", "=", "set", "(", "iter_dims", ")", "src_data_sources", "=", "collections", ".", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
RimeSolver._feed
Feed stub
montblanc/impl/rime/tensorflow/RimeSolver.py
def _feed(self, cube, data_sources, data_sinks, global_iter_args): """ Feed stub """ try: self._feed_impl(cube, data_sources, data_sinks, global_iter_args) except Exception as e: montblanc.log.exception("Feed Exception") raise
def _feed(self, cube, data_sources, data_sinks, global_iter_args): """ Feed stub """ try: self._feed_impl(cube, data_sources, data_sinks, global_iter_args) except Exception as e: montblanc.log.exception("Feed Exception") raise
[ "Feed", "stub" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L356-L362
[ "def", "_feed", "(", "self", ",", "cube", ",", "data_sources", ",", "data_sinks", ",", "global_iter_args", ")", ":", "try", ":", "self", ".", "_feed_impl", "(", "cube", ",", "data_sources", ",", "data_sinks", ",", "global_iter_args", ")", "except", "Exceptio...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
RimeSolver._feed_impl
Implementation of staging_area feeding
montblanc/impl/rime/tensorflow/RimeSolver.py
def _feed_impl(self, cube, data_sources, data_sinks, global_iter_args): """ Implementation of staging_area feeding """ session = self._tf_session FD = self._tf_feed_data LSA = FD.local # Get source strides out before the local sizes are modified during # the source loops...
def _feed_impl(self, cube, data_sources, data_sinks, global_iter_args): """ Implementation of staging_area feeding """ session = self._tf_session FD = self._tf_feed_data LSA = FD.local # Get source strides out before the local sizes are modified during # the source loops...
[ "Implementation", "of", "staging_area", "feeding" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L364-L427
[ "def", "_feed_impl", "(", "self", ",", "cube", ",", "data_sources", ",", "data_sinks", ",", "global_iter_args", ")", ":", "session", "=", "self", ".", "_tf_session", "FD", "=", "self", ".", "_tf_feed_data", "LSA", "=", "FD", ".", "local", "# Get source strid...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
RimeSolver._compute
Call the tensorflow compute
montblanc/impl/rime/tensorflow/RimeSolver.py
def _compute(self, feed_dict, shard): """ Call the tensorflow compute """ try: descriptor, enq = self._tfrun(self._tf_expr[shard], feed_dict=feed_dict) self._inputs_waiting.decrement(shard) except Exception as e: montblanc.log.exception("Compute Exception") ...
def _compute(self, feed_dict, shard): """ Call the tensorflow compute """ try: descriptor, enq = self._tfrun(self._tf_expr[shard], feed_dict=feed_dict) self._inputs_waiting.decrement(shard) except Exception as e: montblanc.log.exception("Compute Exception") ...
[ "Call", "the", "tensorflow", "compute" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L517-L526
[ "def", "_compute", "(", "self", ",", "feed_dict", ",", "shard", ")", ":", "try", ":", "descriptor", ",", "enq", "=", "self", ".", "_tfrun", "(", "self", ".", "_tf_expr", "[", "shard", "]", ",", "feed_dict", "=", "feed_dict", ")", "self", ".", "_input...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
RimeSolver._consume
Consume stub
montblanc/impl/rime/tensorflow/RimeSolver.py
def _consume(self, data_sinks, cube, global_iter_args): """ Consume stub """ try: return self._consume_impl(data_sinks, cube, global_iter_args) except Exception as e: montblanc.log.exception("Consumer Exception") raise e, None, sys.exc_info()[2]
def _consume(self, data_sinks, cube, global_iter_args): """ Consume stub """ try: return self._consume_impl(data_sinks, cube, global_iter_args) except Exception as e: montblanc.log.exception("Consumer Exception") raise e, None, sys.exc_info()[2]
[ "Consume", "stub" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L529-L535
[ "def", "_consume", "(", "self", ",", "data_sinks", ",", "cube", ",", "global_iter_args", ")", ":", "try", ":", "return", "self", ".", "_consume_impl", "(", "data_sinks", ",", "cube", ",", "global_iter_args", ")", "except", "Exception", "as", "e", ":", "mon...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
RimeSolver._consume_impl
Consume
montblanc/impl/rime/tensorflow/RimeSolver.py
def _consume_impl(self, data_sinks, cube, global_iter_args): """ Consume """ LSA = self._tf_feed_data.local output = self._tfrun(LSA.output.get_op) # Expect the descriptor in the first tuple position assert len(output) > 0 assert LSA.output.fed_arrays[0] == 'descriptor'...
def _consume_impl(self, data_sinks, cube, global_iter_args): """ Consume """ LSA = self._tf_feed_data.local output = self._tfrun(LSA.output.get_op) # Expect the descriptor in the first tuple position assert len(output) > 0 assert LSA.output.fed_arrays[0] == 'descriptor'...
[ "Consume" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/RimeSolver.py#L537-L571
[ "def", "_consume_impl", "(", "self", ",", "data_sinks", ",", "cube", ",", "global_iter_args", ")", ":", "LSA", "=", "self", ".", "_tf_feed_data", ".", "local", "output", "=", "self", ".", "_tfrun", "(", "LSA", ".", "output", ".", "get_op", ")", "# Expect...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
rime_solver_cfg
Produces a SolverConfiguration object, inherited from a simple python dict, and containing the options required to configure the RIME Solver. Keyword arguments ----------------- Any keyword arguments are inserted into the returned dict. Returns ------- A SolverConfiguration object.
montblanc/__init__.py
def rime_solver_cfg(**kwargs): """ Produces a SolverConfiguration object, inherited from a simple python dict, and containing the options required to configure the RIME Solver. Keyword arguments ----------------- Any keyword arguments are inserted into the returned dict. Returns ...
def rime_solver_cfg(**kwargs): """ Produces a SolverConfiguration object, inherited from a simple python dict, and containing the options required to configure the RIME Solver. Keyword arguments ----------------- Any keyword arguments are inserted into the returned dict. Returns ...
[ "Produces", "a", "SolverConfiguration", "object", "inherited", "from", "a", "simple", "python", "dict", "and", "containing", "the", "options", "required", "to", "configure", "the", "RIME", "Solver", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/__init__.py#L50-L87
[ "def", "rime_solver_cfg", "(", "*", "*", "kwargs", ")", ":", "from", "configuration", "import", "(", "load_config", ",", "config_validator", ",", "raise_validator_errors", ")", "def", "_merge_copy", "(", "d1", ",", "d2", ")", ":", "return", "{", "k", ":", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_create_filenames
Returns a dictionary of beam filename pairs, keyed on correlation,from the cartesian product of correlations and real, imaginary pairs Given 'beam_$(corr)_$(reim).fits' returns: { 'xx' : ('beam_xx_re.fits', 'beam_xx_im.fits'), 'xy' : ('beam_xy_re.fits', 'beam_xy_im.fits'), ... '...
montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py
def _create_filenames(filename_schema, feed_type): """ Returns a dictionary of beam filename pairs, keyed on correlation,from the cartesian product of correlations and real, imaginary pairs Given 'beam_$(corr)_$(reim).fits' returns: { 'xx' : ('beam_xx_re.fits', 'beam_xx_im.fits'), '...
def _create_filenames(filename_schema, feed_type): """ Returns a dictionary of beam filename pairs, keyed on correlation,from the cartesian product of correlations and real, imaginary pairs Given 'beam_$(corr)_$(reim).fits' returns: { 'xx' : ('beam_xx_re.fits', 'beam_xx_im.fits'), '...
[ "Returns", "a", "dictionary", "of", "beam", "filename", "pairs", "keyed", "on", "correlation", "from", "the", "cartesian", "product", "of", "correlations", "and", "real", "imaginary", "pairs" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py#L163-L211
[ "def", "_create_filenames", "(", "filename_schema", ",", "feed_type", ")", ":", "template", "=", "FitsFilenameTemplate", "(", "filename_schema", ")", "def", "_re_im_filenames", "(", "corr", ",", "template", ")", ":", "try", ":", "return", "tuple", "(", "template...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_open_fits_files
Given a {correlation: filename} mapping for filenames returns a {correlation: file handle} mapping
montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py
def _open_fits_files(filenames): """ Given a {correlation: filename} mapping for filenames returns a {correlation: file handle} mapping """ kw = { 'mode' : 'update', 'memmap' : False } def _fh(fn): """ Returns a filehandle or None if file does not exist """ return fits.open(fn, ...
def _open_fits_files(filenames): """ Given a {correlation: filename} mapping for filenames returns a {correlation: file handle} mapping """ kw = { 'mode' : 'update', 'memmap' : False } def _fh(fn): """ Returns a filehandle or None if file does not exist """ return fits.open(fn, ...
[ "Given", "a", "{", "correlation", ":", "filename", "}", "mapping", "for", "filenames", "returns", "a", "{", "correlation", ":", "file", "handle", "}", "mapping" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py#L213-L226
[ "def", "_open_fits_files", "(", "filenames", ")", ":", "kw", "=", "{", "'mode'", ":", "'update'", ",", "'memmap'", ":", "False", "}", "def", "_fh", "(", "fn", ")", ":", "\"\"\" Returns a filehandle or None if file does not exist \"\"\"", "return", "fits", ".", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_create_axes
Create a FitsAxes object
montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py
def _create_axes(filenames, file_dict): """ Create a FitsAxes object """ try: # Loop through the file_dictionary, finding the # first open FITS file. f = iter(f for tup in file_dict.itervalues() for f in tup if f is not None).next() except StopIteration as e: rai...
def _create_axes(filenames, file_dict): """ Create a FitsAxes object """ try: # Loop through the file_dictionary, finding the # first open FITS file. f = iter(f for tup in file_dict.itervalues() for f in tup if f is not None).next() except StopIteration as e: rai...
[ "Create", "a", "FitsAxes", "object" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py#L237-L261
[ "def", "_create_axes", "(", "filenames", ",", "file_dict", ")", ":", "try", ":", "# Loop through the file_dictionary, finding the", "# first open FITS file.", "f", "=", "iter", "(", "f", "for", "tup", "in", "file_dict", ".", "itervalues", "(", ")", "for", "f", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
FitsBeamSourceProvider._initialise
Initialise the object by generating appropriate filenames, opening associated file handles and inspecting the FITS axes of these files.
montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py
def _initialise(self, feed_type="linear"): """ Initialise the object by generating appropriate filenames, opening associated file handles and inspecting the FITS axes of these files. """ self._filenames = filenames = _create_filenames(self._filename_schema, ...
def _initialise(self, feed_type="linear"): """ Initialise the object by generating appropriate filenames, opening associated file handles and inspecting the FITS axes of these files. """ self._filenames = filenames = _create_filenames(self._filename_schema, ...
[ "Initialise", "the", "object", "by", "generating", "appropriate", "filenames", "opening", "associated", "file", "handles", "and", "inspecting", "the", "FITS", "axes", "of", "these", "files", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py#L333-L360
[ "def", "_initialise", "(", "self", ",", "feed_type", "=", "\"linear\"", ")", ":", "self", ".", "_filenames", "=", "filenames", "=", "_create_filenames", "(", "self", ".", "_filename_schema", ",", "feed_type", ")", "self", ".", "_files", "=", "files", "=", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
FitsBeamSourceProvider.ebeam
ebeam cube data source
montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py
def ebeam(self, context): """ ebeam cube data source """ if context.shape != self.shape: raise ValueError("Partial feeding of the " "beam cube is not yet supported %s %s." % (context.shape, self.shape)) ebeam = np.empty(context.shape, context.dtype) # Iterat...
def ebeam(self, context): """ ebeam cube data source """ if context.shape != self.shape: raise ValueError("Partial feeding of the " "beam cube is not yet supported %s %s." % (context.shape, self.shape)) ebeam = np.empty(context.shape, context.dtype) # Iterat...
[ "ebeam", "cube", "data", "source" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/fits_beam_source_provider.py#L370-L385
[ "def", "ebeam", "(", "self", ",", "context", ")", ":", "if", "context", ".", "shape", "!=", "self", ".", "shape", ":", "raise", "ValueError", "(", "\"Partial feeding of the \"", "\"beam cube is not yet supported %s %s.\"", "%", "(", "context", ".", "shape", ",",...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
MSSinkProvider.model_vis
model visibility data sink
montblanc/impl/rime/tensorflow/sinks/ms_sink_provider.py
def model_vis(self, context): """ model visibility data sink """ column = self._vis_column msshape = None # Do we have a column descriptor for the supplied column? try: coldesc = self._manager.column_descriptors[column] except KeyError as e: colde...
def model_vis(self, context): """ model visibility data sink """ column = self._vis_column msshape = None # Do we have a column descriptor for the supplied column? try: coldesc = self._manager.column_descriptors[column] except KeyError as e: colde...
[ "model", "visibility", "data", "sink" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sinks/ms_sink_provider.py#L54-L86
[ "def", "model_vis", "(", "self", ",", "context", ")", ":", "column", "=", "self", ".", "_vis_column", "msshape", "=", "None", "# Do we have a column descriptor for the supplied column?", "try", ":", "coldesc", "=", "self", ".", "_manager", ".", "column_descriptors",...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_cache
Decorator for caching data source return values Create a key index for the proxied array in the context. Iterate over the array shape descriptor e.g. (ntime, nbl, 3) returning tuples containing the lower and upper extents of string dimensions. Takes (0, d) in the case of an integer dimensions.
montblanc/impl/rime/tensorflow/sources/cached_source_provider.py
def _cache(method): """ Decorator for caching data source return values Create a key index for the proxied array in the context. Iterate over the array shape descriptor e.g. (ntime, nbl, 3) returning tuples containing the lower and upper extents of string dimensions. Takes (0, d) in the case of...
def _cache(method): """ Decorator for caching data source return values Create a key index for the proxied array in the context. Iterate over the array shape descriptor e.g. (ntime, nbl, 3) returning tuples containing the lower and upper extents of string dimensions. Takes (0, d) in the case of...
[ "Decorator", "for", "caching", "data", "source", "return", "values" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/cached_source_provider.py#L29-L56
[ "def", "_cache", "(", "method", ")", ":", "@", "functools", ".", "wraps", "(", "method", ")", "def", "memoizer", "(", "self", ",", "context", ")", ":", "# Construct the key for the given index", "idx", "=", "context", ".", "array_extents", "(", "context", "....
8a2e742e7500bcc6196489b735f87b233075dd2d
train
_proxy
Decorator returning a method that proxies a data source.
montblanc/impl/rime/tensorflow/sources/cached_source_provider.py
def _proxy(method): """ Decorator returning a method that proxies a data source. """ @functools.wraps(method) def memoizer(self, context): return method(context) return memoizer
def _proxy(method): """ Decorator returning a method that proxies a data source. """ @functools.wraps(method) def memoizer(self, context): return method(context) return memoizer
[ "Decorator", "returning", "a", "method", "that", "proxies", "a", "data", "source", "." ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/cached_source_provider.py#L58-L66
[ "def", "_proxy", "(", "method", ")", ":", "@", "functools", ".", "wraps", "(", "method", ")", "def", "memoizer", "(", "self", ",", "context", ")", ":", "return", "method", "(", "context", ")", "return", "memoizer" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
CachedSourceProvider.start
Perform any logic on solution start
montblanc/impl/rime/tensorflow/sources/cached_source_provider.py
def start(self, start_context): """ Perform any logic on solution start """ for p in self._providers: p.start(start_context) if self._clear_start: self.clear_cache()
def start(self, start_context): """ Perform any logic on solution start """ for p in self._providers: p.start(start_context) if self._clear_start: self.clear_cache()
[ "Perform", "any", "logic", "on", "solution", "start" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/cached_source_provider.py#L132-L138
[ "def", "start", "(", "self", ",", "start_context", ")", ":", "for", "p", "in", "self", ".", "_providers", ":", "p", ".", "start", "(", "start_context", ")", "if", "self", ".", "_clear_start", ":", "self", ".", "clear_cache", "(", ")" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
CachedSourceProvider.stop
Perform any logic on solution stop
montblanc/impl/rime/tensorflow/sources/cached_source_provider.py
def stop(self, stop_context): """ Perform any logic on solution stop """ for p in self._providers: p.stop(stop_context) if self._clear_stop: self.clear_cache()
def stop(self, stop_context): """ Perform any logic on solution stop """ for p in self._providers: p.stop(stop_context) if self._clear_stop: self.clear_cache()
[ "Perform", "any", "logic", "on", "solution", "stop" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/cached_source_provider.py#L140-L146
[ "def", "stop", "(", "self", ",", "stop_context", ")", ":", "for", "p", "in", "self", ".", "_providers", ":", "p", ".", "stop", "(", "stop_context", ")", "if", "self", ".", "_clear_stop", ":", "self", ".", "clear_cache", "(", ")" ]
8a2e742e7500bcc6196489b735f87b233075dd2d
train
default_base_ant_pairs
Compute base antenna pairs
montblanc/impl/rime/tensorflow/config.py
def default_base_ant_pairs(self, context): """ Compute base antenna pairs """ k = 0 if context.cfg['auto_correlations'] == True else 1 na = context.dim_global_size('na') gen = (i.astype(context.dtype) for i in np.triu_indices(na, k)) # Cache np.triu_indices(na, k) as its likely that (na, k) will ...
def default_base_ant_pairs(self, context): """ Compute base antenna pairs """ k = 0 if context.cfg['auto_correlations'] == True else 1 na = context.dim_global_size('na') gen = (i.astype(context.dtype) for i in np.triu_indices(na, k)) # Cache np.triu_indices(na, k) as its likely that (na, k) will ...
[ "Compute", "base", "antenna", "pairs" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/config.py#L67-L87
[ "def", "default_base_ant_pairs", "(", "self", ",", "context", ")", ":", "k", "=", "0", "if", "context", ".", "cfg", "[", "'auto_correlations'", "]", "==", "True", "else", "1", "na", "=", "context", ".", "dim_global_size", "(", "'na'", ")", "gen", "=", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
default_antenna1
Default antenna1 values
montblanc/impl/rime/tensorflow/config.py
def default_antenna1(self, context): """ Default antenna1 values """ ant1, ant2 = default_base_ant_pairs(self, context) (tl, tu), (bl, bu) = context.dim_extents('ntime', 'nbl') ant1_result = np.empty(context.shape, context.dtype) ant1_result[:,:] = ant1[np.newaxis,bl:bu] return ant1_result
def default_antenna1(self, context): """ Default antenna1 values """ ant1, ant2 = default_base_ant_pairs(self, context) (tl, tu), (bl, bu) = context.dim_extents('ntime', 'nbl') ant1_result = np.empty(context.shape, context.dtype) ant1_result[:,:] = ant1[np.newaxis,bl:bu] return ant1_result
[ "Default", "antenna1", "values" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/config.py#L89-L95
[ "def", "default_antenna1", "(", "self", ",", "context", ")", ":", "ant1", ",", "ant2", "=", "default_base_ant_pairs", "(", "self", ",", "context", ")", "(", "tl", ",", "tu", ")", ",", "(", "bl", ",", "bu", ")", "=", "context", ".", "dim_extents", "("...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
default_antenna2
Default antenna2 values
montblanc/impl/rime/tensorflow/config.py
def default_antenna2(self, context): """ Default antenna2 values """ ant1, ant2 = default_base_ant_pairs(self, context) (tl, tu), (bl, bu) = context.dim_extents('ntime', 'nbl') ant2_result = np.empty(context.shape, context.dtype) ant2_result[:,:] = ant2[np.newaxis,bl:bu] return ant2_result
def default_antenna2(self, context): """ Default antenna2 values """ ant1, ant2 = default_base_ant_pairs(self, context) (tl, tu), (bl, bu) = context.dim_extents('ntime', 'nbl') ant2_result = np.empty(context.shape, context.dtype) ant2_result[:,:] = ant2[np.newaxis,bl:bu] return ant2_result
[ "Default", "antenna2", "values" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/config.py#L97-L103
[ "def", "default_antenna2", "(", "self", ",", "context", ")", ":", "ant1", ",", "ant2", "=", "default_base_ant_pairs", "(", "self", ",", "context", ")", "(", "tl", ",", "tu", ")", ",", "(", "bl", ",", "bu", ")", "=", "context", ".", "dim_extents", "("...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
identity_on_pols
Returns [[1, 0], tiled up to other dimensions [0, 1]]
montblanc/impl/rime/tensorflow/config.py
def identity_on_pols(self, context): """ Returns [[1, 0], tiled up to other dimensions [0, 1]] """ A = np.empty(context.shape, context.dtype) A[:,:,:] = [[[1,0,0,1]]] return A
def identity_on_pols(self, context): """ Returns [[1, 0], tiled up to other dimensions [0, 1]] """ A = np.empty(context.shape, context.dtype) A[:,:,:] = [[[1,0,0,1]]] return A
[ "Returns", "[[", "1", "0", "]", "tiled", "up", "to", "other", "dimensions", "[", "0", "1", "]]" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/config.py#L134-L141
[ "def", "identity_on_pols", "(", "self", ",", "context", ")", ":", "A", "=", "np", ".", "empty", "(", "context", ".", "shape", ",", "context", ".", "dtype", ")", "A", "[", ":", ",", ":", ",", ":", "]", "=", "[", "[", "[", "1", ",", "0", ",", ...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
default_stokes
Returns [[1, 0], tiled up to other dimensions [0, 0]]
montblanc/impl/rime/tensorflow/config.py
def default_stokes(self, context): """ Returns [[1, 0], tiled up to other dimensions [0, 0]] """ A = np.empty(context.shape, context.dtype) A[:,:,:] = [[[1,0,0,0]]] return A
def default_stokes(self, context): """ Returns [[1, 0], tiled up to other dimensions [0, 0]] """ A = np.empty(context.shape, context.dtype) A[:,:,:] = [[[1,0,0,0]]] return A
[ "Returns", "[[", "1", "0", "]", "tiled", "up", "to", "other", "dimensions", "[", "0", "0", "]]" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/config.py#L143-L150
[ "def", "default_stokes", "(", "self", ",", "context", ")", ":", "A", "=", "np", ".", "empty", "(", "context", ".", "shape", ",", "context", ".", "dtype", ")", "A", "[", ":", ",", ":", ",", ":", "]", "=", "[", "[", "[", "1", ",", "0", ",", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
MSSourceProvider.frequency
Frequency data source
montblanc/impl/rime/tensorflow/sources/ms_source_provider.py
def frequency(self, context): """ Frequency data source """ channels = self._manager.spectral_window_table.getcol(MS.CHAN_FREQ) return channels.reshape(context.shape).astype(context.dtype)
def frequency(self, context): """ Frequency data source """ channels = self._manager.spectral_window_table.getcol(MS.CHAN_FREQ) return channels.reshape(context.shape).astype(context.dtype)
[ "Frequency", "data", "source" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/ms_source_provider.py#L93-L96
[ "def", "frequency", "(", "self", ",", "context", ")", ":", "channels", "=", "self", ".", "_manager", ".", "spectral_window_table", ".", "getcol", "(", "MS", ".", "CHAN_FREQ", ")", "return", "channels", ".", "reshape", "(", "context", ".", "shape", ")", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
MSSourceProvider.ref_frequency
Reference frequency data source
montblanc/impl/rime/tensorflow/sources/ms_source_provider.py
def ref_frequency(self, context): """ Reference frequency data source """ num_chans = self._manager.spectral_window_table.getcol(MS.NUM_CHAN) ref_freqs = self._manager.spectral_window_table.getcol(MS.REF_FREQUENCY) data = np.hstack((np.repeat(rf, bs) for bs, rf in zip(num_chans, ref_fre...
def ref_frequency(self, context): """ Reference frequency data source """ num_chans = self._manager.spectral_window_table.getcol(MS.NUM_CHAN) ref_freqs = self._manager.spectral_window_table.getcol(MS.REF_FREQUENCY) data = np.hstack((np.repeat(rf, bs) for bs, rf in zip(num_chans, ref_fre...
[ "Reference", "frequency", "data", "source" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/ms_source_provider.py#L98-L104
[ "def", "ref_frequency", "(", "self", ",", "context", ")", ":", "num_chans", "=", "self", ".", "_manager", ".", "spectral_window_table", ".", "getcol", "(", "MS", ".", "NUM_CHAN", ")", "ref_freqs", "=", "self", ".", "_manager", ".", "spectral_window_table", "...
8a2e742e7500bcc6196489b735f87b233075dd2d
train
MSSourceProvider.uvw
Per-antenna UVW coordinate data source
montblanc/impl/rime/tensorflow/sources/ms_source_provider.py
def uvw(self, context): """ Per-antenna UVW coordinate data source """ # Hacky access of private member cube = context._cube # Create antenna1 source context a1_actual = cube.array("antenna1", reify=True) a1_ctx = SourceContext("antenna1", cube, context.cfg, ...
def uvw(self, context): """ Per-antenna UVW coordinate data source """ # Hacky access of private member cube = context._cube # Create antenna1 source context a1_actual = cube.array("antenna1", reify=True) a1_ctx = SourceContext("antenna1", cube, context.cfg, ...
[ "Per", "-", "antenna", "UVW", "coordinate", "data", "source" ]
ska-sa/montblanc
python
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/ms_source_provider.py#L106-L141
[ "def", "uvw", "(", "self", ",", "context", ")", ":", "# Hacky access of private member", "cube", "=", "context", ".", "_cube", "# Create antenna1 source context", "a1_actual", "=", "cube", ".", "array", "(", "\"antenna1\"", ",", "reify", "=", "True", ")", "a1_ct...
8a2e742e7500bcc6196489b735f87b233075dd2d