repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
openvax/isovar
isovar/variant_sequences.py
filter_variant_sequences
def filter_variant_sequences( variant_sequences, preferred_sequence_length, min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE,): """ Drop variant sequences which are shorter than request or don't have enough supporting reads. """ variant_sequences = trim_variant_seq...
python
def filter_variant_sequences( variant_sequences, preferred_sequence_length, min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE,): """ Drop variant sequences which are shorter than request or don't have enough supporting reads. """ variant_sequences = trim_variant_seq...
[ "def", "filter_variant_sequences", "(", "variant_sequences", ",", "preferred_sequence_length", ",", "min_variant_sequence_coverage", "=", "MIN_VARIANT_SEQUENCE_COVERAGE", ",", ")", ":", "variant_sequences", "=", "trim_variant_sequences", "(", "variant_sequences", ",", "min_vari...
Drop variant sequences which are shorter than request or don't have enough supporting reads.
[ "Drop", "variant", "sequences", "which", "are", "shorter", "than", "request", "or", "don", "t", "have", "enough", "supporting", "reads", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L339-L352
train
openvax/isovar
isovar/variant_sequences.py
reads_generator_to_sequences_generator
def reads_generator_to_sequences_generator( variant_and_reads_generator, min_alt_rna_reads=MIN_ALT_RNA_READS, min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE, preferred_sequence_length=VARIANT_SEQUENCE_LENGTH, variant_sequence_assembly=VARIANT_SEQUENCE_ASSEMBLY): ...
python
def reads_generator_to_sequences_generator( variant_and_reads_generator, min_alt_rna_reads=MIN_ALT_RNA_READS, min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE, preferred_sequence_length=VARIANT_SEQUENCE_LENGTH, variant_sequence_assembly=VARIANT_SEQUENCE_ASSEMBLY): ...
[ "def", "reads_generator_to_sequences_generator", "(", "variant_and_reads_generator", ",", "min_alt_rna_reads", "=", "MIN_ALT_RNA_READS", ",", "min_variant_sequence_coverage", "=", "MIN_VARIANT_SEQUENCE_COVERAGE", ",", "preferred_sequence_length", "=", "VARIANT_SEQUENCE_LENGTH", ",", ...
For each variant, collect all possible sequence contexts around the variant which are spanned by at least min_reads. Parameters ---------- variant_and_reads_generator : generator Sequence of Variant objects paired with a list of reads which overlap that variant. min_alt_rna_reads :...
[ "For", "each", "variant", "collect", "all", "possible", "sequence", "contexts", "around", "the", "variant", "which", "are", "spanned", "by", "at", "least", "min_reads", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L474-L516
train
openvax/isovar
isovar/variant_sequences.py
VariantSequence.contains
def contains(self, other): """ Is the other VariantSequence a subsequence of this one? The two sequences must agree on the alt nucleotides, the prefix of the longer must contain the prefix of the shorter, and the suffix of the longer must contain the suffix of the shorter. ...
python
def contains(self, other): """ Is the other VariantSequence a subsequence of this one? The two sequences must agree on the alt nucleotides, the prefix of the longer must contain the prefix of the shorter, and the suffix of the longer must contain the suffix of the shorter. ...
[ "def", "contains", "(", "self", ",", "other", ")", ":", "return", "(", "self", ".", "alt", "==", "other", ".", "alt", "and", "self", ".", "prefix", ".", "endswith", "(", "other", ".", "prefix", ")", "and", "self", ".", "suffix", ".", "startswith", ...
Is the other VariantSequence a subsequence of this one? The two sequences must agree on the alt nucleotides, the prefix of the longer must contain the prefix of the shorter, and the suffix of the longer must contain the suffix of the shorter.
[ "Is", "the", "other", "VariantSequence", "a", "subsequence", "of", "this", "one?" ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L67-L77
train
openvax/isovar
isovar/variant_sequences.py
VariantSequence.left_overlaps
def left_overlaps(self, other, min_overlap_size=1): """ Does this VariantSequence overlap another on the left side? """ if self.alt != other.alt: # allele must match! return False if len(other.prefix) > len(self.prefix): # only consider strin...
python
def left_overlaps(self, other, min_overlap_size=1): """ Does this VariantSequence overlap another on the left side? """ if self.alt != other.alt: # allele must match! return False if len(other.prefix) > len(self.prefix): # only consider strin...
[ "def", "left_overlaps", "(", "self", ",", "other", ",", "min_overlap_size", "=", "1", ")", ":", "if", "self", ".", "alt", "!=", "other", ".", "alt", ":", "return", "False", "if", "len", "(", "other", ".", "prefix", ")", ">", "len", "(", "self", "."...
Does this VariantSequence overlap another on the left side?
[ "Does", "this", "VariantSequence", "overlap", "another", "on", "the", "left", "side?" ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L79-L115
train
openvax/isovar
isovar/variant_sequences.py
VariantSequence.add_reads
def add_reads(self, reads): """ Create another VariantSequence with more supporting reads. """ if len(reads) == 0: return self new_reads = self.reads.union(reads) if len(new_reads) > len(self.reads): return VariantSequence( prefix=s...
python
def add_reads(self, reads): """ Create another VariantSequence with more supporting reads. """ if len(reads) == 0: return self new_reads = self.reads.union(reads) if len(new_reads) > len(self.reads): return VariantSequence( prefix=s...
[ "def", "add_reads", "(", "self", ",", "reads", ")", ":", "if", "len", "(", "reads", ")", "==", "0", ":", "return", "self", "new_reads", "=", "self", ".", "reads", ".", "union", "(", "reads", ")", "if", "len", "(", "new_reads", ")", ">", "len", "(...
Create another VariantSequence with more supporting reads.
[ "Create", "another", "VariantSequence", "with", "more", "supporting", "reads", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L117-L131
train
openvax/isovar
isovar/variant_sequences.py
VariantSequence.variant_indices
def variant_indices(self): """ When we combine prefix + alt + suffix into a single string, what are is base-0 index interval which gets us back the alt sequence? First returned index is inclusive, the second is exclusive. """ variant_start_index = len(self.prefix) ...
python
def variant_indices(self): """ When we combine prefix + alt + suffix into a single string, what are is base-0 index interval which gets us back the alt sequence? First returned index is inclusive, the second is exclusive. """ variant_start_index = len(self.prefix) ...
[ "def", "variant_indices", "(", "self", ")", ":", "variant_start_index", "=", "len", "(", "self", ".", "prefix", ")", "variant_len", "=", "len", "(", "self", ".", "alt", ")", "variant_end_index", "=", "variant_start_index", "+", "variant_len", "return", "varian...
When we combine prefix + alt + suffix into a single string, what are is base-0 index interval which gets us back the alt sequence? First returned index is inclusive, the second is exclusive.
[ "When", "we", "combine", "prefix", "+", "alt", "+", "suffix", "into", "a", "single", "string", "what", "are", "is", "base", "-", "0", "index", "interval", "which", "gets", "us", "back", "the", "alt", "sequence?", "First", "returned", "index", "is", "incl...
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L169-L178
train
openvax/isovar
isovar/variant_sequences.py
VariantSequence.coverage
def coverage(self): """ Returns NumPy array indicating number of reads covering each nucleotides of this sequence. """ variant_start_index, variant_end_index = self.variant_indices() n_nucleotides = len(self) coverage_array = np.zeros(n_nucleotides, dtype="int32")...
python
def coverage(self): """ Returns NumPy array indicating number of reads covering each nucleotides of this sequence. """ variant_start_index, variant_end_index = self.variant_indices() n_nucleotides = len(self) coverage_array = np.zeros(n_nucleotides, dtype="int32")...
[ "def", "coverage", "(", "self", ")", ":", "variant_start_index", ",", "variant_end_index", "=", "self", ".", "variant_indices", "(", ")", "n_nucleotides", "=", "len", "(", "self", ")", "coverage_array", "=", "np", ".", "zeros", "(", "n_nucleotides", ",", "dt...
Returns NumPy array indicating number of reads covering each nucleotides of this sequence.
[ "Returns", "NumPy", "array", "indicating", "number", "of", "reads", "covering", "each", "nucleotides", "of", "this", "sequence", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L180-L192
train
openvax/isovar
isovar/variant_sequences.py
VariantSequence.trim_by_coverage
def trim_by_coverage(self, min_reads): """ Given the min number of reads overlapping each nucleotide of a variant sequence, trim this sequence by getting rid of positions which are overlapped by fewer reads than specified. """ read_count_array = self.coverage() lo...
python
def trim_by_coverage(self, min_reads): """ Given the min number of reads overlapping each nucleotide of a variant sequence, trim this sequence by getting rid of positions which are overlapped by fewer reads than specified. """ read_count_array = self.coverage() lo...
[ "def", "trim_by_coverage", "(", "self", ",", "min_reads", ")", ":", "read_count_array", "=", "self", ".", "coverage", "(", ")", "logger", ".", "info", "(", "\"Coverage: %s (len=%d)\"", "%", "(", "read_count_array", ",", "len", "(", "read_count_array", ")", ")"...
Given the min number of reads overlapping each nucleotide of a variant sequence, trim this sequence by getting rid of positions which are overlapped by fewer reads than specified.
[ "Given", "the", "min", "number", "of", "reads", "overlapping", "each", "nucleotide", "of", "a", "variant", "sequence", "trim", "this", "sequence", "by", "getting", "rid", "of", "positions", "which", "are", "overlapped", "by", "fewer", "reads", "than", "specifi...
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequences.py#L200-L242
train
openvax/isovar
isovar/string_helpers.py
trim_N_nucleotides
def trim_N_nucleotides(prefix, suffix): """ Drop all occurrences of 'N' from prefix and suffix nucleotide strings by trimming. """ if 'N' in prefix: # trim prefix to exclude all occurrences of N rightmost_index = prefix.rfind('N') logger.debug( "Trimming %d nucleo...
python
def trim_N_nucleotides(prefix, suffix): """ Drop all occurrences of 'N' from prefix and suffix nucleotide strings by trimming. """ if 'N' in prefix: # trim prefix to exclude all occurrences of N rightmost_index = prefix.rfind('N') logger.debug( "Trimming %d nucleo...
[ "def", "trim_N_nucleotides", "(", "prefix", ",", "suffix", ")", ":", "if", "'N'", "in", "prefix", ":", "rightmost_index", "=", "prefix", ".", "rfind", "(", "'N'", ")", "logger", ".", "debug", "(", "\"Trimming %d nucleotides from read prefix '%s'\"", ",", "rightm...
Drop all occurrences of 'N' from prefix and suffix nucleotide strings by trimming.
[ "Drop", "all", "occurrences", "of", "N", "from", "prefix", "and", "suffix", "nucleotide", "strings", "by", "trimming", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/string_helpers.py#L23-L44
train
openvax/isovar
isovar/string_helpers.py
convert_from_bytes_if_necessary
def convert_from_bytes_if_necessary(prefix, suffix): """ Depending on how we extract data from pysam we may end up with either a string or a byte array of nucleotides. For consistency and simplicity, we want to only use strings in the rest of our code. """ if isinstance(prefix, bytes): p...
python
def convert_from_bytes_if_necessary(prefix, suffix): """ Depending on how we extract data from pysam we may end up with either a string or a byte array of nucleotides. For consistency and simplicity, we want to only use strings in the rest of our code. """ if isinstance(prefix, bytes): p...
[ "def", "convert_from_bytes_if_necessary", "(", "prefix", ",", "suffix", ")", ":", "if", "isinstance", "(", "prefix", ",", "bytes", ")", ":", "prefix", "=", "prefix", ".", "decode", "(", "'ascii'", ")", "if", "isinstance", "(", "suffix", ",", "bytes", ")", ...
Depending on how we extract data from pysam we may end up with either a string or a byte array of nucleotides. For consistency and simplicity, we want to only use strings in the rest of our code.
[ "Depending", "on", "how", "we", "extract", "data", "from", "pysam", "we", "may", "end", "up", "with", "either", "a", "string", "or", "a", "byte", "array", "of", "nucleotides", ".", "For", "consistency", "and", "simplicity", "we", "want", "to", "only", "u...
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/string_helpers.py#L46-L58
train
inveniosoftware/invenio-indexer
invenio_indexer/api.py
Producer.publish
def publish(self, data, **kwargs): """Validate operation type.""" assert data.get('op') in {'index', 'create', 'delete', 'update'} return super(Producer, self).publish(data, **kwargs)
python
def publish(self, data, **kwargs): """Validate operation type.""" assert data.get('op') in {'index', 'create', 'delete', 'update'} return super(Producer, self).publish(data, **kwargs)
[ "def", "publish", "(", "self", ",", "data", ",", "**", "kwargs", ")", ":", "assert", "data", ".", "get", "(", "'op'", ")", "in", "{", "'index'", ",", "'create'", ",", "'delete'", ",", "'update'", "}", "return", "super", "(", "Producer", ",", "self", ...
Validate operation type.
[ "Validate", "operation", "type", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L36-L39
train
inveniosoftware/invenio-indexer
invenio_indexer/api.py
RecordIndexer.index
def index(self, record): """Index a record. The caller is responsible for ensuring that the record has already been committed to the database. If a newer version of a record has already been indexed then the provided record will not be indexed. This behavior can be controlled by...
python
def index(self, record): """Index a record. The caller is responsible for ensuring that the record has already been committed to the database. If a newer version of a record has already been indexed then the provided record will not be indexed. This behavior can be controlled by...
[ "def", "index", "(", "self", ",", "record", ")", ":", "index", ",", "doc_type", "=", "self", ".", "record_to_index", "(", "record", ")", "return", "self", ".", "client", ".", "index", "(", "id", "=", "str", "(", "record", ".", "id", ")", ",", "vers...
Index a record. The caller is responsible for ensuring that the record has already been committed to the database. If a newer version of a record has already been indexed then the provided record will not be indexed. This behavior can be controlled by providing a different ``version_typ...
[ "Index", "a", "record", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L106-L126
train
inveniosoftware/invenio-indexer
invenio_indexer/api.py
RecordIndexer.process_bulk_queue
def process_bulk_queue(self, es_bulk_kwargs=None): """Process bulk indexing queue. :param dict es_bulk_kwargs: Passed to :func:`elasticsearch:elasticsearch.helpers.bulk`. """ with current_celery_app.pool.acquire(block=True) as conn: consumer = Consumer( ...
python
def process_bulk_queue(self, es_bulk_kwargs=None): """Process bulk indexing queue. :param dict es_bulk_kwargs: Passed to :func:`elasticsearch:elasticsearch.helpers.bulk`. """ with current_celery_app.pool.acquire(block=True) as conn: consumer = Consumer( ...
[ "def", "process_bulk_queue", "(", "self", ",", "es_bulk_kwargs", "=", "None", ")", ":", "with", "current_celery_app", ".", "pool", ".", "acquire", "(", "block", "=", "True", ")", "as", "conn", ":", "consumer", "=", "Consumer", "(", "connection", "=", "conn...
Process bulk indexing queue. :param dict es_bulk_kwargs: Passed to :func:`elasticsearch:elasticsearch.helpers.bulk`.
[ "Process", "bulk", "indexing", "queue", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L166-L193
train
inveniosoftware/invenio-indexer
invenio_indexer/api.py
RecordIndexer._bulk_op
def _bulk_op(self, record_id_iterator, op_type, index=None, doc_type=None): """Index record in Elasticsearch asynchronously. :param record_id_iterator: Iterator that yields record UUIDs. :param op_type: Indexing operation (one of ``index``, ``create``, ``delete`` or ``update``). ...
python
def _bulk_op(self, record_id_iterator, op_type, index=None, doc_type=None): """Index record in Elasticsearch asynchronously. :param record_id_iterator: Iterator that yields record UUIDs. :param op_type: Indexing operation (one of ``index``, ``create``, ``delete`` or ``update``). ...
[ "def", "_bulk_op", "(", "self", ",", "record_id_iterator", ",", "op_type", ",", "index", "=", "None", ",", "doc_type", "=", "None", ")", ":", "with", "self", ".", "create_producer", "(", ")", "as", "producer", ":", "for", "rec", "in", "record_id_iterator",...
Index record in Elasticsearch asynchronously. :param record_id_iterator: Iterator that yields record UUIDs. :param op_type: Indexing operation (one of ``index``, ``create``, ``delete`` or ``update``). :param index: The Elasticsearch index. (Default: ``None``) :param doc_type...
[ "Index", "record", "in", "Elasticsearch", "asynchronously", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L209-L225
train
inveniosoftware/invenio-indexer
invenio_indexer/api.py
RecordIndexer._actionsiter
def _actionsiter(self, message_iterator): """Iterate bulk actions. :param message_iterator: Iterator yielding messages from a queue. """ for message in message_iterator: payload = message.decode() try: if payload['op'] == 'delete': ...
python
def _actionsiter(self, message_iterator): """Iterate bulk actions. :param message_iterator: Iterator yielding messages from a queue. """ for message in message_iterator: payload = message.decode() try: if payload['op'] == 'delete': ...
[ "def", "_actionsiter", "(", "self", ",", "message_iterator", ")", ":", "for", "message", "in", "message_iterator", ":", "payload", "=", "message", ".", "decode", "(", ")", "try", ":", "if", "payload", "[", "'op'", "]", "==", "'delete'", ":", "yield", "se...
Iterate bulk actions. :param message_iterator: Iterator yielding messages from a queue.
[ "Iterate", "bulk", "actions", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L227-L246
train
inveniosoftware/invenio-indexer
invenio_indexer/api.py
RecordIndexer._delete_action
def _delete_action(self, payload): """Bulk delete action. :param payload: Decoded message body. :returns: Dictionary defining an Elasticsearch bulk 'delete' action. """ index, doc_type = payload.get('index'), payload.get('doc_type') if not (index and doc_type): ...
python
def _delete_action(self, payload): """Bulk delete action. :param payload: Decoded message body. :returns: Dictionary defining an Elasticsearch bulk 'delete' action. """ index, doc_type = payload.get('index'), payload.get('doc_type') if not (index and doc_type): ...
[ "def", "_delete_action", "(", "self", ",", "payload", ")", ":", "index", ",", "doc_type", "=", "payload", ".", "get", "(", "'index'", ")", ",", "payload", ".", "get", "(", "'doc_type'", ")", "if", "not", "(", "index", "and", "doc_type", ")", ":", "re...
Bulk delete action. :param payload: Decoded message body. :returns: Dictionary defining an Elasticsearch bulk 'delete' action.
[ "Bulk", "delete", "action", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L248-L264
train
inveniosoftware/invenio-indexer
invenio_indexer/api.py
RecordIndexer._index_action
def _index_action(self, payload): """Bulk index action. :param payload: Decoded message body. :returns: Dictionary defining an Elasticsearch bulk 'index' action. """ record = Record.get_record(payload['id']) index, doc_type = self.record_to_index(record) return ...
python
def _index_action(self, payload): """Bulk index action. :param payload: Decoded message body. :returns: Dictionary defining an Elasticsearch bulk 'index' action. """ record = Record.get_record(payload['id']) index, doc_type = self.record_to_index(record) return ...
[ "def", "_index_action", "(", "self", ",", "payload", ")", ":", "record", "=", "Record", ".", "get_record", "(", "payload", "[", "'id'", "]", ")", "index", ",", "doc_type", "=", "self", ".", "record_to_index", "(", "record", ")", "return", "{", "'_op_type...
Bulk index action. :param payload: Decoded message body. :returns: Dictionary defining an Elasticsearch bulk 'index' action.
[ "Bulk", "index", "action", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L266-L283
train
inveniosoftware/invenio-indexer
invenio_indexer/api.py
RecordIndexer._prepare_record
def _prepare_record(record, index, doc_type): """Prepare record data for indexing. :param record: The record to prepare. :param index: The Elasticsearch index. :param doc_type: The Elasticsearch document type. :returns: The record metadata. """ if current_app.con...
python
def _prepare_record(record, index, doc_type): """Prepare record data for indexing. :param record: The record to prepare. :param index: The Elasticsearch index. :param doc_type: The Elasticsearch document type. :returns: The record metadata. """ if current_app.con...
[ "def", "_prepare_record", "(", "record", ",", "index", ",", "doc_type", ")", ":", "if", "current_app", ".", "config", "[", "'INDEXER_REPLACE_REFS'", "]", ":", "data", "=", "copy", ".", "deepcopy", "(", "record", ".", "replace_refs", "(", ")", ")", "else", ...
Prepare record data for indexing. :param record: The record to prepare. :param index: The Elasticsearch index. :param doc_type: The Elasticsearch document type. :returns: The record metadata.
[ "Prepare", "record", "data", "for", "indexing", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/api.py#L286-L313
train
openvax/isovar
isovar/assembly.py
greedy_merge_helper
def greedy_merge_helper( variant_sequences, min_overlap_size=MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE): """ Returns a list of merged VariantSequence objects, and True if any were successfully merged. """ merged_variant_sequences = {} merged_any = False # here we'll keep tr...
python
def greedy_merge_helper( variant_sequences, min_overlap_size=MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE): """ Returns a list of merged VariantSequence objects, and True if any were successfully merged. """ merged_variant_sequences = {} merged_any = False # here we'll keep tr...
[ "def", "greedy_merge_helper", "(", "variant_sequences", ",", "min_overlap_size", "=", "MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE", ")", ":", "merged_variant_sequences", "=", "{", "}", "merged_any", "=", "False", "unmerged_variant_sequences", "=", "set", "(", "variant_seque...
Returns a list of merged VariantSequence objects, and True if any were successfully merged.
[ "Returns", "a", "list", "of", "merged", "VariantSequence", "objects", "and", "True", "if", "any", "were", "successfully", "merged", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/assembly.py#L27-L58
train
openvax/isovar
isovar/assembly.py
greedy_merge
def greedy_merge( variant_sequences, min_overlap_size=MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE): """ Greedily merge overlapping sequences into longer sequences. Accepts a collection of VariantSequence objects and returns another collection of elongated variant sequences. The reads fie...
python
def greedy_merge( variant_sequences, min_overlap_size=MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE): """ Greedily merge overlapping sequences into longer sequences. Accepts a collection of VariantSequence objects and returns another collection of elongated variant sequences. The reads fie...
[ "def", "greedy_merge", "(", "variant_sequences", ",", "min_overlap_size", "=", "MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE", ")", ":", "merged_any", "=", "True", "while", "merged_any", ":", "variant_sequences", ",", "merged_any", "=", "greedy_merge_helper", "(", "variant_...
Greedily merge overlapping sequences into longer sequences. Accepts a collection of VariantSequence objects and returns another collection of elongated variant sequences. The reads field of the returned VariantSequence object will contain reads which only partially overlap the full sequence.
[ "Greedily", "merge", "overlapping", "sequences", "into", "longer", "sequences", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/assembly.py#L60-L76
train
openvax/isovar
isovar/assembly.py
collapse_substrings
def collapse_substrings(variant_sequences): """ Combine shorter sequences which are fully contained in longer sequences. Parameters ---------- variant_sequences : list List of VariantSequence objects Returns a (potentially shorter) list without any contained subsequences. """ if...
python
def collapse_substrings(variant_sequences): """ Combine shorter sequences which are fully contained in longer sequences. Parameters ---------- variant_sequences : list List of VariantSequence objects Returns a (potentially shorter) list without any contained subsequences. """ if...
[ "def", "collapse_substrings", "(", "variant_sequences", ")", ":", "if", "len", "(", "variant_sequences", ")", "<=", "1", ":", "return", "variant_sequences", "extra_reads_from_substrings", "=", "defaultdict", "(", "set", ")", "result_list", "=", "[", "]", "for", ...
Combine shorter sequences which are fully contained in longer sequences. Parameters ---------- variant_sequences : list List of VariantSequence objects Returns a (potentially shorter) list without any contained subsequences.
[ "Combine", "shorter", "sequences", "which", "are", "fully", "contained", "in", "longer", "sequences", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/assembly.py#L78-L116
train
openvax/isovar
isovar/assembly.py
iterative_overlap_assembly
def iterative_overlap_assembly( variant_sequences, min_overlap_size=MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE): """ Assembles longer sequences from reads centered on a variant by between merging all pairs of overlapping sequences and collapsing shorter sequences onto every longer sequen...
python
def iterative_overlap_assembly( variant_sequences, min_overlap_size=MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE): """ Assembles longer sequences from reads centered on a variant by between merging all pairs of overlapping sequences and collapsing shorter sequences onto every longer sequen...
[ "def", "iterative_overlap_assembly", "(", "variant_sequences", ",", "min_overlap_size", "=", "MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE", ")", ":", "if", "len", "(", "variant_sequences", ")", "<=", "1", ":", "return", "variant_sequences", "n_before_collapse", "=", "len",...
Assembles longer sequences from reads centered on a variant by between merging all pairs of overlapping sequences and collapsing shorter sequences onto every longer sequence which contains them. Returns a list of variant sequences, sorted by decreasing read support.
[ "Assembles", "longer", "sequences", "from", "reads", "centered", "on", "a", "variant", "by", "between", "merging", "all", "pairs", "of", "overlapping", "sequences", "and", "collapsing", "shorter", "sequences", "onto", "every", "longer", "sequence", "which", "conta...
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/assembly.py#L118-L146
train
openvax/isovar
isovar/common.py
groupby
def groupby(xs, key_fn): """ Group elements of the list `xs` by keys generated from calling `key_fn`. Returns a dictionary which maps keys to sub-lists of `xs`. """ result = defaultdict(list) for x in xs: key = key_fn(x) result[key].append(x) return result
python
def groupby(xs, key_fn): """ Group elements of the list `xs` by keys generated from calling `key_fn`. Returns a dictionary which maps keys to sub-lists of `xs`. """ result = defaultdict(list) for x in xs: key = key_fn(x) result[key].append(x) return result
[ "def", "groupby", "(", "xs", ",", "key_fn", ")", ":", "result", "=", "defaultdict", "(", "list", ")", "for", "x", "in", "xs", ":", "key", "=", "key_fn", "(", "x", ")", "result", "[", "key", "]", ".", "append", "(", "x", ")", "return", "result" ]
Group elements of the list `xs` by keys generated from calling `key_fn`. Returns a dictionary which maps keys to sub-lists of `xs`.
[ "Group", "elements", "of", "the", "list", "xs", "by", "keys", "generated", "from", "calling", "key_fn", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/common.py#L27-L37
train
bskinn/opan
opan/utils/vector.py
ortho_basis
def ortho_basis(normal, ref_vec=None): """Generates an orthonormal basis in the plane perpendicular to `normal` The orthonormal basis generated spans the plane defined with `normal` as its normal vector. The handedness of `on1` and `on2` in the returned basis is such that: .. math:: ...
python
def ortho_basis(normal, ref_vec=None): """Generates an orthonormal basis in the plane perpendicular to `normal` The orthonormal basis generated spans the plane defined with `normal` as its normal vector. The handedness of `on1` and `on2` in the returned basis is such that: .. math:: ...
[ "def", "ortho_basis", "(", "normal", ",", "ref_vec", "=", "None", ")", ":", "import", "numpy", "as", "np", "from", "scipy", "import", "linalg", "as", "spla", "from", "scipy", "import", "random", "as", "sprnd", "from", ".", ".", "const", "import", "PRM", ...
Generates an orthonormal basis in the plane perpendicular to `normal` The orthonormal basis generated spans the plane defined with `normal` as its normal vector. The handedness of `on1` and `on2` in the returned basis is such that: .. math:: \\mathsf{on1} \\times \\mathsf{on2} = ...
[ "Generates", "an", "orthonormal", "basis", "in", "the", "plane", "perpendicular", "to", "normal" ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L50-L174
train
bskinn/opan
opan/utils/vector.py
orthonorm_check
def orthonorm_check(a, tol=_DEF.ORTHONORM_TOL, report=False): """Checks orthonormality of the column vectors of a matrix. If a one-dimensional |nparray| is passed to `a`, it is treated as a single column vector, rather than a row matrix of length-one column vectors. The matrix `a` does not need to be ...
python
def orthonorm_check(a, tol=_DEF.ORTHONORM_TOL, report=False): """Checks orthonormality of the column vectors of a matrix. If a one-dimensional |nparray| is passed to `a`, it is treated as a single column vector, rather than a row matrix of length-one column vectors. The matrix `a` does not need to be ...
[ "def", "orthonorm_check", "(", "a", ",", "tol", "=", "_DEF", ".", "ORTHONORM_TOL", ",", "report", "=", "False", ")", ":", "import", "numpy", "as", "np", "from", ".", "base", "import", "delta_fxn", "orth", "=", "True", "n_fail", "=", "[", "]", "o_fail",...
Checks orthonormality of the column vectors of a matrix. If a one-dimensional |nparray| is passed to `a`, it is treated as a single column vector, rather than a row matrix of length-one column vectors. The matrix `a` does not need to be square, though it must have at least as many rows as columns, sin...
[ "Checks", "orthonormality", "of", "the", "column", "vectors", "of", "a", "matrix", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L179-L282
train
bskinn/opan
opan/utils/vector.py
parallel_check
def parallel_check(vec1, vec2): """Checks whether two vectors are parallel OR anti-parallel. Vectors must be of the same dimension. Parameters ---------- vec1 length-R |npfloat_| -- First vector to compare vec2 length-R |npfloat_| -- Second vector to compare ...
python
def parallel_check(vec1, vec2): """Checks whether two vectors are parallel OR anti-parallel. Vectors must be of the same dimension. Parameters ---------- vec1 length-R |npfloat_| -- First vector to compare vec2 length-R |npfloat_| -- Second vector to compare ...
[ "def", "parallel_check", "(", "vec1", ",", "vec2", ")", ":", "from", ".", ".", "const", "import", "PRM", "import", "numpy", "as", "np", "par", "=", "False", "for", "n", ",", "v", "in", "enumerate", "(", "[", "vec1", ",", "vec2", "]", ")", ":", "i...
Checks whether two vectors are parallel OR anti-parallel. Vectors must be of the same dimension. Parameters ---------- vec1 length-R |npfloat_| -- First vector to compare vec2 length-R |npfloat_| -- Second vector to compare Returns ------- par ...
[ "Checks", "whether", "two", "vectors", "are", "parallel", "OR", "anti", "-", "parallel", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L288-L335
train
bskinn/opan
opan/utils/vector.py
proj
def proj(vec, vec_onto): """ Vector projection. Calculated as: .. math:: \\mathsf{vec\\_onto} * \\frac{\\mathsf{vec}\\cdot\\mathsf{vec\\_onto}} {\\mathsf{vec\\_onto}\\cdot\\mathsf{vec\\_onto}} Parameters ---------- vec length-R |npfloat_| -- Vector to projec...
python
def proj(vec, vec_onto): """ Vector projection. Calculated as: .. math:: \\mathsf{vec\\_onto} * \\frac{\\mathsf{vec}\\cdot\\mathsf{vec\\_onto}} {\\mathsf{vec\\_onto}\\cdot\\mathsf{vec\\_onto}} Parameters ---------- vec length-R |npfloat_| -- Vector to projec...
[ "def", "proj", "(", "vec", ",", "vec_onto", ")", ":", "import", "numpy", "as", "np", "if", "not", "len", "(", "vec", ".", "shape", ")", "==", "1", ":", "raise", "ValueError", "(", "\"'vec' is not a vector\"", ")", "if", "not", "len", "(", "vec_onto", ...
Vector projection. Calculated as: .. math:: \\mathsf{vec\\_onto} * \\frac{\\mathsf{vec}\\cdot\\mathsf{vec\\_onto}} {\\mathsf{vec\\_onto}\\cdot\\mathsf{vec\\_onto}} Parameters ---------- vec length-R |npfloat_| -- Vector to project vec_onto length-R ...
[ "Vector", "projection", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L341-L386
train
bskinn/opan
opan/utils/vector.py
rej
def rej(vec, vec_onto): """ Vector rejection. Calculated by subtracting from `vec` the projection of `vec` onto `vec_onto`: .. math:: \\mathsf{vec} - \\mathrm{proj}\\left(\\mathsf{vec}, \\ \\mathsf{vec\\_onto}\\right) Parameters ---------- vec length-R |npfloat_| ...
python
def rej(vec, vec_onto): """ Vector rejection. Calculated by subtracting from `vec` the projection of `vec` onto `vec_onto`: .. math:: \\mathsf{vec} - \\mathrm{proj}\\left(\\mathsf{vec}, \\ \\mathsf{vec\\_onto}\\right) Parameters ---------- vec length-R |npfloat_| ...
[ "def", "rej", "(", "vec", ",", "vec_onto", ")", ":", "import", "numpy", "as", "np", "rej_vec", "=", "vec", "-", "proj", "(", "vec", ",", "vec_onto", ")", "return", "rej_vec" ]
Vector rejection. Calculated by subtracting from `vec` the projection of `vec` onto `vec_onto`: .. math:: \\mathsf{vec} - \\mathrm{proj}\\left(\\mathsf{vec}, \\ \\mathsf{vec\\_onto}\\right) Parameters ---------- vec length-R |npfloat_| -- Vector to reject ...
[ "Vector", "rejection", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L392-L426
train
bskinn/opan
opan/utils/vector.py
vec_angle
def vec_angle(vec1, vec2): """ Angle between two R-dimensional vectors. Angle calculated as: .. math:: \\arccos\\left[ \\frac{\\mathsf{vec1}\cdot\\mathsf{vec2}} {\\left\\|\\mathsf{vec1}\\right\\| \\left\\|\\mathsf{vec2}\\right\\|} \\right] Parameters -...
python
def vec_angle(vec1, vec2): """ Angle between two R-dimensional vectors. Angle calculated as: .. math:: \\arccos\\left[ \\frac{\\mathsf{vec1}\cdot\\mathsf{vec2}} {\\left\\|\\mathsf{vec1}\\right\\| \\left\\|\\mathsf{vec2}\\right\\|} \\right] Parameters -...
[ "def", "vec_angle", "(", "vec1", ",", "vec2", ")", ":", "import", "numpy", "as", "np", "from", "scipy", "import", "linalg", "as", "spla", "from", ".", ".", "const", "import", "PRM", "if", "len", "(", "vec1", ".", "shape", ")", "!=", "1", ":", "rais...
Angle between two R-dimensional vectors. Angle calculated as: .. math:: \\arccos\\left[ \\frac{\\mathsf{vec1}\cdot\\mathsf{vec2}} {\\left\\|\\mathsf{vec1}\\right\\| \\left\\|\\mathsf{vec2}\\right\\|} \\right] Parameters ---------- vec1 length-R...
[ "Angle", "between", "two", "R", "-", "dimensional", "vectors", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L432-L499
train
matthewwithanm/django-classbasedsettings
cbsettings/importers.py
new_module
def new_module(name): """ Do all of the gruntwork associated with creating a new module. """ parent = None if '.' in name: parent_name = name.rsplit('.', 1)[0] parent = __import__(parent_name, fromlist=['']) module = imp.new_module(name) sys.modules[name] = module if pa...
python
def new_module(name): """ Do all of the gruntwork associated with creating a new module. """ parent = None if '.' in name: parent_name = name.rsplit('.', 1)[0] parent = __import__(parent_name, fromlist=['']) module = imp.new_module(name) sys.modules[name] = module if pa...
[ "def", "new_module", "(", "name", ")", ":", "parent", "=", "None", "if", "'.'", "in", "name", ":", "parent_name", "=", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "[", "0", "]", "parent", "=", "__import__", "(", "parent_name", ",", "fromlist", ...
Do all of the gruntwork associated with creating a new module.
[ "Do", "all", "of", "the", "gruntwork", "associated", "with", "creating", "a", "new", "module", "." ]
ac9e4362bd1f4954f3e4679b97726cab2b22aea9
https://github.com/matthewwithanm/django-classbasedsettings/blob/ac9e4362bd1f4954f3e4679b97726cab2b22aea9/cbsettings/importers.py#L5-L19
train
openvax/isovar
isovar/allele_counts.py
allele_counts_dataframe
def allele_counts_dataframe(variant_and_allele_reads_generator): """ Creates a DataFrame containing number of reads supporting the ref vs. alt alleles for each variant. """ df_builder = DataFrameBuilder( AlleleCount, extra_column_fns={ "gene": lambda variant, _: ";".join(...
python
def allele_counts_dataframe(variant_and_allele_reads_generator): """ Creates a DataFrame containing number of reads supporting the ref vs. alt alleles for each variant. """ df_builder = DataFrameBuilder( AlleleCount, extra_column_fns={ "gene": lambda variant, _: ";".join(...
[ "def", "allele_counts_dataframe", "(", "variant_and_allele_reads_generator", ")", ":", "df_builder", "=", "DataFrameBuilder", "(", "AlleleCount", ",", "extra_column_fns", "=", "{", "\"gene\"", ":", "lambda", "variant", ",", "_", ":", "\";\"", ".", "join", "(", "va...
Creates a DataFrame containing number of reads supporting the ref vs. alt alleles for each variant.
[ "Creates", "a", "DataFrame", "containing", "number", "of", "reads", "supporting", "the", "ref", "vs", ".", "alt", "alleles", "for", "each", "variant", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/allele_counts.py#L46-L59
train
portfoliome/postpy
postpy/extensions.py
install_extension
def install_extension(conn, extension: str): """Install Postgres extension.""" query = 'CREATE EXTENSION IF NOT EXISTS "%s";' with conn.cursor() as cursor: cursor.execute(query, (AsIs(extension),)) installed = check_extension(conn, extension) if not installed: raise psycopg2.Prog...
python
def install_extension(conn, extension: str): """Install Postgres extension.""" query = 'CREATE EXTENSION IF NOT EXISTS "%s";' with conn.cursor() as cursor: cursor.execute(query, (AsIs(extension),)) installed = check_extension(conn, extension) if not installed: raise psycopg2.Prog...
[ "def", "install_extension", "(", "conn", ",", "extension", ":", "str", ")", ":", "query", "=", "'CREATE EXTENSION IF NOT EXISTS \"%s\";'", "with", "conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "query", ",", "(", "AsIs",...
Install Postgres extension.
[ "Install", "Postgres", "extension", "." ]
fe26199131b15295fc5f669a0ad2a7f47bf490ee
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/extensions.py#L5-L18
train
portfoliome/postpy
postpy/extensions.py
check_extension
def check_extension(conn, extension: str) -> bool: """Check to see if an extension is installed.""" query = 'SELECT installed_version FROM pg_available_extensions WHERE name=%s;' with conn.cursor() as cursor: cursor.execute(query, (extension,)) result = cursor.fetchone() if result is ...
python
def check_extension(conn, extension: str) -> bool: """Check to see if an extension is installed.""" query = 'SELECT installed_version FROM pg_available_extensions WHERE name=%s;' with conn.cursor() as cursor: cursor.execute(query, (extension,)) result = cursor.fetchone() if result is ...
[ "def", "check_extension", "(", "conn", ",", "extension", ":", "str", ")", "->", "bool", ":", "query", "=", "'SELECT installed_version FROM pg_available_extensions WHERE name=%s;'", "with", "conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execu...
Check to see if an extension is installed.
[ "Check", "to", "see", "if", "an", "extension", "is", "installed", "." ]
fe26199131b15295fc5f669a0ad2a7f47bf490ee
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/extensions.py#L21-L37
train
kmike/opencorpora-tools
opencorpora/reader.py
make_iterable
def make_iterable(obj, default=None): """ Ensure obj is iterable. """ if obj is None: return default or [] if isinstance(obj, (compat.string_types, compat.integer_types)): return [obj] return obj
python
def make_iterable(obj, default=None): """ Ensure obj is iterable. """ if obj is None: return default or [] if isinstance(obj, (compat.string_types, compat.integer_types)): return [obj] return obj
[ "def", "make_iterable", "(", "obj", ",", "default", "=", "None", ")", ":", "if", "obj", "is", "None", ":", "return", "default", "or", "[", "]", "if", "isinstance", "(", "obj", ",", "(", "compat", ".", "string_types", ",", "compat", ".", "integer_types"...
Ensure obj is iterable.
[ "Ensure", "obj", "is", "iterable", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L12-L18
train
kmike/opencorpora-tools
opencorpora/reader.py
CorpusReader.iter_documents
def iter_documents(self, fileids=None, categories=None, _destroy=False): """ Return an iterator over corpus documents. """ doc_ids = self._filter_ids(fileids, categories) for doc in imap(self.get_document, doc_ids): yield doc if _destroy: doc.destroy()
python
def iter_documents(self, fileids=None, categories=None, _destroy=False): """ Return an iterator over corpus documents. """ doc_ids = self._filter_ids(fileids, categories) for doc in imap(self.get_document, doc_ids): yield doc if _destroy: doc.destroy()
[ "def", "iter_documents", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ",", "_destroy", "=", "False", ")", ":", "doc_ids", "=", "self", ".", "_filter_ids", "(", "fileids", ",", "categories", ")", "for", "doc", "in", "imap", ...
Return an iterator over corpus documents.
[ "Return", "an", "iterator", "over", "corpus", "documents", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L176-L182
train
kmike/opencorpora-tools
opencorpora/reader.py
CorpusReader._create_meta_cache
def _create_meta_cache(self): """ Try to dump metadata to a file. """ try: with open(self._cache_filename, 'wb') as f: compat.pickle.dump(self._document_meta, f, 1) except (IOError, compat.pickle.PickleError): pass
python
def _create_meta_cache(self): """ Try to dump metadata to a file. """ try: with open(self._cache_filename, 'wb') as f: compat.pickle.dump(self._document_meta, f, 1) except (IOError, compat.pickle.PickleError): pass
[ "def", "_create_meta_cache", "(", "self", ")", ":", "try", ":", "with", "open", "(", "self", ".", "_cache_filename", ",", "'wb'", ")", "as", "f", ":", "compat", ".", "pickle", ".", "dump", "(", "self", ".", "_document_meta", ",", "f", ",", "1", ")", ...
Try to dump metadata to a file.
[ "Try", "to", "dump", "metadata", "to", "a", "file", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L295-L301
train
kmike/opencorpora-tools
opencorpora/reader.py
CorpusReader._load_meta_cache
def _load_meta_cache(self): """ Try to load metadata from file. """ try: if self._should_invalidate_cache(): os.remove(self._cache_filename) else: with open(self._cache_filename, 'rb') as f: self._document_meta = compat.pickle.l...
python
def _load_meta_cache(self): """ Try to load metadata from file. """ try: if self._should_invalidate_cache(): os.remove(self._cache_filename) else: with open(self._cache_filename, 'rb') as f: self._document_meta = compat.pickle.l...
[ "def", "_load_meta_cache", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_should_invalidate_cache", "(", ")", ":", "os", ".", "remove", "(", "self", ".", "_cache_filename", ")", "else", ":", "with", "open", "(", "self", ".", "_cache_filename", "...
Try to load metadata from file.
[ "Try", "to", "load", "metadata", "from", "file", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L303-L313
train
kmike/opencorpora-tools
opencorpora/reader.py
CorpusReader._compute_document_meta
def _compute_document_meta(self): """ Return documents meta information that can be used for fast document lookups. Meta information consists of documents titles, categories and positions in file. """ meta = OrderedDict() bounds_iter = xml_utils.bounds(se...
python
def _compute_document_meta(self): """ Return documents meta information that can be used for fast document lookups. Meta information consists of documents titles, categories and positions in file. """ meta = OrderedDict() bounds_iter = xml_utils.bounds(se...
[ "def", "_compute_document_meta", "(", "self", ")", ":", "meta", "=", "OrderedDict", "(", ")", "bounds_iter", "=", "xml_utils", ".", "bounds", "(", "self", ".", "filename", ",", "start_re", "=", "r'<text id=\"(\\d+)\"[^>]*name=\"([^\"]*)\"'", ",", "end_re", "=", ...
Return documents meta information that can be used for fast document lookups. Meta information consists of documents titles, categories and positions in file.
[ "Return", "documents", "meta", "information", "that", "can", "be", "used", "for", "fast", "document", "lookups", ".", "Meta", "information", "consists", "of", "documents", "titles", "categories", "and", "positions", "in", "file", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L320-L342
train
kmike/opencorpora-tools
opencorpora/reader.py
CorpusReader._document_xml
def _document_xml(self, doc_id): """ Return xml Element for the document document_id. """ doc_str = self._get_doc_by_raw_offset(str(doc_id)) return compat.ElementTree.XML(doc_str.encode('utf8'))
python
def _document_xml(self, doc_id): """ Return xml Element for the document document_id. """ doc_str = self._get_doc_by_raw_offset(str(doc_id)) return compat.ElementTree.XML(doc_str.encode('utf8'))
[ "def", "_document_xml", "(", "self", ",", "doc_id", ")", ":", "doc_str", "=", "self", ".", "_get_doc_by_raw_offset", "(", "str", "(", "doc_id", ")", ")", "return", "compat", ".", "ElementTree", ".", "XML", "(", "doc_str", ".", "encode", "(", "'utf8'", ")...
Return xml Element for the document document_id.
[ "Return", "xml", "Element", "for", "the", "document", "document_id", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L344-L347
train
kmike/opencorpora-tools
opencorpora/reader.py
CorpusReader._get_doc_by_line_offset
def _get_doc_by_line_offset(self, doc_id): """ Load document from xml using line offset information. This is much slower than _get_doc_by_raw_offset but should work everywhere. """ bounds = self._get_meta()[str(doc_id)].bounds return xml_utils.load_chunk(self.file...
python
def _get_doc_by_line_offset(self, doc_id): """ Load document from xml using line offset information. This is much slower than _get_doc_by_raw_offset but should work everywhere. """ bounds = self._get_meta()[str(doc_id)].bounds return xml_utils.load_chunk(self.file...
[ "def", "_get_doc_by_line_offset", "(", "self", ",", "doc_id", ")", ":", "bounds", "=", "self", ".", "_get_meta", "(", ")", "[", "str", "(", "doc_id", ")", "]", ".", "bounds", "return", "xml_utils", ".", "load_chunk", "(", "self", ".", "filename", ",", ...
Load document from xml using line offset information. This is much slower than _get_doc_by_raw_offset but should work everywhere.
[ "Load", "document", "from", "xml", "using", "line", "offset", "information", ".", "This", "is", "much", "slower", "than", "_get_doc_by_raw_offset", "but", "should", "work", "everywhere", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L357-L364
train
pyviz/imagen
imagen/colorspaces.py
_threeDdot_simple
def _threeDdot_simple(M,a): "Return Ma, where M is a 3x3 transformation matrix, for each pixel" result = np.empty(a.shape,dtype=a.dtype) for i in range(a.shape[0]): for j in range(a.shape[1]): A = np.array([a[i,j,0],a[i,j,1],a[i,j,2]]).reshape((3,1)) L = np.dot(M,A) ...
python
def _threeDdot_simple(M,a): "Return Ma, where M is a 3x3 transformation matrix, for each pixel" result = np.empty(a.shape,dtype=a.dtype) for i in range(a.shape[0]): for j in range(a.shape[1]): A = np.array([a[i,j,0],a[i,j,1],a[i,j,2]]).reshape((3,1)) L = np.dot(M,A) ...
[ "def", "_threeDdot_simple", "(", "M", ",", "a", ")", ":", "\"Return Ma, where M is a 3x3 transformation matrix, for each pixel\"", "result", "=", "np", ".", "empty", "(", "a", ".", "shape", ",", "dtype", "=", "a", ".", "dtype", ")", "for", "i", "in", "range", ...
Return Ma, where M is a 3x3 transformation matrix, for each pixel
[ "Return", "Ma", "where", "M", "is", "a", "3x3", "transformation", "matrix", "for", "each", "pixel" ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L49-L62
train
pyviz/imagen
imagen/colorspaces.py
_swaplch
def _swaplch(LCH): "Reverse the order of an LCH numpy dstack or tuple for analysis." try: # Numpy array L,C,H = np.dsplit(LCH,3) return np.dstack((H,C,L)) except: # Tuple L,C,H = LCH return H,C,L
python
def _swaplch(LCH): "Reverse the order of an LCH numpy dstack or tuple for analysis." try: # Numpy array L,C,H = np.dsplit(LCH,3) return np.dstack((H,C,L)) except: # Tuple L,C,H = LCH return H,C,L
[ "def", "_swaplch", "(", "LCH", ")", ":", "\"Reverse the order of an LCH numpy dstack or tuple for analysis.\"", "try", ":", "L", ",", "C", ",", "H", "=", "np", ".", "dsplit", "(", "LCH", ",", "3", ")", "return", "np", ".", "dstack", "(", "(", "H", ",", "...
Reverse the order of an LCH numpy dstack or tuple for analysis.
[ "Reverse", "the", "order", "of", "an", "LCH", "numpy", "dstack", "or", "tuple", "for", "analysis", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L435-L442
train
pyviz/imagen
imagen/colorspaces.py
ColorSpace.rgb_to_hsv
def rgb_to_hsv(self,RGB): "linear rgb to hsv" gammaRGB = self._gamma_rgb(RGB) return self._ABC_to_DEF_by_fn(gammaRGB,rgb_to_hsv)
python
def rgb_to_hsv(self,RGB): "linear rgb to hsv" gammaRGB = self._gamma_rgb(RGB) return self._ABC_to_DEF_by_fn(gammaRGB,rgb_to_hsv)
[ "def", "rgb_to_hsv", "(", "self", ",", "RGB", ")", ":", "\"linear rgb to hsv\"", "gammaRGB", "=", "self", ".", "_gamma_rgb", "(", "RGB", ")", "return", "self", ".", "_ABC_to_DEF_by_fn", "(", "gammaRGB", ",", "rgb_to_hsv", ")" ]
linear rgb to hsv
[ "linear", "rgb", "to", "hsv" ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L413-L416
train
pyviz/imagen
imagen/colorspaces.py
ColorSpace.hsv_to_rgb
def hsv_to_rgb(self,HSV): "hsv to linear rgb" gammaRGB = self._ABC_to_DEF_by_fn(HSV,hsv_to_rgb) return self._ungamma_rgb(gammaRGB)
python
def hsv_to_rgb(self,HSV): "hsv to linear rgb" gammaRGB = self._ABC_to_DEF_by_fn(HSV,hsv_to_rgb) return self._ungamma_rgb(gammaRGB)
[ "def", "hsv_to_rgb", "(", "self", ",", "HSV", ")", ":", "\"hsv to linear rgb\"", "gammaRGB", "=", "self", ".", "_ABC_to_DEF_by_fn", "(", "HSV", ",", "hsv_to_rgb", ")", "return", "self", ".", "_ungamma_rgb", "(", "gammaRGB", ")" ]
hsv to linear rgb
[ "hsv", "to", "linear", "rgb" ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L418-L421
train
pyviz/imagen
imagen/colorspaces.py
ColorConverter.image2working
def image2working(self,i): """Transform images i provided into the specified working color space.""" return self.colorspace.convert(self.image_space, self.working_space, i)
python
def image2working(self,i): """Transform images i provided into the specified working color space.""" return self.colorspace.convert(self.image_space, self.working_space, i)
[ "def", "image2working", "(", "self", ",", "i", ")", ":", "return", "self", ".", "colorspace", ".", "convert", "(", "self", ".", "image_space", ",", "self", ".", "working_space", ",", "i", ")" ]
Transform images i provided into the specified working color space.
[ "Transform", "images", "i", "provided", "into", "the", "specified", "working", "color", "space", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L477-L481
train
pyviz/imagen
imagen/colorspaces.py
ColorConverter.working2analysis
def working2analysis(self,r): "Transform working space inputs to the analysis color space." a = self.colorspace.convert(self.working_space, self.analysis_space, r) return self.swap_polar_HSVorder[self.analysis_space](a)
python
def working2analysis(self,r): "Transform working space inputs to the analysis color space." a = self.colorspace.convert(self.working_space, self.analysis_space, r) return self.swap_polar_HSVorder[self.analysis_space](a)
[ "def", "working2analysis", "(", "self", ",", "r", ")", ":", "\"Transform working space inputs to the analysis color space.\"", "a", "=", "self", ".", "colorspace", ".", "convert", "(", "self", ".", "working_space", ",", "self", ".", "analysis_space", ",", "r", ")"...
Transform working space inputs to the analysis color space.
[ "Transform", "working", "space", "inputs", "to", "the", "analysis", "color", "space", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L483-L486
train
pyviz/imagen
imagen/colorspaces.py
ColorConverter.analysis2working
def analysis2working(self,a): "Convert back from the analysis color space to the working space." a = self.swap_polar_HSVorder[self.analysis_space](a) return self.colorspace.convert(self.analysis_space, self.working_space, a)
python
def analysis2working(self,a): "Convert back from the analysis color space to the working space." a = self.swap_polar_HSVorder[self.analysis_space](a) return self.colorspace.convert(self.analysis_space, self.working_space, a)
[ "def", "analysis2working", "(", "self", ",", "a", ")", ":", "\"Convert back from the analysis color space to the working space.\"", "a", "=", "self", ".", "swap_polar_HSVorder", "[", "self", ".", "analysis_space", "]", "(", "a", ")", "return", "self", ".", "colorspa...
Convert back from the analysis color space to the working space.
[ "Convert", "back", "from", "the", "analysis", "color", "space", "to", "the", "working", "space", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L488-L491
train
kmike/opencorpora-tools
opencorpora/xml_utils.py
load_chunk
def load_chunk(filename, bounds, encoding='utf8', slow=False): """ Load a chunk from file using Bounds info. Pass 'slow=True' for an alternative loading method based on line numbers. """ if slow: return _load_chunk_slow(filename, bounds, encoding) with open(filename, 'rb') as f: ...
python
def load_chunk(filename, bounds, encoding='utf8', slow=False): """ Load a chunk from file using Bounds info. Pass 'slow=True' for an alternative loading method based on line numbers. """ if slow: return _load_chunk_slow(filename, bounds, encoding) with open(filename, 'rb') as f: ...
[ "def", "load_chunk", "(", "filename", ",", "bounds", ",", "encoding", "=", "'utf8'", ",", "slow", "=", "False", ")", ":", "if", "slow", ":", "return", "_load_chunk_slow", "(", "filename", ",", "bounds", ",", "encoding", ")", "with", "open", "(", "filenam...
Load a chunk from file using Bounds info. Pass 'slow=True' for an alternative loading method based on line numbers.
[ "Load", "a", "chunk", "from", "file", "using", "Bounds", "info", ".", "Pass", "slow", "=", "True", "for", "an", "alternative", "loading", "method", "based", "on", "line", "numbers", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/xml_utils.py#L52-L63
train
portfoliome/postpy
postpy/data_types.py
generate_numeric_range
def generate_numeric_range(items, lower_bound, upper_bound): """Generate postgresql numeric range and label for insertion. Parameters ---------- items: iterable labels for ranges. lower_bound: numeric lower bound upper_bound: numeric upper bound """ quantile_grid = create_quantiles(ite...
python
def generate_numeric_range(items, lower_bound, upper_bound): """Generate postgresql numeric range and label for insertion. Parameters ---------- items: iterable labels for ranges. lower_bound: numeric lower bound upper_bound: numeric upper bound """ quantile_grid = create_quantiles(ite...
[ "def", "generate_numeric_range", "(", "items", ",", "lower_bound", ",", "upper_bound", ")", ":", "quantile_grid", "=", "create_quantiles", "(", "items", ",", "lower_bound", ",", "upper_bound", ")", "labels", ",", "bounds", "=", "(", "zip", "(", "*", "quantile_...
Generate postgresql numeric range and label for insertion. Parameters ---------- items: iterable labels for ranges. lower_bound: numeric lower bound upper_bound: numeric upper bound
[ "Generate", "postgresql", "numeric", "range", "and", "label", "for", "insertion", "." ]
fe26199131b15295fc5f669a0ad2a7f47bf490ee
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/data_types.py#L30-L44
train
pyviz/imagen
imagen/image.py
edge_average
def edge_average(a): "Return the mean value around the edge of an array." if len(np.ravel(a)) < 2: return float(a[0]) else: top_edge = a[0] bottom_edge = a[-1] left_edge = a[1:-1,0] right_edge = a[1:-1,-1] edge_sum = np.sum(top_edge) + np.sum(bottom_edge) + ...
python
def edge_average(a): "Return the mean value around the edge of an array." if len(np.ravel(a)) < 2: return float(a[0]) else: top_edge = a[0] bottom_edge = a[-1] left_edge = a[1:-1,0] right_edge = a[1:-1,-1] edge_sum = np.sum(top_edge) + np.sum(bottom_edge) + ...
[ "def", "edge_average", "(", "a", ")", ":", "\"Return the mean value around the edge of an array.\"", "if", "len", "(", "np", ".", "ravel", "(", "a", ")", ")", "<", "2", ":", "return", "float", "(", "a", "[", "0", "]", ")", "else", ":", "top_edge", "=", ...
Return the mean value around the edge of an array.
[ "Return", "the", "mean", "value", "around", "the", "edge", "of", "an", "array", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L206-L220
train
pyviz/imagen
imagen/image.py
GenericImage._process_channels
def _process_channels(self,p,**params_to_override): """ Add the channel information to the channel_data attribute. """ orig_image = self._image for i in range(len(self._channel_data)): self._image = self._original_channel_data[i] self._channel_data[i] = s...
python
def _process_channels(self,p,**params_to_override): """ Add the channel information to the channel_data attribute. """ orig_image = self._image for i in range(len(self._channel_data)): self._image = self._original_channel_data[i] self._channel_data[i] = s...
[ "def", "_process_channels", "(", "self", ",", "p", ",", "**", "params_to_override", ")", ":", "orig_image", "=", "self", ".", "_image", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_channel_data", ")", ")", ":", "self", ".", "_image", "=",...
Add the channel information to the channel_data attribute.
[ "Add", "the", "channel", "information", "to", "the", "channel_data", "attribute", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L322-L332
train
pyviz/imagen
imagen/image.py
FileImage.set_matrix_dimensions
def set_matrix_dimensions(self, *args): """ Subclassed to delete the cached image when matrix dimensions are changed. """ self._image = None super(FileImage, self).set_matrix_dimensions(*args)
python
def set_matrix_dimensions(self, *args): """ Subclassed to delete the cached image when matrix dimensions are changed. """ self._image = None super(FileImage, self).set_matrix_dimensions(*args)
[ "def", "set_matrix_dimensions", "(", "self", ",", "*", "args", ")", ":", "self", ".", "_image", "=", "None", "super", "(", "FileImage", ",", "self", ")", ".", "set_matrix_dimensions", "(", "*", "args", ")" ]
Subclassed to delete the cached image when matrix dimensions are changed.
[ "Subclassed", "to", "delete", "the", "cached", "image", "when", "matrix", "dimensions", "are", "changed", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L425-L431
train
pyviz/imagen
imagen/image.py
FileImage._load_pil_image
def _load_pil_image(self, filename): """ Load image using PIL. """ self._channel_data = [] self._original_channel_data = [] im = Image.open(filename) self._image = ImageOps.grayscale(im) im.load() file_data = np.asarray(im, float) file_da...
python
def _load_pil_image(self, filename): """ Load image using PIL. """ self._channel_data = [] self._original_channel_data = [] im = Image.open(filename) self._image = ImageOps.grayscale(im) im.load() file_data = np.asarray(im, float) file_da...
[ "def", "_load_pil_image", "(", "self", ",", "filename", ")", ":", "self", ".", "_channel_data", "=", "[", "]", "self", ".", "_original_channel_data", "=", "[", "]", "im", "=", "Image", ".", "open", "(", "filename", ")", "self", ".", "_image", "=", "Ima...
Load image using PIL.
[ "Load", "image", "using", "PIL", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L450-L469
train
pyviz/imagen
imagen/image.py
FileImage._load_npy
def _load_npy(self, filename): """ Load image using Numpy. """ self._channel_data = [] self._original_channel_data = [] file_channel_data = np.load(filename) file_channel_data = file_channel_data / file_channel_data.max() for i in range(file_channel_data....
python
def _load_npy(self, filename): """ Load image using Numpy. """ self._channel_data = [] self._original_channel_data = [] file_channel_data = np.load(filename) file_channel_data = file_channel_data / file_channel_data.max() for i in range(file_channel_data....
[ "def", "_load_npy", "(", "self", ",", "filename", ")", ":", "self", ".", "_channel_data", "=", "[", "]", "self", ".", "_original_channel_data", "=", "[", "]", "file_channel_data", "=", "np", ".", "load", "(", "filename", ")", "file_channel_data", "=", "fil...
Load image using Numpy.
[ "Load", "image", "using", "Numpy", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L472-L485
train
bskinn/opan
opan/utils/decorate.py
kwargfetch.ok_kwarg
def ok_kwarg(val): """Helper method for screening keyword arguments""" import keyword try: return str.isidentifier(val) and not keyword.iskeyword(val) except TypeError: # Non-string values are never a valid keyword arg return False
python
def ok_kwarg(val): """Helper method for screening keyword arguments""" import keyword try: return str.isidentifier(val) and not keyword.iskeyword(val) except TypeError: # Non-string values are never a valid keyword arg return False
[ "def", "ok_kwarg", "(", "val", ")", ":", "import", "keyword", "try", ":", "return", "str", ".", "isidentifier", "(", "val", ")", "and", "not", "keyword", ".", "iskeyword", "(", "val", ")", "except", "TypeError", ":", "return", "False" ]
Helper method for screening keyword arguments
[ "Helper", "method", "for", "screening", "keyword", "arguments" ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/decorate.py#L186-L195
train
inveniosoftware/invenio-indexer
invenio_indexer/cli.py
run
def run(delayed, concurrency, version_type=None, queue=None, raise_on_error=True): """Run bulk record indexing.""" if delayed: celery_kwargs = { 'kwargs': { 'version_type': version_type, 'es_bulk_kwargs': {'raise_on_error': raise_on_error}, ...
python
def run(delayed, concurrency, version_type=None, queue=None, raise_on_error=True): """Run bulk record indexing.""" if delayed: celery_kwargs = { 'kwargs': { 'version_type': version_type, 'es_bulk_kwargs': {'raise_on_error': raise_on_error}, ...
[ "def", "run", "(", "delayed", ",", "concurrency", ",", "version_type", "=", "None", ",", "queue", "=", "None", ",", "raise_on_error", "=", "True", ")", ":", "if", "delayed", ":", "celery_kwargs", "=", "{", "'kwargs'", ":", "{", "'version_type'", ":", "ve...
Run bulk record indexing.
[ "Run", "bulk", "record", "indexing", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L43-L63
train
inveniosoftware/invenio-indexer
invenio_indexer/cli.py
reindex
def reindex(pid_type): """Reindex all records. :param pid_type: Pid type. """ click.secho('Sending records to indexing queue ...', fg='green') query = (x[0] for x in PersistentIdentifier.query.filter_by( object_type='rec', status=PIDStatus.REGISTERED ).filter( PersistentIdentif...
python
def reindex(pid_type): """Reindex all records. :param pid_type: Pid type. """ click.secho('Sending records to indexing queue ...', fg='green') query = (x[0] for x in PersistentIdentifier.query.filter_by( object_type='rec', status=PIDStatus.REGISTERED ).filter( PersistentIdentif...
[ "def", "reindex", "(", "pid_type", ")", ":", "click", ".", "secho", "(", "'Sending records to indexing queue ...'", ",", "fg", "=", "'green'", ")", "query", "=", "(", "x", "[", "0", "]", "for", "x", "in", "PersistentIdentifier", ".", "query", ".", "filter_...
Reindex all records. :param pid_type: Pid type.
[ "Reindex", "all", "records", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L72-L88
train
inveniosoftware/invenio-indexer
invenio_indexer/cli.py
process_actions
def process_actions(actions): """Process queue actions.""" queue = current_app.config['INDEXER_MQ_QUEUE'] with establish_connection() as c: q = queue(c) for action in actions: q = action(q)
python
def process_actions(actions): """Process queue actions.""" queue = current_app.config['INDEXER_MQ_QUEUE'] with establish_connection() as c: q = queue(c) for action in actions: q = action(q)
[ "def", "process_actions", "(", "actions", ")", ":", "queue", "=", "current_app", ".", "config", "[", "'INDEXER_MQ_QUEUE'", "]", "with", "establish_connection", "(", ")", "as", "c", ":", "q", "=", "queue", "(", "c", ")", "for", "action", "in", "actions", ...
Process queue actions.
[ "Process", "queue", "actions", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L98-L104
train
inveniosoftware/invenio-indexer
invenio_indexer/cli.py
init_queue
def init_queue(): """Initialize indexing queue.""" def action(queue): queue.declare() click.secho('Indexing queue has been initialized.', fg='green') return queue return action
python
def init_queue(): """Initialize indexing queue.""" def action(queue): queue.declare() click.secho('Indexing queue has been initialized.', fg='green') return queue return action
[ "def", "init_queue", "(", ")", ":", "def", "action", "(", "queue", ")", ":", "queue", ".", "declare", "(", ")", "click", ".", "secho", "(", "'Indexing queue has been initialized.'", ",", "fg", "=", "'green'", ")", "return", "queue", "return", "action" ]
Initialize indexing queue.
[ "Initialize", "indexing", "queue", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L108-L114
train
inveniosoftware/invenio-indexer
invenio_indexer/cli.py
purge_queue
def purge_queue(): """Purge indexing queue.""" def action(queue): queue.purge() click.secho('Indexing queue has been purged.', fg='green') return queue return action
python
def purge_queue(): """Purge indexing queue.""" def action(queue): queue.purge() click.secho('Indexing queue has been purged.', fg='green') return queue return action
[ "def", "purge_queue", "(", ")", ":", "def", "action", "(", "queue", ")", ":", "queue", ".", "purge", "(", ")", "click", ".", "secho", "(", "'Indexing queue has been purged.'", ",", "fg", "=", "'green'", ")", "return", "queue", "return", "action" ]
Purge indexing queue.
[ "Purge", "indexing", "queue", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L118-L124
train
inveniosoftware/invenio-indexer
invenio_indexer/cli.py
delete_queue
def delete_queue(): """Delete indexing queue.""" def action(queue): queue.delete() click.secho('Indexing queue has been deleted.', fg='green') return queue return action
python
def delete_queue(): """Delete indexing queue.""" def action(queue): queue.delete() click.secho('Indexing queue has been deleted.', fg='green') return queue return action
[ "def", "delete_queue", "(", ")", ":", "def", "action", "(", "queue", ")", ":", "queue", ".", "delete", "(", ")", "click", ".", "secho", "(", "'Indexing queue has been deleted.'", ",", "fg", "=", "'green'", ")", "return", "queue", "return", "action" ]
Delete indexing queue.
[ "Delete", "indexing", "queue", "." ]
1460aa8976b449d9a3a99d356322b158e9be6f80
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L128-L134
train
openvax/isovar
isovar/reference_sequence_key.py
variant_matches_reference_sequence
def variant_matches_reference_sequence(variant, ref_seq_on_transcript, strand): """ Make sure that reference nucleotides we expect to see on the reference transcript from a variant are the same ones we encounter. """ if strand == "-": ref_seq_on_transcript = reverse_complement_dna(ref_seq_on...
python
def variant_matches_reference_sequence(variant, ref_seq_on_transcript, strand): """ Make sure that reference nucleotides we expect to see on the reference transcript from a variant are the same ones we encounter. """ if strand == "-": ref_seq_on_transcript = reverse_complement_dna(ref_seq_on...
[ "def", "variant_matches_reference_sequence", "(", "variant", ",", "ref_seq_on_transcript", ",", "strand", ")", ":", "if", "strand", "==", "\"-\"", ":", "ref_seq_on_transcript", "=", "reverse_complement_dna", "(", "ref_seq_on_transcript", ")", "return", "ref_seq_on_transcr...
Make sure that reference nucleotides we expect to see on the reference transcript from a variant are the same ones we encounter.
[ "Make", "sure", "that", "reference", "nucleotides", "we", "expect", "to", "see", "on", "the", "reference", "transcript", "from", "a", "variant", "are", "the", "same", "ones", "we", "encounter", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/reference_sequence_key.py#L131-L138
train
openvax/isovar
isovar/reference_sequence_key.py
ReferenceSequenceKey.from_variant_and_transcript
def from_variant_and_transcript( cls, variant, transcript, context_size): """ Extracts the reference sequence around a variant locus on a particular transcript. Parameters ---------- variant : varcode.Variant transcript : pyensembl.Transcript ...
python
def from_variant_and_transcript( cls, variant, transcript, context_size): """ Extracts the reference sequence around a variant locus on a particular transcript. Parameters ---------- variant : varcode.Variant transcript : pyensembl.Transcript ...
[ "def", "from_variant_and_transcript", "(", "cls", ",", "variant", ",", "transcript", ",", "context_size", ")", ":", "full_transcript_sequence", "=", "transcript", ".", "sequence", "if", "full_transcript_sequence", "is", "None", ":", "logger", ".", "warn", "(", "\"...
Extracts the reference sequence around a variant locus on a particular transcript. Parameters ---------- variant : varcode.Variant transcript : pyensembl.Transcript context_size : int Returns SequenceKey object. Can also return None if Transcript lack...
[ "Extracts", "the", "reference", "sequence", "around", "a", "variant", "locus", "on", "a", "particular", "transcript", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/reference_sequence_key.py#L51-L128
train
pyviz/imagen
imagen/__init__.py
wrap
def wrap(lower, upper, x): """ Circularly alias the numeric value x into the range [lower,upper). Valid for cyclic quantities like orientations or hues. """ #I have no idea how I came up with this algorithm; it should be simplified. # # Note that Python's % operator works on floats and arra...
python
def wrap(lower, upper, x): """ Circularly alias the numeric value x into the range [lower,upper). Valid for cyclic quantities like orientations or hues. """ #I have no idea how I came up with this algorithm; it should be simplified. # # Note that Python's % operator works on floats and arra...
[ "def", "wrap", "(", "lower", ",", "upper", ",", "x", ")", ":", "range_", "=", "upper", "-", "lower", "return", "lower", "+", "np", ".", "fmod", "(", "x", "-", "lower", "+", "2", "*", "range_", "*", "(", "1", "-", "np", ".", "floor", "(", "x",...
Circularly alias the numeric value x into the range [lower,upper). Valid for cyclic quantities like orientations or hues.
[ "Circularly", "alias", "the", "numeric", "value", "x", "into", "the", "range", "[", "lower", "upper", ")", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L503-L515
train
pyviz/imagen
imagen/__init__.py
Line._pixelsize
def _pixelsize(self, p): """Calculate line width necessary to cover at least one pixel on all axes.""" xpixelsize = 1./float(p.xdensity) ypixelsize = 1./float(p.ydensity) return max([xpixelsize,ypixelsize])
python
def _pixelsize(self, p): """Calculate line width necessary to cover at least one pixel on all axes.""" xpixelsize = 1./float(p.xdensity) ypixelsize = 1./float(p.ydensity) return max([xpixelsize,ypixelsize])
[ "def", "_pixelsize", "(", "self", ",", "p", ")", ":", "xpixelsize", "=", "1.", "/", "float", "(", "p", ".", "xdensity", ")", "ypixelsize", "=", "1.", "/", "float", "(", "p", ".", "ydensity", ")", "return", "max", "(", "[", "xpixelsize", ",", "ypixe...
Calculate line width necessary to cover at least one pixel on all axes.
[ "Calculate", "line", "width", "necessary", "to", "cover", "at", "least", "one", "pixel", "on", "all", "axes", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L199-L203
train
pyviz/imagen
imagen/__init__.py
Line._count_pixels_on_line
def _count_pixels_on_line(self, y, p): """Count the number of pixels rendered on this line.""" h = line(y, self._effective_thickness(p), 0.0) return h.sum()
python
def _count_pixels_on_line(self, y, p): """Count the number of pixels rendered on this line.""" h = line(y, self._effective_thickness(p), 0.0) return h.sum()
[ "def", "_count_pixels_on_line", "(", "self", ",", "y", ",", "p", ")", ":", "h", "=", "line", "(", "y", ",", "self", ".", "_effective_thickness", "(", "p", ")", ",", "0.0", ")", "return", "h", ".", "sum", "(", ")" ]
Count the number of pixels rendered on this line.
[ "Count", "the", "number", "of", "pixels", "rendered", "on", "this", "line", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L209-L212
train
pyviz/imagen
imagen/__init__.py
Selector.num_channels
def num_channels(self): """ Get the number of channels in the input generators. """ if(self.inspect_value('index') is None): if(len(self.generators)>0): return self.generators[0].num_channels() return 0 return self.get_current_generator()....
python
def num_channels(self): """ Get the number of channels in the input generators. """ if(self.inspect_value('index') is None): if(len(self.generators)>0): return self.generators[0].num_channels() return 0 return self.get_current_generator()....
[ "def", "num_channels", "(", "self", ")", ":", "if", "(", "self", ".", "inspect_value", "(", "'index'", ")", "is", "None", ")", ":", "if", "(", "len", "(", "self", ".", "generators", ")", ">", "0", ")", ":", "return", "self", ".", "generators", "[",...
Get the number of channels in the input generators.
[ "Get", "the", "number", "of", "channels", "in", "the", "input", "generators", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L567-L576
train
pyviz/imagen
imagen/__init__.py
PowerSpectrum._set_frequency_spacing
def _set_frequency_spacing(self, min_freq, max_freq): """ Frequency spacing to use, i.e. how to map the available frequency range to the discrete sheet rows. NOTE: We're calculating the spacing of a range between the highest and lowest frequencies, the actual segmentation and ...
python
def _set_frequency_spacing(self, min_freq, max_freq): """ Frequency spacing to use, i.e. how to map the available frequency range to the discrete sheet rows. NOTE: We're calculating the spacing of a range between the highest and lowest frequencies, the actual segmentation and ...
[ "def", "_set_frequency_spacing", "(", "self", ",", "min_freq", ",", "max_freq", ")", ":", "self", ".", "frequency_spacing", "=", "np", ".", "linspace", "(", "min_freq", ",", "max_freq", ",", "num", "=", "self", ".", "_sheet_dimensions", "[", "0", "]", "+",...
Frequency spacing to use, i.e. how to map the available frequency range to the discrete sheet rows. NOTE: We're calculating the spacing of a range between the highest and lowest frequencies, the actual segmentation and averaging of the frequencies to fit this spacing occurs in _...
[ "Frequency", "spacing", "to", "use", "i", ".", "e", ".", "how", "to", "map", "the", "available", "frequency", "range", "to", "the", "discrete", "sheet", "rows", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L1401-L1415
train
portfoliome/postpy
postpy/pg_encodings.py
get_postgres_encoding
def get_postgres_encoding(python_encoding: str) -> str: """Python to postgres encoding map.""" encoding = normalize_encoding(python_encoding.lower()) encoding_ = aliases.aliases[encoding.replace('_', '', 1)].upper() pg_encoding = PG_ENCODING_MAP[encoding_.replace('_', '')] return pg_encoding
python
def get_postgres_encoding(python_encoding: str) -> str: """Python to postgres encoding map.""" encoding = normalize_encoding(python_encoding.lower()) encoding_ = aliases.aliases[encoding.replace('_', '', 1)].upper() pg_encoding = PG_ENCODING_MAP[encoding_.replace('_', '')] return pg_encoding
[ "def", "get_postgres_encoding", "(", "python_encoding", ":", "str", ")", "->", "str", ":", "encoding", "=", "normalize_encoding", "(", "python_encoding", ".", "lower", "(", ")", ")", "encoding_", "=", "aliases", ".", "aliases", "[", "encoding", ".", "replace",...
Python to postgres encoding map.
[ "Python", "to", "postgres", "encoding", "map", "." ]
fe26199131b15295fc5f669a0ad2a7f47bf490ee
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/pg_encodings.py#L15-L22
train
bskinn/opan
opan/output.py
OrcaOutput.en_last
def en_last(self): """ Report the energies from the last SCF present in the output. Returns a |dict| providing the various energy values from the last SCF cycle performed in the output. Keys are those of :attr:`~opan.output.OrcaOutput.p_en`. Any energy value not relevant to the ...
python
def en_last(self): """ Report the energies from the last SCF present in the output. Returns a |dict| providing the various energy values from the last SCF cycle performed in the output. Keys are those of :attr:`~opan.output.OrcaOutput.p_en`. Any energy value not relevant to the ...
[ "def", "en_last", "(", "self", ")", ":", "last_ens", "=", "dict", "(", ")", "for", "(", "k", ",", "l", ")", "in", "self", ".", "en", ".", "items", "(", ")", ":", "last_ens", ".", "update", "(", "{", "k", ":", "l", "[", "-", "1", "]", "if", ...
Report the energies from the last SCF present in the output. Returns a |dict| providing the various energy values from the last SCF cycle performed in the output. Keys are those of :attr:`~opan.output.OrcaOutput.p_en`. Any energy value not relevant to the parsed output is assign...
[ "Report", "the", "energies", "from", "the", "last", "SCF", "present", "in", "the", "output", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/output.py#L792-L818
train
portfoliome/postpy
postpy/connections.py
connect
def connect(host=None, database=None, user=None, password=None, **kwargs): """Create a database connection.""" host = host or os.environ['PGHOST'] database = database or os.environ['PGDATABASE'] user = user or os.environ['PGUSER'] password = password or os.environ['PGPASSWORD'] return psycopg2...
python
def connect(host=None, database=None, user=None, password=None, **kwargs): """Create a database connection.""" host = host or os.environ['PGHOST'] database = database or os.environ['PGDATABASE'] user = user or os.environ['PGUSER'] password = password or os.environ['PGPASSWORD'] return psycopg2...
[ "def", "connect", "(", "host", "=", "None", ",", "database", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "**", "kwargs", ")", ":", "host", "=", "host", "or", "os", ".", "environ", "[", "'PGHOST'", "]", "database", "=",...
Create a database connection.
[ "Create", "a", "database", "connection", "." ]
fe26199131b15295fc5f669a0ad2a7f47bf490ee
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/connections.py#L8-L20
train
happyleavesaoc/python-orvibo
orvibo/s20.py
_setup
def _setup(): """ Set up module. Open a UDP socket, and listen in a thread. """ _SOCKET.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) _SOCKET.bind(('', PORT)) udp = threading.Thread(target=_listen, daemon=True) udp.start()
python
def _setup(): """ Set up module. Open a UDP socket, and listen in a thread. """ _SOCKET.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) _SOCKET.bind(('', PORT)) udp = threading.Thread(target=_listen, daemon=True) udp.start()
[ "def", "_setup", "(", ")", ":", "_SOCKET", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_BROADCAST", ",", "1", ")", "_SOCKET", ".", "bind", "(", "(", "''", ",", "PORT", ")", ")", "udp", "=", "threading", ".", "Thread", ...
Set up module. Open a UDP socket, and listen in a thread.
[ "Set", "up", "module", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L50-L58
train
happyleavesaoc/python-orvibo
orvibo/s20.py
discover
def discover(timeout=DISCOVERY_TIMEOUT): """ Discover devices on the local network. :param timeout: Optional timeout in seconds. :returns: Set of discovered host addresses. """ hosts = {} payload = MAGIC + DISCOVERY for _ in range(RETRIES): _SOCKET.sendto(bytearray(payload), ('255.2...
python
def discover(timeout=DISCOVERY_TIMEOUT): """ Discover devices on the local network. :param timeout: Optional timeout in seconds. :returns: Set of discovered host addresses. """ hosts = {} payload = MAGIC + DISCOVERY for _ in range(RETRIES): _SOCKET.sendto(bytearray(payload), ('255.2...
[ "def", "discover", "(", "timeout", "=", "DISCOVERY_TIMEOUT", ")", ":", "hosts", "=", "{", "}", "payload", "=", "MAGIC", "+", "DISCOVERY", "for", "_", "in", "range", "(", "RETRIES", ")", ":", "_SOCKET", ".", "sendto", "(", "bytearray", "(", "payload", "...
Discover devices on the local network. :param timeout: Optional timeout in seconds. :returns: Set of discovered host addresses.
[ "Discover", "devices", "on", "the", "local", "network", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L66-L91
train
happyleavesaoc/python-orvibo
orvibo/s20.py
S20._discover_mac
def _discover_mac(self): """ Discovers MAC address of device. Discovery is done by sending a UDP broadcast. All configured devices reply. The response contains the MAC address in both needed formats. Discovery of multiple switches must be done synchronously. :returns: ...
python
def _discover_mac(self): """ Discovers MAC address of device. Discovery is done by sending a UDP broadcast. All configured devices reply. The response contains the MAC address in both needed formats. Discovery of multiple switches must be done synchronously. :returns: ...
[ "def", "_discover_mac", "(", "self", ")", ":", "mac", "=", "None", "mac_reversed", "=", "None", "cmd", "=", "MAGIC", "+", "DISCOVERY", "resp", "=", "self", ".", "_udp_transact", "(", "cmd", ",", "self", ".", "_discovery_resp", ",", "broadcast", "=", "Tru...
Discovers MAC address of device. Discovery is done by sending a UDP broadcast. All configured devices reply. The response contains the MAC address in both needed formats. Discovery of multiple switches must be done synchronously. :returns: Tuple of MAC address and reversed MAC...
[ "Discovers", "MAC", "address", "of", "device", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L167-L188
train
happyleavesaoc/python-orvibo
orvibo/s20.py
S20._subscribe
def _subscribe(self): """ Subscribe to the device. A subscription serves two purposes: - Returns state (on/off). - Enables state changes on the device for a short period of time. """ cmd = MAGIC + SUBSCRIBE + self._mac \ + PADDING_1 + self._mac_reve...
python
def _subscribe(self): """ Subscribe to the device. A subscription serves two purposes: - Returns state (on/off). - Enables state changes on the device for a short period of time. """ cmd = MAGIC + SUBSCRIBE + self._mac \ + PADDING_1 + self._mac_reve...
[ "def", "_subscribe", "(", "self", ")", ":", "cmd", "=", "MAGIC", "+", "SUBSCRIBE", "+", "self", ".", "_mac", "+", "PADDING_1", "+", "self", ".", "_mac_reversed", "+", "PADDING_1", "status", "=", "self", ".", "_udp_transact", "(", "cmd", ",", "self", "....
Subscribe to the device. A subscription serves two purposes: - Returns state (on/off). - Enables state changes on the device for a short period of time.
[ "Subscribe", "to", "the", "device", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L190-L206
train
happyleavesaoc/python-orvibo
orvibo/s20.py
S20._control
def _control(self, state): """ Control device state. Possible states are ON or OFF. :param state: Switch to this state. """ # Renew subscription if necessary if not self._subscription_is_recent(): self._subscribe() cmd = MAGIC + CONTROL + self._mac...
python
def _control(self, state): """ Control device state. Possible states are ON or OFF. :param state: Switch to this state. """ # Renew subscription if necessary if not self._subscription_is_recent(): self._subscribe() cmd = MAGIC + CONTROL + self._mac...
[ "def", "_control", "(", "self", ",", "state", ")", ":", "if", "not", "self", ".", "_subscription_is_recent", "(", ")", ":", "self", ".", "_subscribe", "(", ")", "cmd", "=", "MAGIC", "+", "CONTROL", "+", "self", ".", "_mac", "+", "PADDING_1", "+", "PA...
Control device state. Possible states are ON or OFF. :param state: Switch to this state.
[ "Control", "device", "state", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L215-L233
train
happyleavesaoc/python-orvibo
orvibo/s20.py
S20._discovery_resp
def _discovery_resp(self, data): """ Handle a discovery response. :param data: Payload. :param addr: Address tuple. :returns: MAC and reversed MAC. """ if _is_discovery_response(data): _LOGGER.debug("Discovered MAC of %s: %s", self.host, ...
python
def _discovery_resp(self, data): """ Handle a discovery response. :param data: Payload. :param addr: Address tuple. :returns: MAC and reversed MAC. """ if _is_discovery_response(data): _LOGGER.debug("Discovered MAC of %s: %s", self.host, ...
[ "def", "_discovery_resp", "(", "self", ",", "data", ")", ":", "if", "_is_discovery_response", "(", "data", ")", ":", "_LOGGER", ".", "debug", "(", "\"Discovered MAC of %s: %s\"", ",", "self", ".", "host", ",", "binascii", ".", "hexlify", "(", "data", "[", ...
Handle a discovery response. :param data: Payload. :param addr: Address tuple. :returns: MAC and reversed MAC.
[ "Handle", "a", "discovery", "response", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L235-L245
train
happyleavesaoc/python-orvibo
orvibo/s20.py
S20._subscribe_resp
def _subscribe_resp(self, data): """ Handle a subscribe response. :param data: Payload. :returns: State (ON/OFF) """ if _is_subscribe_response(data): status = bytes([data[23]]) _LOGGER.debug("Successfully subscribed to %s, state: %s", ...
python
def _subscribe_resp(self, data): """ Handle a subscribe response. :param data: Payload. :returns: State (ON/OFF) """ if _is_subscribe_response(data): status = bytes([data[23]]) _LOGGER.debug("Successfully subscribed to %s, state: %s", ...
[ "def", "_subscribe_resp", "(", "self", ",", "data", ")", ":", "if", "_is_subscribe_response", "(", "data", ")", ":", "status", "=", "bytes", "(", "[", "data", "[", "23", "]", "]", ")", "_LOGGER", ".", "debug", "(", "\"Successfully subscribed to %s, state: %s...
Handle a subscribe response. :param data: Payload. :returns: State (ON/OFF)
[ "Handle", "a", "subscribe", "response", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L247-L257
train
happyleavesaoc/python-orvibo
orvibo/s20.py
S20._control_resp
def _control_resp(self, data, state): """ Handle a control response. :param data: Payload. :param state: Requested state. :returns: Acknowledged state. """ if _is_control_response(data): ack_state = bytes([data[22]]) if state == ack_state: ...
python
def _control_resp(self, data, state): """ Handle a control response. :param data: Payload. :param state: Requested state. :returns: Acknowledged state. """ if _is_control_response(data): ack_state = bytes([data[22]]) if state == ack_state: ...
[ "def", "_control_resp", "(", "self", ",", "data", ",", "state", ")", ":", "if", "_is_control_response", "(", "data", ")", ":", "ack_state", "=", "bytes", "(", "[", "data", "[", "22", "]", "]", ")", "if", "state", "==", "ack_state", ":", "_LOGGER", "....
Handle a control response. :param data: Payload. :param state: Requested state. :returns: Acknowledged state.
[ "Handle", "a", "control", "response", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L259-L271
train
happyleavesaoc/python-orvibo
orvibo/s20.py
S20._udp_transact
def _udp_transact(self, payload, handler, *args, broadcast=False, timeout=TIMEOUT): """ Complete a UDP transaction. UDP is stateless and not guaranteed, so we have to take some mitigation steps: - Send payload multiple times. - Wait for awhile to receive re...
python
def _udp_transact(self, payload, handler, *args, broadcast=False, timeout=TIMEOUT): """ Complete a UDP transaction. UDP is stateless and not guaranteed, so we have to take some mitigation steps: - Send payload multiple times. - Wait for awhile to receive re...
[ "def", "_udp_transact", "(", "self", ",", "payload", ",", "handler", ",", "*", "args", ",", "broadcast", "=", "False", ",", "timeout", "=", "TIMEOUT", ")", ":", "if", "self", ".", "host", "in", "_BUFFER", ":", "del", "_BUFFER", "[", "self", ".", "hos...
Complete a UDP transaction. UDP is stateless and not guaranteed, so we have to take some mitigation steps: - Send payload multiple times. - Wait for awhile to receive response. :param payload: Payload to send. :param handler: Response handler. :param args: Argum...
[ "Complete", "a", "UDP", "transaction", "." ]
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L273-L303
train
kmike/opencorpora-tools
opencorpora/reader_lxml.py
load
def load(source): """ Load OpenCorpora corpus. The ``source`` can be any of the following: - a file name/path - a file object - a file-like object - a URL using the HTTP or FTP protocol """ parser = get_xml_parser() return etree.parse(source, parser=parser).getroot()
python
def load(source): """ Load OpenCorpora corpus. The ``source`` can be any of the following: - a file name/path - a file object - a file-like object - a URL using the HTTP or FTP protocol """ parser = get_xml_parser() return etree.parse(source, parser=parser).getroot()
[ "def", "load", "(", "source", ")", ":", "parser", "=", "get_xml_parser", "(", ")", "return", "etree", ".", "parse", "(", "source", ",", "parser", "=", "parser", ")", ".", "getroot", "(", ")" ]
Load OpenCorpora corpus. The ``source`` can be any of the following: - a file name/path - a file object - a file-like object - a URL using the HTTP or FTP protocol
[ "Load", "OpenCorpora", "corpus", "." ]
26fee106aea1180d2975b3825dcf9b3875e80db1
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader_lxml.py#L11-L24
train
openvax/isovar
isovar/translation.py
translation_generator
def translation_generator( variant_sequences, reference_contexts, min_transcript_prefix_length, max_transcript_mismatches, include_mismatches_after_variant, protein_sequence_length=None): """ Given all detected VariantSequence objects for a particular variant ...
python
def translation_generator( variant_sequences, reference_contexts, min_transcript_prefix_length, max_transcript_mismatches, include_mismatches_after_variant, protein_sequence_length=None): """ Given all detected VariantSequence objects for a particular variant ...
[ "def", "translation_generator", "(", "variant_sequences", ",", "reference_contexts", ",", "min_transcript_prefix_length", ",", "max_transcript_mismatches", ",", "include_mismatches_after_variant", ",", "protein_sequence_length", "=", "None", ")", ":", "for", "reference_context"...
Given all detected VariantSequence objects for a particular variant and all the ReferenceContext objects for that locus, translate multiple protein sequences, up to the number specified by the argument max_protein_sequences_per_variant. Parameters ---------- variant_sequences : list of VariantS...
[ "Given", "all", "detected", "VariantSequence", "objects", "for", "a", "particular", "variant", "and", "all", "the", "ReferenceContext", "objects", "for", "that", "locus", "translate", "multiple", "protein", "sequences", "up", "to", "the", "number", "specified", "b...
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L355-L405
train
openvax/isovar
isovar/translation.py
translate_variant_reads
def translate_variant_reads( variant, variant_reads, protein_sequence_length, transcript_id_whitelist=None, min_alt_rna_reads=MIN_ALT_RNA_READS, min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE, min_transcript_prefix_length=MIN_TRANSCRIPT_PREFIX_LENGTH,...
python
def translate_variant_reads( variant, variant_reads, protein_sequence_length, transcript_id_whitelist=None, min_alt_rna_reads=MIN_ALT_RNA_READS, min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE, min_transcript_prefix_length=MIN_TRANSCRIPT_PREFIX_LENGTH,...
[ "def", "translate_variant_reads", "(", "variant", ",", "variant_reads", ",", "protein_sequence_length", ",", "transcript_id_whitelist", "=", "None", ",", "min_alt_rna_reads", "=", "MIN_ALT_RNA_READS", ",", "min_variant_sequence_coverage", "=", "MIN_VARIANT_SEQUENCE_COVERAGE", ...
Given a variant and its associated alt reads, construct variant sequences and translate them into Translation objects. Returns 0 or more Translation objects. Parameters ---------- variant : varcode.Variant variant_reads : sequence or generator AlleleRead objects supporting the variant...
[ "Given", "a", "variant", "and", "its", "associated", "alt", "reads", "construct", "variant", "sequences", "and", "translate", "them", "into", "Translation", "objects", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L408-L505
train
openvax/isovar
isovar/translation.py
Translation.as_translation_key
def as_translation_key(self): """ Project Translation object or any other derived class into just a TranslationKey, which has fewer fields and can be used as a dictionary key. """ return TranslationKey(**{ name: getattr(self, name) for name in Tran...
python
def as_translation_key(self): """ Project Translation object or any other derived class into just a TranslationKey, which has fewer fields and can be used as a dictionary key. """ return TranslationKey(**{ name: getattr(self, name) for name in Tran...
[ "def", "as_translation_key", "(", "self", ")", ":", "return", "TranslationKey", "(", "**", "{", "name", ":", "getattr", "(", "self", ",", "name", ")", "for", "name", "in", "TranslationKey", ".", "_fields", "}", ")" ]
Project Translation object or any other derived class into just a TranslationKey, which has fewer fields and can be used as a dictionary key.
[ "Project", "Translation", "object", "or", "any", "other", "derived", "class", "into", "just", "a", "TranslationKey", "which", "has", "fewer", "fields", "and", "can", "be", "used", "as", "a", "dictionary", "key", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L150-L158
train
openvax/isovar
isovar/translation.py
Translation.from_variant_sequence_and_reference_context
def from_variant_sequence_and_reference_context( cls, variant_sequence, reference_context, min_transcript_prefix_length, max_transcript_mismatches, include_mismatches_after_variant, protein_sequence_length=None): """ Att...
python
def from_variant_sequence_and_reference_context( cls, variant_sequence, reference_context, min_transcript_prefix_length, max_transcript_mismatches, include_mismatches_after_variant, protein_sequence_length=None): """ Att...
[ "def", "from_variant_sequence_and_reference_context", "(", "cls", ",", "variant_sequence", ",", "reference_context", ",", "min_transcript_prefix_length", ",", "max_transcript_mismatches", ",", "include_mismatches_after_variant", ",", "protein_sequence_length", "=", "None", ")", ...
Attempt to translate a single VariantSequence using the reading frame from a single ReferenceContext. Parameters ---------- variant_sequence : VariantSequence reference_context : ReferenceContext min_transcript_prefix_length : int Minimum number of nucleoti...
[ "Attempt", "to", "translate", "a", "single", "VariantSequence", "using", "the", "reading", "frame", "from", "a", "single", "ReferenceContext", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L161-L258
train
imlonghao/cachet.python
cachet.py
Cachet.postComponents
def postComponents(self, name, status, **kwargs): '''Create a new component. :param name: Name of the component :param status: Status of the component; 1-4 :param description: (optional) Description of the component :param link: (optional) A hyperlink to the component :p...
python
def postComponents(self, name, status, **kwargs): '''Create a new component. :param name: Name of the component :param status: Status of the component; 1-4 :param description: (optional) Description of the component :param link: (optional) A hyperlink to the component :p...
[ "def", "postComponents", "(", "self", ",", "name", ",", "status", ",", "**", "kwargs", ")", ":", "kwargs", "[", "'name'", "]", "=", "name", "kwargs", "[", "'status'", "]", "=", "status", "return", "self", ".", "__postRequest", "(", "'/components'", ",", ...
Create a new component. :param name: Name of the component :param status: Status of the component; 1-4 :param description: (optional) Description of the component :param link: (optional) A hyperlink to the component :param order: (optional) Order of the component :param ...
[ "Create", "a", "new", "component", "." ]
624b0d8e09b551a3be45dec207da6aa89f1e56e8
https://github.com/imlonghao/cachet.python/blob/624b0d8e09b551a3be45dec207da6aa89f1e56e8/cachet.py#L51-L67
train
imlonghao/cachet.python
cachet.py
Cachet.postIncidents
def postIncidents(self, name, message, status, visible, **kwargs): '''Create a new incident. :param name: Name of the incident :param message: A message (supporting Markdown) to explain more. :param status: Status of the incident. :param visible: Whether the incident is publicly...
python
def postIncidents(self, name, message, status, visible, **kwargs): '''Create a new incident. :param name: Name of the incident :param message: A message (supporting Markdown) to explain more. :param status: Status of the incident. :param visible: Whether the incident is publicly...
[ "def", "postIncidents", "(", "self", ",", "name", ",", "message", ",", "status", ",", "visible", ",", "**", "kwargs", ")", ":", "kwargs", "[", "'name'", "]", "=", "name", "kwargs", "[", "'message'", "]", "=", "message", "kwargs", "[", "'status'", "]", ...
Create a new incident. :param name: Name of the incident :param message: A message (supporting Markdown) to explain more. :param status: Status of the incident. :param visible: Whether the incident is publicly visible. :param component_id: (optional) Component to update. ...
[ "Create", "a", "new", "incident", "." ]
624b0d8e09b551a3be45dec207da6aa89f1e56e8
https://github.com/imlonghao/cachet.python/blob/624b0d8e09b551a3be45dec207da6aa89f1e56e8/cachet.py#L168-L186
train
imlonghao/cachet.python
cachet.py
Cachet.postMetrics
def postMetrics(self, name, suffix, description, default_value, **kwargs): '''Create a new metric. :param name: Name of metric :param suffix: Measurments in :param description: Description of what the metric is measuring :param default_value: The default value to use when a poin...
python
def postMetrics(self, name, suffix, description, default_value, **kwargs): '''Create a new metric. :param name: Name of metric :param suffix: Measurments in :param description: Description of what the metric is measuring :param default_value: The default value to use when a poin...
[ "def", "postMetrics", "(", "self", ",", "name", ",", "suffix", ",", "description", ",", "default_value", ",", "**", "kwargs", ")", ":", "kwargs", "[", "'name'", "]", "=", "name", "kwargs", "[", "'suffix'", "]", "=", "suffix", "kwargs", "[", "'description...
Create a new metric. :param name: Name of metric :param suffix: Measurments in :param description: Description of what the metric is measuring :param default_value: The default value to use when a point is added :param display_chart: (optional) Whether to display the chart on th...
[ "Create", "a", "new", "metric", "." ]
624b0d8e09b551a3be45dec207da6aa89f1e56e8
https://github.com/imlonghao/cachet.python/blob/624b0d8e09b551a3be45dec207da6aa89f1e56e8/cachet.py#L223-L239
train
imlonghao/cachet.python
cachet.py
Cachet.postMetricsPointsByID
def postMetricsPointsByID(self, id, value, **kwargs): '''Add a metric point to a given metric. :param id: Metric ID :param value: Value to plot on the metric graph :param timestamp: Unix timestamp of the point was measured :return: :class:`Response <Response>` object :rt...
python
def postMetricsPointsByID(self, id, value, **kwargs): '''Add a metric point to a given metric. :param id: Metric ID :param value: Value to plot on the metric graph :param timestamp: Unix timestamp of the point was measured :return: :class:`Response <Response>` object :rt...
[ "def", "postMetricsPointsByID", "(", "self", ",", "id", ",", "value", ",", "**", "kwargs", ")", ":", "kwargs", "[", "'value'", "]", "=", "value", "return", "self", ".", "__postRequest", "(", "'/metrics/%s/points'", "%", "id", ",", "kwargs", ")" ]
Add a metric point to a given metric. :param id: Metric ID :param value: Value to plot on the metric graph :param timestamp: Unix timestamp of the point was measured :return: :class:`Response <Response>` object :rtype: requests.Response
[ "Add", "a", "metric", "point", "to", "a", "given", "metric", "." ]
624b0d8e09b551a3be45dec207da6aa89f1e56e8
https://github.com/imlonghao/cachet.python/blob/624b0d8e09b551a3be45dec207da6aa89f1e56e8/cachet.py#L271-L282
train
bskinn/opan
opan/utils/inertia.py
ctr_mass
def ctr_mass(geom, masses): """Calculate the center of mass of the indicated geometry. Take a geometry and atom masses and compute the location of the center of mass. Parameters ---------- geom length-3N |npfloat_| -- Coordinates of the atoms masses length-N OR len...
python
def ctr_mass(geom, masses): """Calculate the center of mass of the indicated geometry. Take a geometry and atom masses and compute the location of the center of mass. Parameters ---------- geom length-3N |npfloat_| -- Coordinates of the atoms masses length-N OR len...
[ "def", "ctr_mass", "(", "geom", ",", "masses", ")", ":", "import", "numpy", "as", "np", "from", ".", "base", "import", "safe_cast", "as", "scast", "if", "len", "(", "geom", ".", "shape", ")", "!=", "1", ":", "raise", "ValueError", "(", "\"Geometry is n...
Calculate the center of mass of the indicated geometry. Take a geometry and atom masses and compute the location of the center of mass. Parameters ---------- geom length-3N |npfloat_| -- Coordinates of the atoms masses length-N OR length-3N |npfloat_| -- Atomic...
[ "Calculate", "the", "center", "of", "mass", "of", "the", "indicated", "geometry", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/inertia.py#L52-L113
train
bskinn/opan
opan/utils/inertia.py
ctr_geom
def ctr_geom(geom, masses): """ Returns geometry shifted to center of mass. Helper function to automate / encapsulate translation of a geometry to its center of mass. Parameters ---------- geom length-3N |npfloat_| -- Original coordinates of the atoms masses length...
python
def ctr_geom(geom, masses): """ Returns geometry shifted to center of mass. Helper function to automate / encapsulate translation of a geometry to its center of mass. Parameters ---------- geom length-3N |npfloat_| -- Original coordinates of the atoms masses length...
[ "def", "ctr_geom", "(", "geom", ",", "masses", ")", ":", "import", "numpy", "as", "np", "shift", "=", "np", ".", "tile", "(", "ctr_mass", "(", "geom", ",", "masses", ")", ",", "geom", ".", "shape", "[", "0", "]", "/", "3", ")", "ctr_geom", "=", ...
Returns geometry shifted to center of mass. Helper function to automate / encapsulate translation of a geometry to its center of mass. Parameters ---------- geom length-3N |npfloat_| -- Original coordinates of the atoms masses length-N OR length-3N |npfloat_| -- ...
[ "Returns", "geometry", "shifted", "to", "center", "of", "mass", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/inertia.py#L119-L158
train
bskinn/opan
opan/utils/inertia.py
inertia_tensor
def inertia_tensor(geom, masses): """Generate the 3x3 moment-of-inertia tensor. Compute the 3x3 moment-of-inertia tensor for the provided geometry and atomic masses. Always recenters the geometry to the center of mass as the first step. Reference for inertia tensor: [Kro92]_, Eq. (2.26) .. t...
python
def inertia_tensor(geom, masses): """Generate the 3x3 moment-of-inertia tensor. Compute the 3x3 moment-of-inertia tensor for the provided geometry and atomic masses. Always recenters the geometry to the center of mass as the first step. Reference for inertia tensor: [Kro92]_, Eq. (2.26) .. t...
[ "def", "inertia_tensor", "(", "geom", ",", "masses", ")", ":", "import", "numpy", "as", "np", "geom", "=", "ctr_geom", "(", "geom", ",", "masses", ")", "if", "geom", ".", "shape", "[", "0", "]", "==", "3", "*", "masses", ".", "shape", "[", "0", "...
Generate the 3x3 moment-of-inertia tensor. Compute the 3x3 moment-of-inertia tensor for the provided geometry and atomic masses. Always recenters the geometry to the center of mass as the first step. Reference for inertia tensor: [Kro92]_, Eq. (2.26) .. todo:: Replace cite eventually with link t...
[ "Generate", "the", "3x3", "moment", "-", "of", "-", "inertia", "tensor", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/inertia.py#L164-L242
train
bskinn/opan
opan/utils/inertia.py
rot_consts
def rot_consts(geom, masses, units=_EURC.INV_INERTIA, on_tol=_DEF.ORTHONORM_TOL): """Rotational constants for a given molecular system. Calculates the rotational constants for the provided system with numerical value given in the units provided in `units`. The orthnormality tolerance `on_tol` is requi...
python
def rot_consts(geom, masses, units=_EURC.INV_INERTIA, on_tol=_DEF.ORTHONORM_TOL): """Rotational constants for a given molecular system. Calculates the rotational constants for the provided system with numerical value given in the units provided in `units`. The orthnormality tolerance `on_tol` is requi...
[ "def", "rot_consts", "(", "geom", ",", "masses", ",", "units", "=", "_EURC", ".", "INV_INERTIA", ",", "on_tol", "=", "_DEF", ".", "ORTHONORM_TOL", ")", ":", "import", "numpy", "as", "np", "from", ".", ".", "const", "import", "EnumTopType", "as", "ETT", ...
Rotational constants for a given molecular system. Calculates the rotational constants for the provided system with numerical value given in the units provided in `units`. The orthnormality tolerance `on_tol` is required in order to be passed through to the :func:`principals` function. If the sys...
[ "Rotational", "constants", "for", "a", "given", "molecular", "system", "." ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/inertia.py#L499-L598
train
bskinn/opan
opan/utils/inertia.py
_fadn_orth
def _fadn_orth(vec, geom): """First non-zero Atomic Displacement Non-Orthogonal to Vec Utility function to identify the first atomic displacement in a geometry that is (a) not the zero vector; and (b) not normal to the reference vector. Parameters ---------- vec length-3 |npfloat_| -- ...
python
def _fadn_orth(vec, geom): """First non-zero Atomic Displacement Non-Orthogonal to Vec Utility function to identify the first atomic displacement in a geometry that is (a) not the zero vector; and (b) not normal to the reference vector. Parameters ---------- vec length-3 |npfloat_| -- ...
[ "def", "_fadn_orth", "(", "vec", ",", "geom", ")", ":", "import", "numpy", "as", "np", "from", "scipy", "import", "linalg", "as", "spla", "from", ".", ".", "const", "import", "PRM", "from", ".", ".", "error", "import", "InertiaError", "from", ".", "vec...
First non-zero Atomic Displacement Non-Orthogonal to Vec Utility function to identify the first atomic displacement in a geometry that is (a) not the zero vector; and (b) not normal to the reference vector. Parameters ---------- vec length-3 |npfloat_| -- Reference vector. Does not...
[ "First", "non", "-", "zero", "Atomic", "Displacement", "Non", "-", "Orthogonal", "to", "Vec" ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/inertia.py#L604-L667
train
bskinn/opan
opan/utils/inertia.py
_fadn_par
def _fadn_par(vec, geom): """First non-zero Atomic Displacement that is Non-Parallel with Vec Utility function to identify the first atomic displacement in a geometry that is both (a) not the zero vector and (b) non-(anti-)parallel with a reference vector. Parameters ---------- vec ...
python
def _fadn_par(vec, geom): """First non-zero Atomic Displacement that is Non-Parallel with Vec Utility function to identify the first atomic displacement in a geometry that is both (a) not the zero vector and (b) non-(anti-)parallel with a reference vector. Parameters ---------- vec ...
[ "def", "_fadn_par", "(", "vec", ",", "geom", ")", ":", "import", "numpy", "as", "np", "from", "scipy", "import", "linalg", "as", "spla", "from", ".", ".", "const", "import", "PRM", "from", ".", ".", "error", "import", "InertiaError", "from", ".", "vect...
First non-zero Atomic Displacement that is Non-Parallel with Vec Utility function to identify the first atomic displacement in a geometry that is both (a) not the zero vector and (b) non-(anti-)parallel with a reference vector. Parameters ---------- vec length-3 |npfloat_| -- R...
[ "First", "non", "-", "zero", "Atomic", "Displacement", "that", "is", "Non", "-", "Parallel", "with", "Vec" ]
0b1b21662df6abc971407a9386db21a8796fbfe5
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/inertia.py#L674-L740
train
openvax/isovar
isovar/reference_context.py
reference_contexts_for_variants
def reference_contexts_for_variants( variants, context_size, transcript_id_whitelist=None): """ Extract a set of reference contexts for each variant in the collection. Parameters ---------- variants : varcode.VariantCollection context_size : int Max of nucleotid...
python
def reference_contexts_for_variants( variants, context_size, transcript_id_whitelist=None): """ Extract a set of reference contexts for each variant in the collection. Parameters ---------- variants : varcode.VariantCollection context_size : int Max of nucleotid...
[ "def", "reference_contexts_for_variants", "(", "variants", ",", "context_size", ",", "transcript_id_whitelist", "=", "None", ")", ":", "result", "=", "OrderedDict", "(", ")", "for", "variant", "in", "variants", ":", "result", "[", "variant", "]", "=", "reference...
Extract a set of reference contexts for each variant in the collection. Parameters ---------- variants : varcode.VariantCollection context_size : int Max of nucleotides to include to the left and right of the variant in the context sequence. transcript_id_whitelist : set, optional...
[ "Extract", "a", "set", "of", "reference", "contexts", "for", "each", "variant", "in", "the", "collection", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/reference_context.py#L141-L168
train
openvax/isovar
isovar/reference_context.py
variants_to_reference_contexts_dataframe
def variants_to_reference_contexts_dataframe( variants, context_size, transcript_id_whitelist=None): """ Given a collection of variants, find all reference sequence contexts around each variant. Parameters ---------- variants : varcode.VariantCollection context_size...
python
def variants_to_reference_contexts_dataframe( variants, context_size, transcript_id_whitelist=None): """ Given a collection of variants, find all reference sequence contexts around each variant. Parameters ---------- variants : varcode.VariantCollection context_size...
[ "def", "variants_to_reference_contexts_dataframe", "(", "variants", ",", "context_size", ",", "transcript_id_whitelist", "=", "None", ")", ":", "df_builder", "=", "DataFrameBuilder", "(", "ReferenceContext", ",", "exclude", "=", "[", "\"variant\"", "]", ",", "converte...
Given a collection of variants, find all reference sequence contexts around each variant. Parameters ---------- variants : varcode.VariantCollection context_size : int Max of nucleotides to include to the left and right of the variant in the context sequence. transcript_id_whi...
[ "Given", "a", "collection", "of", "variants", "find", "all", "reference", "sequence", "contexts", "around", "each", "variant", "." ]
b39b684920e3f6b344851d6598a1a1c67bce913b
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/reference_context.py#L170-L205
train
pyviz/imagen
imagen/patternfn.py
exponential
def exponential(x, y, xscale, yscale): """ Two-dimensional oriented exponential decay pattern. """ if xscale==0.0 or yscale==0.0: return x*0.0 with float_error_ignore(): x_w = np.divide(x,xscale) y_h = np.divide(y,yscale) return np.exp(-np.sqrt(x_w*x_w+y_h*y_h))
python
def exponential(x, y, xscale, yscale): """ Two-dimensional oriented exponential decay pattern. """ if xscale==0.0 or yscale==0.0: return x*0.0 with float_error_ignore(): x_w = np.divide(x,xscale) y_h = np.divide(y,yscale) return np.exp(-np.sqrt(x_w*x_w+y_h*y_h))
[ "def", "exponential", "(", "x", ",", "y", ",", "xscale", ",", "yscale", ")", ":", "if", "xscale", "==", "0.0", "or", "yscale", "==", "0.0", ":", "return", "x", "*", "0.0", "with", "float_error_ignore", "(", ")", ":", "x_w", "=", "np", ".", "divide"...
Two-dimensional oriented exponential decay pattern.
[ "Two", "-", "dimensional", "oriented", "exponential", "decay", "pattern", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patternfn.py#L82-L92
train
pyviz/imagen
imagen/patternfn.py
line
def line(y, thickness, gaussian_width): """ Infinite-length line with a solid central region, then Gaussian fall-off at the edges. """ distance_from_line = abs(y) gaussian_y_coord = distance_from_line - thickness/2.0 sigmasq = gaussian_width*gaussian_width if sigmasq==0.0: falloff =...
python
def line(y, thickness, gaussian_width): """ Infinite-length line with a solid central region, then Gaussian fall-off at the edges. """ distance_from_line = abs(y) gaussian_y_coord = distance_from_line - thickness/2.0 sigmasq = gaussian_width*gaussian_width if sigmasq==0.0: falloff =...
[ "def", "line", "(", "y", ",", "thickness", ",", "gaussian_width", ")", ":", "distance_from_line", "=", "abs", "(", "y", ")", "gaussian_y_coord", "=", "distance_from_line", "-", "thickness", "/", "2.0", "sigmasq", "=", "gaussian_width", "*", "gaussian_width", "...
Infinite-length line with a solid central region, then Gaussian fall-off at the edges.
[ "Infinite", "-", "length", "line", "with", "a", "solid", "central", "region", "then", "Gaussian", "fall", "-", "off", "at", "the", "edges", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patternfn.py#L114-L128
train
pyviz/imagen
imagen/patternfn.py
disk
def disk(x, y, height, gaussian_width): """ Circular disk with Gaussian fall-off after the solid central region. """ disk_radius = height/2.0 distance_from_origin = np.sqrt(x**2+y**2) distance_outside_disk = distance_from_origin - disk_radius sigmasq = gaussian_width*gaussian_width if ...
python
def disk(x, y, height, gaussian_width): """ Circular disk with Gaussian fall-off after the solid central region. """ disk_radius = height/2.0 distance_from_origin = np.sqrt(x**2+y**2) distance_outside_disk = distance_from_origin - disk_radius sigmasq = gaussian_width*gaussian_width if ...
[ "def", "disk", "(", "x", ",", "y", ",", "height", ",", "gaussian_width", ")", ":", "disk_radius", "=", "height", "/", "2.0", "distance_from_origin", "=", "np", ".", "sqrt", "(", "x", "**", "2", "+", "y", "**", "2", ")", "distance_outside_disk", "=", ...
Circular disk with Gaussian fall-off after the solid central region.
[ "Circular", "disk", "with", "Gaussian", "fall", "-", "off", "after", "the", "solid", "central", "region", "." ]
53c5685c880f54b42795964d8db50b02e8590e88
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patternfn.py#L131-L148
train