partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
greedy_merge
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.
isovar/assembly.py
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): """ Greedily merge overlapping sequences into longer sequences. Accepts a collection of VariantSequence objects and returns another collection of elongated variant sequences. The reads fie...
[ "Greedily", "merge", "overlapping", "sequences", "into", "longer", "sequences", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/assembly.py#L60-L76
[ "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_...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
collapse_substrings
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.
isovar/assembly.py
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): """ 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...
[ "Combine", "shorter", "sequences", "which", "are", "fully", "contained", "in", "longer", "sequences", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/assembly.py#L78-L116
[ "def", "collapse_substrings", "(", "variant_sequences", ")", ":", "if", "len", "(", "variant_sequences", ")", "<=", "1", ":", "# if we don't have at least two VariantSequences then just", "# return your input", "return", "variant_sequences", "# dictionary mapping VariantSequence ...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
iterative_overlap_assembly
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.
isovar/assembly.py
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): """ 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...
[ "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...
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/assembly.py#L118-L146
[ "def", "iterative_overlap_assembly", "(", "variant_sequences", ",", "min_overlap_size", "=", "MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE", ")", ":", "if", "len", "(", "variant_sequences", ")", "<=", "1", ":", "# if we don't have at least two sequences to start with then", "# sk...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
groupby
Group elements of the list `xs` by keys generated from calling `key_fn`. Returns a dictionary which maps keys to sub-lists of `xs`.
isovar/common.py
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): """ 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
[ "Group", "elements", "of", "the", "list", "xs", "by", "keys", "generated", "from", "calling", "key_fn", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/common.py#L27-L37
[ "def", "groupby", "(", "xs", ",", "key_fn", ")", ":", "result", "=", "defaultdict", "(", "list", ")", "for", "x", "in", "xs", ":", "key", "=", "key_fn", "(", "x", ")", "result", "[", "key", "]", ".", "append", "(", "x", ")", "return", "result" ]
b39b684920e3f6b344851d6598a1a1c67bce913b
train
ortho_basis
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} = ...
opan/utils/vector.py
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): """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:: ...
[ "Generates", "an", "orthonormal", "basis", "in", "the", "plane", "perpendicular", "to", "normal" ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L50-L174
[ "def", "ortho_basis", "(", "normal", ",", "ref_vec", "=", "None", ")", ":", "# Imports for library functions", "import", "numpy", "as", "np", "from", "scipy", "import", "linalg", "as", "spla", "from", "scipy", "import", "random", "as", "sprnd", "from", ".", ...
0b1b21662df6abc971407a9386db21a8796fbfe5
train
orthonorm_check
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...
opan/utils/vector.py
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): """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 ...
[ "Checks", "orthonormality", "of", "the", "column", "vectors", "of", "a", "matrix", "." ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L179-L282
[ "def", "orthonorm_check", "(", "a", ",", "tol", "=", "_DEF", ".", "ORTHONORM_TOL", ",", "report", "=", "False", ")", ":", "# Imports", "import", "numpy", "as", "np", "from", ".", "base", "import", "delta_fxn", "#!TODO? orthonorm_check Must add traps to ensure a is...
0b1b21662df6abc971407a9386db21a8796fbfe5
train
parallel_check
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 ...
opan/utils/vector.py
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): """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 ...
[ "Checks", "whether", "two", "vectors", "are", "parallel", "OR", "anti", "-", "parallel", "." ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L288-L335
[ "def", "parallel_check", "(", "vec1", ",", "vec2", ")", ":", "# Imports", "from", ".", ".", "const", "import", "PRM", "import", "numpy", "as", "np", "# Initialize False", "par", "=", "False", "# Shape check", "for", "n", ",", "v", "in", "enumerate", "(", ...
0b1b21662df6abc971407a9386db21a8796fbfe5
train
proj
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 ...
opan/utils/vector.py
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): """ 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...
[ "Vector", "projection", "." ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L341-L386
[ "def", "proj", "(", "vec", ",", "vec_onto", ")", ":", "# Imports", "import", "numpy", "as", "np", "# Ensure vectors", "if", "not", "len", "(", "vec", ".", "shape", ")", "==", "1", ":", "raise", "ValueError", "(", "\"'vec' is not a vector\"", ")", "## end i...
0b1b21662df6abc971407a9386db21a8796fbfe5
train
rej
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 ...
opan/utils/vector.py
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): """ 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", "rejection", "." ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L392-L426
[ "def", "rej", "(", "vec", ",", "vec_onto", ")", ":", "# Imports", "import", "numpy", "as", "np", "# Calculate and return.", "rej_vec", "=", "vec", "-", "proj", "(", "vec", ",", "vec_onto", ")", "return", "rej_vec" ]
0b1b21662df6abc971407a9386db21a8796fbfe5
train
vec_angle
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...
opan/utils/vector.py
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): """ 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 -...
[ "Angle", "between", "two", "R", "-", "dimensional", "vectors", "." ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/vector.py#L432-L499
[ "def", "vec_angle", "(", "vec1", ",", "vec2", ")", ":", "# Imports", "import", "numpy", "as", "np", "from", "scipy", "import", "linalg", "as", "spla", "from", ".", ".", "const", "import", "PRM", "# Check shape and equal length", "if", "len", "(", "vec1", "...
0b1b21662df6abc971407a9386db21a8796fbfe5
train
new_module
Do all of the gruntwork associated with creating a new module.
cbsettings/importers.py
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): """ 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...
[ "Do", "all", "of", "the", "gruntwork", "associated", "with", "creating", "a", "new", "module", "." ]
matthewwithanm/django-classbasedsettings
python
https://github.com/matthewwithanm/django-classbasedsettings/blob/ac9e4362bd1f4954f3e4679b97726cab2b22aea9/cbsettings/importers.py#L5-L19
[ "def", "new_module", "(", "name", ")", ":", "parent", "=", "None", "if", "'.'", "in", "name", ":", "parent_name", "=", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "[", "0", "]", "parent", "=", "__import__", "(", "parent_name", ",", "fromlist", ...
ac9e4362bd1f4954f3e4679b97726cab2b22aea9
train
allele_counts_dataframe
Creates a DataFrame containing number of reads supporting the ref vs. alt alleles for each variant.
isovar/allele_counts.py
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): """ 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(...
[ "Creates", "a", "DataFrame", "containing", "number", "of", "reads", "supporting", "the", "ref", "vs", ".", "alt", "alleles", "for", "each", "variant", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/allele_counts.py#L46-L59
[ "def", "allele_counts_dataframe", "(", "variant_and_allele_reads_generator", ")", ":", "df_builder", "=", "DataFrameBuilder", "(", "AlleleCount", ",", "extra_column_fns", "=", "{", "\"gene\"", ":", "lambda", "variant", ",", "_", ":", "\";\"", ".", "join", "(", "va...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
install_extension
Install Postgres extension.
postpy/extensions.py
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): """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...
[ "Install", "Postgres", "extension", "." ]
portfoliome/postpy
python
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/extensions.py#L5-L18
[ "def", "install_extension", "(", "conn", ",", "extension", ":", "str", ")", ":", "query", "=", "'CREATE EXTENSION IF NOT EXISTS \"%s\";'", "with", "conn", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "query", ",", "(", "AsIs",...
fe26199131b15295fc5f669a0ad2a7f47bf490ee
train
check_extension
Check to see if an extension is installed.
postpy/extensions.py
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: """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 ...
[ "Check", "to", "see", "if", "an", "extension", "is", "installed", "." ]
portfoliome/postpy
python
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/extensions.py#L21-L37
[ "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...
fe26199131b15295fc5f669a0ad2a7f47bf490ee
train
xrange.count
rangeobject.count(value) -> integer -- return number of occurrences of value
picklable_itertools/range.py
def count(self, i): """rangeobject.count(value) -> integer -- return number of occurrences of value """ if self._stop > self._start and self._step > 0: return int(self._start <= i < self._stop and (i - self._start) % self._step == 0) elif self._...
def count(self, i): """rangeobject.count(value) -> integer -- return number of occurrences of value """ if self._stop > self._start and self._step > 0: return int(self._start <= i < self._stop and (i - self._start) % self._step == 0) elif self._...
[ "rangeobject", ".", "count", "(", "value", ")", "-", ">", "integer", "--", "return", "number", "of", "occurrences", "of", "value" ]
mila-iqia/picklable-itertools
python
https://github.com/mila-iqia/picklable-itertools/blob/e00238867875df0258cf4f83f528d846e7c1afc4/picklable_itertools/range.py#L53-L64
[ "def", "count", "(", "self", ",", "i", ")", ":", "if", "self", ".", "_stop", ">", "self", ".", "_start", "and", "self", ".", "_step", ">", "0", ":", "return", "int", "(", "self", ".", "_start", "<=", "i", "<", "self", ".", "_stop", "and", "(", ...
e00238867875df0258cf4f83f528d846e7c1afc4
train
xrange.index
xrangeobject.index(value, [start, [stop]]) -> integer -- return index of value. Raise ValueError if the value is not present.
picklable_itertools/range.py
def index(self, i): """xrangeobject.index(value, [start, [stop]]) -> integer -- return index of value. Raise ValueError if the value is not present. """ if self.count(i) == 0: raise ValueError("{} is not in range".format(i)) return (i - self._start) // self._s...
def index(self, i): """xrangeobject.index(value, [start, [stop]]) -> integer -- return index of value. Raise ValueError if the value is not present. """ if self.count(i) == 0: raise ValueError("{} is not in range".format(i)) return (i - self._start) // self._s...
[ "xrangeobject", ".", "index", "(", "value", "[", "start", "[", "stop", "]]", ")", "-", ">", "integer", "--", "return", "index", "of", "value", ".", "Raise", "ValueError", "if", "the", "value", "is", "not", "present", "." ]
mila-iqia/picklable-itertools
python
https://github.com/mila-iqia/picklable-itertools/blob/e00238867875df0258cf4f83f528d846e7c1afc4/picklable_itertools/range.py#L66-L73
[ "def", "index", "(", "self", ",", "i", ")", ":", "if", "self", ".", "count", "(", "i", ")", "==", "0", ":", "raise", "ValueError", "(", "\"{} is not in range\"", ".", "format", "(", "i", ")", ")", "return", "(", "i", "-", "self", ".", "_start", "...
e00238867875df0258cf4f83f528d846e7c1afc4
train
make_iterable
Ensure obj is iterable.
opencorpora/reader.py
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): """ Ensure obj is iterable. """ if obj is None: return default or [] if isinstance(obj, (compat.string_types, compat.integer_types)): return [obj] return obj
[ "Ensure", "obj", "is", "iterable", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L12-L18
[ "def", "make_iterable", "(", "obj", ",", "default", "=", "None", ")", ":", "if", "obj", "is", "None", ":", "return", "default", "or", "[", "]", "if", "isinstance", "(", "obj", ",", "(", "compat", ".", "string_types", ",", "compat", ".", "integer_types"...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
CorpusReader.iter_documents
Return an iterator over corpus documents.
opencorpora/reader.py
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): """ 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()
[ "Return", "an", "iterator", "over", "corpus", "documents", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L176-L182
[ "def", "iter_documents", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ",", "_destroy", "=", "False", ")", ":", "doc_ids", "=", "self", ".", "_filter_ids", "(", "fileids", ",", "categories", ")", "for", "doc", "in", "imap", ...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
CorpusReader.catalog
Return information about documents in corpora: a list of tuples (doc_id, doc_title).
opencorpora/reader.py
def catalog(self, categories=None): """ Return information about documents in corpora: a list of tuples (doc_id, doc_title). """ ids = self._filter_ids(None, categories) doc_meta = self._get_meta() return [(doc_id, doc_meta[doc_id].title) for doc_id in ids]
def catalog(self, categories=None): """ Return information about documents in corpora: a list of tuples (doc_id, doc_title). """ ids = self._filter_ids(None, categories) doc_meta = self._get_meta() return [(doc_id, doc_meta[doc_id].title) for doc_id in ids]
[ "Return", "information", "about", "documents", "in", "corpora", ":", "a", "list", "of", "tuples", "(", "doc_id", "doc_title", ")", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L244-L251
[ "def", "catalog", "(", "self", ",", "categories", "=", "None", ")", ":", "ids", "=", "self", ".", "_filter_ids", "(", "None", ",", "categories", ")", "doc_meta", "=", "self", ".", "_get_meta", "(", ")", "return", "[", "(", "doc_id", ",", "doc_meta", ...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
CorpusReader._create_meta_cache
Try to dump metadata to a file.
opencorpora/reader.py
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 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
[ "Try", "to", "dump", "metadata", "to", "a", "file", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L295-L301
[ "def", "_create_meta_cache", "(", "self", ")", ":", "try", ":", "with", "open", "(", "self", ".", "_cache_filename", ",", "'wb'", ")", "as", "f", ":", "compat", ".", "pickle", ".", "dump", "(", "self", ".", "_document_meta", ",", "f", ",", "1", ")", ...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
CorpusReader._load_meta_cache
Try to load metadata from file.
opencorpora/reader.py
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 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...
[ "Try", "to", "load", "metadata", "from", "file", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L303-L313
[ "def", "_load_meta_cache", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_should_invalidate_cache", "(", ")", ":", "os", ".", "remove", "(", "self", ".", "_cache_filename", ")", "else", ":", "with", "open", "(", "self", ".", "_cache_filename", "...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
CorpusReader._compute_document_meta
Return documents meta information that can be used for fast document lookups. Meta information consists of documents titles, categories and positions in file.
opencorpora/reader.py
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): """ 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...
[ "Return", "documents", "meta", "information", "that", "can", "be", "used", "for", "fast", "document", "lookups", ".", "Meta", "information", "consists", "of", "documents", "titles", "categories", "and", "positions", "in", "file", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L320-L342
[ "def", "_compute_document_meta", "(", "self", ")", ":", "meta", "=", "OrderedDict", "(", ")", "bounds_iter", "=", "xml_utils", ".", "bounds", "(", "self", ".", "filename", ",", "start_re", "=", "r'<text id=\"(\\d+)\"[^>]*name=\"([^\"]*)\"'", ",", "end_re", "=", ...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
CorpusReader._document_xml
Return xml Element for the document document_id.
opencorpora/reader.py
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): """ 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'))
[ "Return", "xml", "Element", "for", "the", "document", "document_id", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L344-L347
[ "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'", ")...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
CorpusReader._get_doc_by_raw_offset
Load document from xml using bytes offset information. XXX: this is not tested under Windows.
opencorpora/reader.py
def _get_doc_by_raw_offset(self, doc_id): """ Load document from xml using bytes offset information. XXX: this is not tested under Windows. """ bounds = self._get_meta()[str(doc_id)].bounds return xml_utils.load_chunk(self.filename, bounds)
def _get_doc_by_raw_offset(self, doc_id): """ Load document from xml using bytes offset information. XXX: this is not tested under Windows. """ bounds = self._get_meta()[str(doc_id)].bounds return xml_utils.load_chunk(self.filename, bounds)
[ "Load", "document", "from", "xml", "using", "bytes", "offset", "information", ".", "XXX", ":", "this", "is", "not", "tested", "under", "Windows", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L349-L355
[ "def", "_get_doc_by_raw_offset", "(", "self", ",", "doc_id", ")", ":", "bounds", "=", "self", ".", "_get_meta", "(", ")", "[", "str", "(", "doc_id", ")", "]", ".", "bounds", "return", "xml_utils", ".", "load_chunk", "(", "self", ".", "filename", ",", "...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
CorpusReader._get_doc_by_line_offset
Load document from xml using line offset information. This is much slower than _get_doc_by_raw_offset but should work everywhere.
opencorpora/reader.py
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): """ 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...
[ "Load", "document", "from", "xml", "using", "line", "offset", "information", ".", "This", "is", "much", "slower", "than", "_get_doc_by_raw_offset", "but", "should", "work", "everywhere", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader.py#L357-L364
[ "def", "_get_doc_by_line_offset", "(", "self", ",", "doc_id", ")", ":", "bounds", "=", "self", ".", "_get_meta", "(", ")", "[", "str", "(", "doc_id", ")", "]", ".", "bounds", "return", "xml_utils", ".", "load_chunk", "(", "self", ".", "filename", ",", ...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
_threeDdot_simple
Return Ma, where M is a 3x3 transformation matrix, for each pixel
imagen/colorspaces.py
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(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) ...
[ "Return", "Ma", "where", "M", "is", "a", "3x3", "transformation", "matrix", "for", "each", "pixel" ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L49-L62
[ "def", "_threeDdot_simple", "(", "M", ",", "a", ")", ":", "result", "=", "np", ".", "empty", "(", "a", ".", "shape", ",", "dtype", "=", "a", ".", "dtype", ")", "for", "i", "in", "range", "(", "a", ".", "shape", "[", "0", "]", ")", ":", "for",...
53c5685c880f54b42795964d8db50b02e8590e88
train
_swaplch
Reverse the order of an LCH numpy dstack or tuple for analysis.
imagen/colorspaces.py
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: # 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
[ "Reverse", "the", "order", "of", "an", "LCH", "numpy", "dstack", "or", "tuple", "for", "analysis", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L435-L442
[ "def", "_swaplch", "(", "LCH", ")", ":", "try", ":", "# Numpy array", "L", ",", "C", ",", "H", "=", "np", ".", "dsplit", "(", "LCH", ",", "3", ")", "return", "np", ".", "dstack", "(", "(", "H", ",", "C", ",", "L", ")", ")", "except", ":", "...
53c5685c880f54b42795964d8db50b02e8590e88
train
ColorSpace.convert
Convert image or color "what" from "from_" colorpace to "to" colorspace. E.g.: ``convert("rgb", "hsv", X)``, where X is a numpy dstack or a color tuple.
imagen/colorspaces.py
def convert(self, from_, to, what): """ Convert image or color "what" from "from_" colorpace to "to" colorspace. E.g.: ``convert("rgb", "hsv", X)``, where X is a numpy dstack or a color tuple. """ if(from_.lower()==to.lower()): return what # Check i...
def convert(self, from_, to, what): """ Convert image or color "what" from "from_" colorpace to "to" colorspace. E.g.: ``convert("rgb", "hsv", X)``, where X is a numpy dstack or a color tuple. """ if(from_.lower()==to.lower()): return what # Check i...
[ "Convert", "image", "or", "color", "what", "from", "from_", "colorpace", "to", "to", "colorspace", ".", "E", ".", "g", ".", ":", "convert", "(", "rgb", "hsv", "X", ")", "where", "X", "is", "a", "numpy", "dstack", "or", "a", "color", "tuple", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L283-L303
[ "def", "convert", "(", "self", ",", "from_", ",", "to", ",", "what", ")", ":", "if", "(", "from_", ".", "lower", "(", ")", "==", "to", ".", "lower", "(", ")", ")", ":", "return", "what", "# Check if there exist an optimized function that performs", "# from...
53c5685c880f54b42795964d8db50b02e8590e88
train
ColorSpace.rgb_to_hsv
linear rgb to hsv
imagen/colorspaces.py
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" ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L413-L416
[ "def", "rgb_to_hsv", "(", "self", ",", "RGB", ")", ":", "gammaRGB", "=", "self", ".", "_gamma_rgb", "(", "RGB", ")", "return", "self", ".", "_ABC_to_DEF_by_fn", "(", "gammaRGB", ",", "rgb_to_hsv", ")" ]
53c5685c880f54b42795964d8db50b02e8590e88
train
ColorSpace.hsv_to_rgb
hsv to linear rgb
imagen/colorspaces.py
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" ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L418-L421
[ "def", "hsv_to_rgb", "(", "self", ",", "HSV", ")", ":", "gammaRGB", "=", "self", ".", "_ABC_to_DEF_by_fn", "(", "HSV", ",", "hsv_to_rgb", ")", "return", "self", ".", "_ungamma_rgb", "(", "gammaRGB", ")" ]
53c5685c880f54b42795964d8db50b02e8590e88
train
ColorConverter.image2working
Transform images i provided into the specified working color space.
imagen/colorspaces.py
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): """Transform images i provided into the specified working color space.""" return self.colorspace.convert(self.image_space, self.working_space, i)
[ "Transform", "images", "i", "provided", "into", "the", "specified", "working", "color", "space", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L477-L481
[ "def", "image2working", "(", "self", ",", "i", ")", ":", "return", "self", ".", "colorspace", ".", "convert", "(", "self", ".", "image_space", ",", "self", ".", "working_space", ",", "i", ")" ]
53c5685c880f54b42795964d8db50b02e8590e88
train
ColorConverter.working2analysis
Transform working space inputs to the analysis color space.
imagen/colorspaces.py
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) return self.swap_polar_HSVorder[self.analysis_space](a)
[ "Transform", "working", "space", "inputs", "to", "the", "analysis", "color", "space", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L483-L486
[ "def", "working2analysis", "(", "self", ",", "r", ")", ":", "a", "=", "self", ".", "colorspace", ".", "convert", "(", "self", ".", "working_space", ",", "self", ".", "analysis_space", ",", "r", ")", "return", "self", ".", "swap_polar_HSVorder", "[", "sel...
53c5685c880f54b42795964d8db50b02e8590e88
train
ColorConverter.analysis2working
Convert back from the analysis color space to the working space.
imagen/colorspaces.py
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.colorspace.convert(self.analysis_space, self.working_space, a)
[ "Convert", "back", "from", "the", "analysis", "color", "space", "to", "the", "working", "space", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L488-L491
[ "def", "analysis2working", "(", "self", ",", "a", ")", ":", "a", "=", "self", ".", "swap_polar_HSVorder", "[", "self", ".", "analysis_space", "]", "(", "a", ")", "return", "self", ".", "colorspace", ".", "convert", "(", "self", ".", "analysis_space", ","...
53c5685c880f54b42795964d8db50b02e8590e88
train
ColorConverter.analysis2display
Utility conversion function that transforms data from the analysis color space to the display space (currently hard-set to RGB) for visualization.
imagen/colorspaces.py
def analysis2display(self,a): """ Utility conversion function that transforms data from the analysis color space to the display space (currently hard-set to RGB) for visualization. """ a = self.swap_polar_HSVorder[self.analysis_space](a) return self.colorspace.con...
def analysis2display(self,a): """ Utility conversion function that transforms data from the analysis color space to the display space (currently hard-set to RGB) for visualization. """ a = self.swap_polar_HSVorder[self.analysis_space](a) return self.colorspace.con...
[ "Utility", "conversion", "function", "that", "transforms", "data", "from", "the", "analysis", "color", "space", "to", "the", "display", "space", "(", "currently", "hard", "-", "set", "to", "RGB", ")", "for", "visualization", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L493-L500
[ "def", "analysis2display", "(", "self", ",", "a", ")", ":", "a", "=", "self", ".", "swap_polar_HSVorder", "[", "self", ".", "analysis_space", "]", "(", "a", ")", "return", "self", ".", "colorspace", ".", "convert", "(", "self", ".", "analysis_space", "."...
53c5685c880f54b42795964d8db50b02e8590e88
train
iterparse
iterparse variant that supports 'tag' parameter (like lxml), yields elements and clears nodes after parsing.
opencorpora/xml_utils.py
def iterparse(source, tag, clear=False, events=None): """ iterparse variant that supports 'tag' parameter (like lxml), yields elements and clears nodes after parsing. """ for event, elem in ElementTree.iterparse(source, events=events): if elem.tag == tag: yield elem if cl...
def iterparse(source, tag, clear=False, events=None): """ iterparse variant that supports 'tag' parameter (like lxml), yields elements and clears nodes after parsing. """ for event, elem in ElementTree.iterparse(source, events=events): if elem.tag == tag: yield elem if cl...
[ "iterparse", "variant", "that", "supports", "tag", "parameter", "(", "like", "lxml", ")", "yields", "elements", "and", "clears", "nodes", "after", "parsing", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/xml_utils.py#L12-L21
[ "def", "iterparse", "(", "source", ",", "tag", ",", "clear", "=", "False", ",", "events", "=", "None", ")", ":", "for", "event", ",", "elem", "in", "ElementTree", ".", "iterparse", "(", "source", ",", "events", "=", "events", ")", ":", "if", "elem", ...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
bounds
Compute chunk bounds from text file according to start_re and end_re: yields (start_match, Bounds) tuples.
opencorpora/xml_utils.py
def bounds(filename, start_re, end_re, encoding='utf8'): """ Compute chunk bounds from text file according to start_re and end_re: yields (start_match, Bounds) tuples. """ start_re, end_re = re.compile(start_re), re.compile(end_re) mo, line_start, line_end, byte_start, byte_end = [None]*5 of...
def bounds(filename, start_re, end_re, encoding='utf8'): """ Compute chunk bounds from text file according to start_re and end_re: yields (start_match, Bounds) tuples. """ start_re, end_re = re.compile(start_re), re.compile(end_re) mo, line_start, line_end, byte_start, byte_end = [None]*5 of...
[ "Compute", "chunk", "bounds", "from", "text", "file", "according", "to", "start_re", "and", "end_re", ":", "yields", "(", "start_match", "Bounds", ")", "tuples", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/xml_utils.py#L28-L49
[ "def", "bounds", "(", "filename", ",", "start_re", ",", "end_re", ",", "encoding", "=", "'utf8'", ")", ":", "start_re", ",", "end_re", "=", "re", ".", "compile", "(", "start_re", ")", ",", "re", ".", "compile", "(", "end_re", ")", "mo", ",", "line_st...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
load_chunk
Load a chunk from file using Bounds info. Pass 'slow=True' for an alternative loading method based on line numbers.
opencorpora/xml_utils.py
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): """ 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: ...
[ "Load", "a", "chunk", "from", "file", "using", "Bounds", "info", ".", "Pass", "slow", "=", "True", "for", "an", "alternative", "loading", "method", "based", "on", "line", "numbers", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/xml_utils.py#L52-L63
[ "def", "load_chunk", "(", "filename", ",", "bounds", ",", "encoding", "=", "'utf8'", ",", "slow", "=", "False", ")", ":", "if", "slow", ":", "return", "_load_chunk_slow", "(", "filename", ",", "bounds", ",", "encoding", ")", "with", "open", "(", "filenam...
26fee106aea1180d2975b3825dcf9b3875e80db1
train
add_reference_context_args
Extends an ArgumentParser instance with the following commandline arguments: --context-size
isovar/cli/reference_context_args.py
def add_reference_context_args(parser): """ Extends an ArgumentParser instance with the following commandline arguments: --context-size """ reference_context_group = parser.add_argument_group("Reference Transcripts") parser.add_argument( "--context-size", default=CDNA_CONTEXT...
def add_reference_context_args(parser): """ Extends an ArgumentParser instance with the following commandline arguments: --context-size """ reference_context_group = parser.add_argument_group("Reference Transcripts") parser.add_argument( "--context-size", default=CDNA_CONTEXT...
[ "Extends", "an", "ArgumentParser", "instance", "with", "the", "following", "commandline", "arguments", ":", "--", "context", "-", "size" ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/cli/reference_context_args.py#L26-L36
[ "def", "add_reference_context_args", "(", "parser", ")", ":", "reference_context_group", "=", "parser", ".", "add_argument_group", "(", "\"Reference Transcripts\"", ")", "parser", ".", "add_argument", "(", "\"--context-size\"", ",", "default", "=", "CDNA_CONTEXT_SIZE", ...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
generate_numeric_range
Generate postgresql numeric range and label for insertion. Parameters ---------- items: iterable labels for ranges. lower_bound: numeric lower bound upper_bound: numeric upper bound
postpy/data_types.py
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): """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...
[ "Generate", "postgresql", "numeric", "range", "and", "label", "for", "insertion", "." ]
portfoliome/postpy
python
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/data_types.py#L30-L44
[ "def", "generate_numeric_range", "(", "items", ",", "lower_bound", ",", "upper_bound", ")", ":", "quantile_grid", "=", "create_quantiles", "(", "items", ",", "lower_bound", ",", "upper_bound", ")", "labels", ",", "bounds", "=", "(", "zip", "(", "*", "quantile_...
fe26199131b15295fc5f669a0ad2a7f47bf490ee
train
edge_average
Return the mean value around the edge of an array.
imagen/image.py
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 = 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) + ...
[ "Return", "the", "mean", "value", "around", "the", "edge", "of", "an", "array", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L206-L220
[ "def", "edge_average", "(", "a", ")", ":", "if", "len", "(", "np", ".", "ravel", "(", "a", ")", ")", "<", "2", ":", "return", "float", "(", "a", "[", "0", "]", ")", "else", ":", "top_edge", "=", "a", "[", "0", "]", "bottom_edge", "=", "a", ...
53c5685c880f54b42795964d8db50b02e8590e88
train
GenericImage._reduced_call
Simplified version of PatternGenerator's __call__ method.
imagen/image.py
def _reduced_call(self, **params_to_override): """ Simplified version of PatternGenerator's __call__ method. """ p=param.ParamOverrides(self,params_to_override) fn_result = self.function(p) self._apply_mask(p,fn_result) result = p.scale*fn_result+p.offset ...
def _reduced_call(self, **params_to_override): """ Simplified version of PatternGenerator's __call__ method. """ p=param.ParamOverrides(self,params_to_override) fn_result = self.function(p) self._apply_mask(p,fn_result) result = p.scale*fn_result+p.offset ...
[ "Simplified", "version", "of", "PatternGenerator", "s", "__call__", "method", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L310-L319
[ "def", "_reduced_call", "(", "self", ",", "*", "*", "params_to_override", ")", ":", "p", "=", "param", ".", "ParamOverrides", "(", "self", ",", "params_to_override", ")", "fn_result", "=", "self", ".", "function", "(", "p", ")", "self", ".", "_apply_mask",...
53c5685c880f54b42795964d8db50b02e8590e88
train
GenericImage._process_channels
Add the channel information to the channel_data attribute.
imagen/image.py
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): """ 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...
[ "Add", "the", "channel", "information", "to", "the", "channel_data", "attribute", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L322-L332
[ "def", "_process_channels", "(", "self", ",", "p", ",", "*", "*", "params_to_override", ")", ":", "orig_image", "=", "self", ".", "_image", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_channel_data", ")", ")", ":", "self", ".", "_image", ...
53c5685c880f54b42795964d8db50b02e8590e88
train
FileImage.set_matrix_dimensions
Subclassed to delete the cached image when matrix dimensions are changed.
imagen/image.py
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): """ Subclassed to delete the cached image when matrix dimensions are changed. """ self._image = None super(FileImage, self).set_matrix_dimensions(*args)
[ "Subclassed", "to", "delete", "the", "cached", "image", "when", "matrix", "dimensions", "are", "changed", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L425-L431
[ "def", "set_matrix_dimensions", "(", "self", ",", "*", "args", ")", ":", "self", ".", "_image", "=", "None", "super", "(", "FileImage", ",", "self", ")", ".", "set_matrix_dimensions", "(", "*", "args", ")" ]
53c5685c880f54b42795964d8db50b02e8590e88
train
FileImage._load_pil_image
Load image using PIL.
imagen/image.py
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): """ 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...
[ "Load", "image", "using", "PIL", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L450-L469
[ "def", "_load_pil_image", "(", "self", ",", "filename", ")", ":", "self", ".", "_channel_data", "=", "[", "]", "self", ".", "_original_channel_data", "=", "[", "]", "im", "=", "Image", ".", "open", "(", "filename", ")", "self", ".", "_image", "=", "Ima...
53c5685c880f54b42795964d8db50b02e8590e88
train
FileImage._load_npy
Load image using Numpy.
imagen/image.py
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): """ 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....
[ "Load", "image", "using", "Numpy", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/image.py#L472-L485
[ "def", "_load_npy", "(", "self", ",", "filename", ")", ":", "self", ".", "_channel_data", "=", "[", "]", "self", ".", "_original_channel_data", "=", "[", "]", "file_channel_data", "=", "np", ".", "load", "(", "filename", ")", "file_channel_data", "=", "fil...
53c5685c880f54b42795964d8db50b02e8590e88
train
add_protein_sequence_args
Extends an ArgumentParser instance with the following args: --max-protein-sequences-per-variant Also adds all translation arguments such as: --protein-sequence-length
isovar/cli/protein_sequence_args.py
def add_protein_sequence_args(parser): """ Extends an ArgumentParser instance with the following args: --max-protein-sequences-per-variant Also adds all translation arguments such as: --protein-sequence-length """ protein_sequence_group = parser.add_argument_group( "Protein s...
def add_protein_sequence_args(parser): """ Extends an ArgumentParser instance with the following args: --max-protein-sequences-per-variant Also adds all translation arguments such as: --protein-sequence-length """ protein_sequence_group = parser.add_argument_group( "Protein s...
[ "Extends", "an", "ArgumentParser", "instance", "with", "the", "following", "args", ":", "--", "max", "-", "protein", "-", "sequences", "-", "per", "-", "variant", "Also", "adds", "all", "translation", "arguments", "such", "as", ":", "--", "protein", "-", "...
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/cli/protein_sequence_args.py#L28-L41
[ "def", "add_protein_sequence_args", "(", "parser", ")", ":", "protein_sequence_group", "=", "parser", ".", "add_argument_group", "(", "\"Protein sequences (grouping equivalent translations)\"", ")", "protein_sequence_group", ".", "add_argument", "(", "\"--max-protein-sequences-pe...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
kwargfetch.ok_kwarg
Helper method for screening keyword arguments
opan/utils/decorate.py
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): """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
[ "Helper", "method", "for", "screening", "keyword", "arguments" ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/decorate.py#L186-L195
[ "def", "ok_kwarg", "(", "val", ")", ":", "import", "keyword", "try", ":", "return", "str", ".", "isidentifier", "(", "val", ")", "and", "not", "keyword", ".", "iskeyword", "(", "val", ")", "except", "TypeError", ":", "# Non-string values are never a valid keyw...
0b1b21662df6abc971407a9386db21a8796fbfe5
train
run
Run bulk record indexing.
invenio_indexer/cli.py
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): """Run bulk record indexing.""" if delayed: celery_kwargs = { 'kwargs': { 'version_type': version_type, 'es_bulk_kwargs': {'raise_on_error': raise_on_error}, ...
[ "Run", "bulk", "record", "indexing", "." ]
inveniosoftware/invenio-indexer
python
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L43-L63
[ "def", "run", "(", "delayed", ",", "concurrency", ",", "version_type", "=", "None", ",", "queue", "=", "None", ",", "raise_on_error", "=", "True", ")", ":", "if", "delayed", ":", "celery_kwargs", "=", "{", "'kwargs'", ":", "{", "'version_type'", ":", "ve...
1460aa8976b449d9a3a99d356322b158e9be6f80
train
reindex
Reindex all records. :param pid_type: Pid type.
invenio_indexer/cli.py
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): """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...
[ "Reindex", "all", "records", "." ]
inveniosoftware/invenio-indexer
python
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L72-L88
[ "def", "reindex", "(", "pid_type", ")", ":", "click", ".", "secho", "(", "'Sending records to indexing queue ...'", ",", "fg", "=", "'green'", ")", "query", "=", "(", "x", "[", "0", "]", "for", "x", "in", "PersistentIdentifier", ".", "query", ".", "filter_...
1460aa8976b449d9a3a99d356322b158e9be6f80
train
process_actions
Process queue actions.
invenio_indexer/cli.py
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): """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)
[ "Process", "queue", "actions", "." ]
inveniosoftware/invenio-indexer
python
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L98-L104
[ "def", "process_actions", "(", "actions", ")", ":", "queue", "=", "current_app", ".", "config", "[", "'INDEXER_MQ_QUEUE'", "]", "with", "establish_connection", "(", ")", "as", "c", ":", "q", "=", "queue", "(", "c", ")", "for", "action", "in", "actions", ...
1460aa8976b449d9a3a99d356322b158e9be6f80
train
init_queue
Initialize indexing queue.
invenio_indexer/cli.py
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(): """Initialize indexing queue.""" def action(queue): queue.declare() click.secho('Indexing queue has been initialized.', fg='green') return queue return action
[ "Initialize", "indexing", "queue", "." ]
inveniosoftware/invenio-indexer
python
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L108-L114
[ "def", "init_queue", "(", ")", ":", "def", "action", "(", "queue", ")", ":", "queue", ".", "declare", "(", ")", "click", ".", "secho", "(", "'Indexing queue has been initialized.'", ",", "fg", "=", "'green'", ")", "return", "queue", "return", "action" ]
1460aa8976b449d9a3a99d356322b158e9be6f80
train
purge_queue
Purge indexing queue.
invenio_indexer/cli.py
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(): """Purge indexing queue.""" def action(queue): queue.purge() click.secho('Indexing queue has been purged.', fg='green') return queue return action
[ "Purge", "indexing", "queue", "." ]
inveniosoftware/invenio-indexer
python
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L118-L124
[ "def", "purge_queue", "(", ")", ":", "def", "action", "(", "queue", ")", ":", "queue", ".", "purge", "(", ")", "click", ".", "secho", "(", "'Indexing queue has been purged.'", ",", "fg", "=", "'green'", ")", "return", "queue", "return", "action" ]
1460aa8976b449d9a3a99d356322b158e9be6f80
train
delete_queue
Delete indexing queue.
invenio_indexer/cli.py
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(): """Delete indexing queue.""" def action(queue): queue.delete() click.secho('Indexing queue has been deleted.', fg='green') return queue return action
[ "Delete", "indexing", "queue", "." ]
inveniosoftware/invenio-indexer
python
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/cli.py#L128-L134
[ "def", "delete_queue", "(", ")", ":", "def", "action", "(", "queue", ")", ":", "queue", ".", "delete", "(", ")", "click", ".", "secho", "(", "'Indexing queue has been deleted.'", ",", "fg", "=", "'green'", ")", "return", "queue", "return", "action" ]
1460aa8976b449d9a3a99d356322b158e9be6f80
train
variant_matches_reference_sequence
Make sure that reference nucleotides we expect to see on the reference transcript from a variant are the same ones we encounter.
isovar/reference_sequence_key.py
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): """ 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...
[ "Make", "sure", "that", "reference", "nucleotides", "we", "expect", "to", "see", "on", "the", "reference", "transcript", "from", "a", "variant", "are", "the", "same", "ones", "we", "encounter", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/reference_sequence_key.py#L131-L138
[ "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...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
ReferenceSequenceKey.from_variant_and_transcript
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...
isovar/reference_sequence_key.py
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): """ Extracts the reference sequence around a variant locus on a particular transcript. Parameters ---------- variant : varcode.Variant transcript : pyensembl.Transcript ...
[ "Extracts", "the", "reference", "sequence", "around", "a", "variant", "locus", "on", "a", "particular", "transcript", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/reference_sequence_key.py#L51-L128
[ "def", "from_variant_and_transcript", "(", "cls", ",", "variant", ",", "transcript", ",", "context_size", ")", ":", "full_transcript_sequence", "=", "transcript", ".", "sequence", "if", "full_transcript_sequence", "is", "None", ":", "logger", ".", "warn", "(", "\"...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
ellipsize
>>> print(ellipsize(u'lorem ipsum dolor sit amet', 40)) lorem ipsum dolor sit amet >>> print(ellipsize(u'lorem ipsum dolor sit amet', 20)) lorem ipsum dolor...
turq/util/text.py
def ellipsize(s, max_length=60): """ >>> print(ellipsize(u'lorem ipsum dolor sit amet', 40)) lorem ipsum dolor sit amet >>> print(ellipsize(u'lorem ipsum dolor sit amet', 20)) lorem ipsum dolor... """ if len(s) > max_length: ellipsis = '...' return s[:(max_length - len(ellips...
def ellipsize(s, max_length=60): """ >>> print(ellipsize(u'lorem ipsum dolor sit amet', 40)) lorem ipsum dolor sit amet >>> print(ellipsize(u'lorem ipsum dolor sit amet', 20)) lorem ipsum dolor... """ if len(s) > max_length: ellipsis = '...' return s[:(max_length - len(ellips...
[ ">>>", "print", "(", "ellipsize", "(", "u", "lorem", "ipsum", "dolor", "sit", "amet", "40", "))", "lorem", "ipsum", "dolor", "sit", "amet", ">>>", "print", "(", "ellipsize", "(", "u", "lorem", "ipsum", "dolor", "sit", "amet", "20", "))", "lorem", "ipsu...
vfaronov/turq
python
https://github.com/vfaronov/turq/blob/3ef1261442b90d6d947b8fe2362e19e7f47a64c3/turq/util/text.py#L43-L54
[ "def", "ellipsize", "(", "s", ",", "max_length", "=", "60", ")", ":", "if", "len", "(", "s", ")", ">", "max_length", ":", "ellipsis", "=", "'...'", "return", "s", "[", ":", "(", "max_length", "-", "len", "(", "ellipsis", ")", ")", "]", "+", "elli...
3ef1261442b90d6d947b8fe2362e19e7f47a64c3
train
wrap
Circularly alias the numeric value x into the range [lower,upper). Valid for cyclic quantities like orientations or hues.
imagen/__init__.py
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): """ 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...
[ "Circularly", "alias", "the", "numeric", "value", "x", "into", "the", "range", "[", "lower", "upper", ")", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L503-L515
[ "def", "wrap", "(", "lower", ",", "upper", ",", "x", ")", ":", "#I have no idea how I came up with this algorithm; it should be simplified.", "#", "# Note that Python's % operator works on floats and arrays;", "# usually one can simply use that instead. E.g. to wrap array or", "# scalar...
53c5685c880f54b42795964d8db50b02e8590e88
train
SineGrating.function
Return a sine grating pattern (two-dimensional sine wave).
imagen/__init__.py
def function(self,p): """Return a sine grating pattern (two-dimensional sine wave).""" return 0.5 + 0.5*np.sin(p.frequency*2*pi*self.pattern_y + p.phase)
def function(self,p): """Return a sine grating pattern (two-dimensional sine wave).""" return 0.5 + 0.5*np.sin(p.frequency*2*pi*self.pattern_y + p.phase)
[ "Return", "a", "sine", "grating", "pattern", "(", "two", "-", "dimensional", "sine", "wave", ")", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L146-L148
[ "def", "function", "(", "self", ",", "p", ")", ":", "return", "0.5", "+", "0.5", "*", "np", ".", "sin", "(", "p", ".", "frequency", "*", "2", "*", "pi", "*", "self", ".", "pattern_y", "+", "p", ".", "phase", ")" ]
53c5685c880f54b42795964d8db50b02e8590e88
train
Line._pixelsize
Calculate line width necessary to cover at least one pixel on all axes.
imagen/__init__.py
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): """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])
[ "Calculate", "line", "width", "necessary", "to", "cover", "at", "least", "one", "pixel", "on", "all", "axes", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L199-L203
[ "def", "_pixelsize", "(", "self", ",", "p", ")", ":", "xpixelsize", "=", "1.", "/", "float", "(", "p", ".", "xdensity", ")", "ypixelsize", "=", "1.", "/", "float", "(", "p", ".", "ydensity", ")", "return", "max", "(", "[", "xpixelsize", ",", "ypixe...
53c5685c880f54b42795964d8db50b02e8590e88
train
Line._count_pixels_on_line
Count the number of pixels rendered on this line.
imagen/__init__.py
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): """Count the number of pixels rendered on this line.""" h = line(y, self._effective_thickness(p), 0.0) return h.sum()
[ "Count", "the", "number", "of", "pixels", "rendered", "on", "this", "line", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L209-L212
[ "def", "_count_pixels_on_line", "(", "self", ",", "y", ",", "p", ")", ":", "h", "=", "line", "(", "y", ",", "self", ".", "_effective_thickness", "(", "p", ")", ",", "0.0", ")", "return", "h", ".", "sum", "(", ")" ]
53c5685c880f54b42795964d8db50b02e8590e88
train
Line._minimal_y
For the specified y and one offset by half a pixel, return the one that results in the fewest pixels turned on, so that when the thickness has been enforced to be at least one pixel, no extra pixels are needlessly included (which would cause double-width lines).
imagen/__init__.py
def _minimal_y(self, p): """ For the specified y and one offset by half a pixel, return the one that results in the fewest pixels turned on, so that when the thickness has been enforced to be at least one pixel, no extra pixels are needlessly included (which would cause d...
def _minimal_y(self, p): """ For the specified y and one offset by half a pixel, return the one that results in the fewest pixels turned on, so that when the thickness has been enforced to be at least one pixel, no extra pixels are needlessly included (which would cause d...
[ "For", "the", "specified", "y", "and", "one", "offset", "by", "half", "a", "pixel", "return", "the", "one", "that", "results", "in", "the", "fewest", "pixels", "turned", "on", "so", "that", "when", "the", "thickness", "has", "been", "enforced", "to", "be...
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L214-L224
[ "def", "_minimal_y", "(", "self", ",", "p", ")", ":", "y0", "=", "self", ".", "pattern_y", "y1", "=", "y0", "+", "self", ".", "_pixelsize", "(", "p", ")", "/", "2.", "return", "y0", "if", "self", ".", "_count_pixels_on_line", "(", "y0", ",", "p", ...
53c5685c880f54b42795964d8db50b02e8590e88
train
SquareGrating.function
Return a square-wave grating (alternating black and white bars).
imagen/__init__.py
def function(self,p): """ Return a square-wave grating (alternating black and white bars). """ return np.around( 0.5 + 0.5*np.sin(pi*(p.duty_cycle-0.5)) + 0.5*np.sin(p.frequency*2*pi*self.pattern_y + p.phase))
def function(self,p): """ Return a square-wave grating (alternating black and white bars). """ return np.around( 0.5 + 0.5*np.sin(pi*(p.duty_cycle-0.5)) + 0.5*np.sin(p.frequency*2*pi*self.pattern_y + p.phase))
[ "Return", "a", "square", "-", "wave", "grating", "(", "alternating", "black", "and", "white", "bars", ")", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L492-L499
[ "def", "function", "(", "self", ",", "p", ")", ":", "return", "np", ".", "around", "(", "0.5", "+", "0.5", "*", "np", ".", "sin", "(", "pi", "*", "(", "p", ".", "duty_cycle", "-", "0.5", ")", ")", "+", "0.5", "*", "np", ".", "sin", "(", "p"...
53c5685c880f54b42795964d8db50b02e8590e88
train
Selector.function
Selects and returns one of the patterns in the list.
imagen/__init__.py
def function(self,p): """Selects and returns one of the patterns in the list.""" int_index=int(len(p.generators)*wrap(0,1.0,p.index)) pg=p.generators[int_index] image_array = pg(xdensity=p.xdensity,ydensity=p.ydensity,bounds=p.bounds, x=p.x+p.size*(pg.x*np.cos(p...
def function(self,p): """Selects and returns one of the patterns in the list.""" int_index=int(len(p.generators)*wrap(0,1.0,p.index)) pg=p.generators[int_index] image_array = pg(xdensity=p.xdensity,ydensity=p.ydensity,bounds=p.bounds, x=p.x+p.size*(pg.x*np.cos(p...
[ "Selects", "and", "returns", "one", "of", "the", "patterns", "in", "the", "list", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L533-L544
[ "def", "function", "(", "self", ",", "p", ")", ":", "int_index", "=", "int", "(", "len", "(", "p", ".", "generators", ")", "*", "wrap", "(", "0", ",", "1.0", ",", "p", ".", "index", ")", ")", "pg", "=", "p", ".", "generators", "[", "int_index",...
53c5685c880f54b42795964d8db50b02e8590e88
train
Selector.get_current_generator
Return the current generator (as specified by self.index).
imagen/__init__.py
def get_current_generator(self): """Return the current generator (as specified by self.index).""" int_index=int(len(self.generators)*wrap(0,1.0,self.inspect_value('index'))) return self.generators[int_index]
def get_current_generator(self): """Return the current generator (as specified by self.index).""" int_index=int(len(self.generators)*wrap(0,1.0,self.inspect_value('index'))) return self.generators[int_index]
[ "Return", "the", "current", "generator", "(", "as", "specified", "by", "self", ".", "index", ")", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L546-L549
[ "def", "get_current_generator", "(", "self", ")", ":", "int_index", "=", "int", "(", "len", "(", "self", ".", "generators", ")", "*", "wrap", "(", "0", ",", "1.0", ",", "self", ".", "inspect_value", "(", "'index'", ")", ")", ")", "return", "self", "....
53c5685c880f54b42795964d8db50b02e8590e88
train
Selector.channels
Get channel data from the current generator. use_cached is not supported at the moment, though it must be forced to be True in the current_generator in order to avoid generating the same data twice (the first time by self() and the second with current_generator.channels() ).
imagen/__init__.py
def channels(self, use_cached=False, **params_to_override): """ Get channel data from the current generator. use_cached is not supported at the moment, though it must be forced to be True in the current_generator in order to avoid generating the same data twice (the first time b...
def channels(self, use_cached=False, **params_to_override): """ Get channel data from the current generator. use_cached is not supported at the moment, though it must be forced to be True in the current_generator in order to avoid generating the same data twice (the first time b...
[ "Get", "channel", "data", "from", "the", "current", "generator", ".", "use_cached", "is", "not", "supported", "at", "the", "moment", "though", "it", "must", "be", "forced", "to", "be", "True", "in", "the", "current_generator", "in", "order", "to", "avoid", ...
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L551-L565
[ "def", "channels", "(", "self", ",", "use_cached", "=", "False", ",", "*", "*", "params_to_override", ")", ":", "default", "=", "self", "(", "*", "*", "params_to_override", ")", "current_generator", "=", "self", ".", "get_current_generator", "(", ")", "res",...
53c5685c880f54b42795964d8db50b02e8590e88
train
Selector.num_channels
Get the number of channels in the input generators.
imagen/__init__.py
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): """ 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()....
[ "Get", "the", "number", "of", "channels", "in", "the", "input", "generators", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L567-L576
[ "def", "num_channels", "(", "self", ")", ":", "if", "(", "self", ".", "inspect_value", "(", "'index'", ")", "is", "None", ")", ":", "if", "(", "len", "(", "self", ".", "generators", ")", ">", "0", ")", ":", "return", "self", ".", "generators", "[",...
53c5685c880f54b42795964d8db50b02e8590e88
train
LogGaussian._setup_xy
Produce pattern coordinate matrices from the bounds and density (or rows and cols), and transforms them according to x, y, and orientation.
imagen/__init__.py
def _setup_xy(self, p): """ Produce pattern coordinate matrices from the bounds and density (or rows and cols), and transforms them according to x, y, and orientation. """ self.debug("bounds=%s, xdensity=%s, ydensity=%s, x=%s, y=%s, orientation=%s",p.bounds, p.xdensity, p...
def _setup_xy(self, p): """ Produce pattern coordinate matrices from the bounds and density (or rows and cols), and transforms them according to x, y, and orientation. """ self.debug("bounds=%s, xdensity=%s, ydensity=%s, x=%s, y=%s, orientation=%s",p.bounds, p.xdensity, p...
[ "Produce", "pattern", "coordinate", "matrices", "from", "the", "bounds", "and", "density", "(", "or", "rows", "and", "cols", ")", "and", "transforms", "them", "according", "to", "x", "y", "and", "orientation", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L1122-L1132
[ "def", "_setup_xy", "(", "self", ",", "p", ")", ":", "self", ".", "debug", "(", "\"bounds=%s, xdensity=%s, ydensity=%s, x=%s, y=%s, orientation=%s\"", ",", "p", ".", "bounds", ",", "p", ".", "xdensity", ",", "p", ".", "ydensity", ",", "p", ".", "x", ",", "...
53c5685c880f54b42795964d8db50b02e8590e88
train
LogGaussian._create_and_rotate_coordinate_arrays
Create pattern matrices from x and y vectors, and rotate them to the specified orientation.
imagen/__init__.py
def _create_and_rotate_coordinate_arrays(self, x, y, p): """ Create pattern matrices from x and y vectors, and rotate them to the specified orientation. """ if p.aspect_ratio == 0 or p.size == 0: x = x * 0.0 y = y * 0.0 else: x = (x*10...
def _create_and_rotate_coordinate_arrays(self, x, y, p): """ Create pattern matrices from x and y vectors, and rotate them to the specified orientation. """ if p.aspect_ratio == 0 or p.size == 0: x = x * 0.0 y = y * 0.0 else: x = (x*10...
[ "Create", "pattern", "matrices", "from", "x", "and", "y", "vectors", "and", "rotate", "them", "to", "the", "specified", "orientation", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L1135-L1155
[ "def", "_create_and_rotate_coordinate_arrays", "(", "self", ",", "x", ",", "y", ",", "p", ")", ":", "if", "p", ".", "aspect_ratio", "==", "0", "or", "p", ".", "size", "==", "0", ":", "x", "=", "x", "*", "0.0", "y", "=", "y", "*", "0.0", "else", ...
53c5685c880f54b42795964d8db50b02e8590e88
train
TimeSeries.extract_specific_interval
Overload if special behaviour is required when a series ends.
imagen/__init__.py
def extract_specific_interval(self, interval_start, interval_end): """ Overload if special behaviour is required when a series ends. """ interval_start = int(interval_start) interval_end = int(interval_end) if interval_start >= interval_end: raise ValueError...
def extract_specific_interval(self, interval_start, interval_end): """ Overload if special behaviour is required when a series ends. """ interval_start = int(interval_start) interval_end = int(interval_end) if interval_start >= interval_end: raise ValueError...
[ "Overload", "if", "special", "behaviour", "is", "required", "when", "a", "series", "ends", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L1265-L1308
[ "def", "extract_specific_interval", "(", "self", ",", "interval_start", ",", "interval_end", ")", ":", "interval_start", "=", "int", "(", "interval_start", ")", "interval_end", "=", "int", "(", "interval_end", ")", "if", "interval_start", ">=", "interval_end", ":"...
53c5685c880f54b42795964d8db50b02e8590e88
train
PowerSpectrum._set_frequency_spacing
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 _...
imagen/__init__.py
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): """ 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 ...
[ "Frequency", "spacing", "to", "use", "i", ".", "e", ".", "how", "to", "map", "the", "available", "frequency", "range", "to", "the", "discrete", "sheet", "rows", "." ]
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L1401-L1415
[ "def", "_set_frequency_spacing", "(", "self", ",", "min_freq", ",", "max_freq", ")", ":", "self", ".", "frequency_spacing", "=", "np", ".", "linspace", "(", "min_freq", ",", "max_freq", ",", "num", "=", "self", ".", "_sheet_dimensions", "[", "0", "]", "+",...
53c5685c880f54b42795964d8db50b02e8590e88
train
PowerSpectrum._get_row_amplitudes
Perform a real Discrete Fourier Transform (DFT; implemented using a Fast Fourier Transform algorithm, FFT) of the current sample from the signal multiplied by the smoothing window. See numpy.rfft for information about the Fourier transform.
imagen/__init__.py
def _get_row_amplitudes(self): """ Perform a real Discrete Fourier Transform (DFT; implemented using a Fast Fourier Transform algorithm, FFT) of the current sample from the signal multiplied by the smoothing window. See numpy.rfft for information about the Fourier transform. ...
def _get_row_amplitudes(self): """ Perform a real Discrete Fourier Transform (DFT; implemented using a Fast Fourier Transform algorithm, FFT) of the current sample from the signal multiplied by the smoothing window. See numpy.rfft for information about the Fourier transform. ...
[ "Perform", "a", "real", "Discrete", "Fourier", "Transform", "(", "DFT", ";", "implemented", "using", "a", "Fast", "Fourier", "Transform", "algorithm", "FFT", ")", "of", "the", "current", "sample", "from", "the", "signal", "multiplied", "by", "the", "smoothing"...
pyviz/imagen
python
https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/__init__.py#L1418-L1450
[ "def", "_get_row_amplitudes", "(", "self", ")", ":", "signal_interval", "=", "self", ".", "signal", "(", ")", "sample_rate", "=", "self", ".", "signal", ".", "sample_rate", "# A signal window *must* span one sample rate", "signal_window", "=", "np", ".", "tile", "...
53c5685c880f54b42795964d8db50b02e8590e88
train
create_graph
This function creates a graph of vertices and edges from segments returned by SLIC. :param array grid: A grid of segments as returned by the slic function defined in skimage library :return: A graph as [vertices, edges]
segraph/segraph.py
def create_graph(grid): """ This function creates a graph of vertices and edges from segments returned by SLIC. :param array grid: A grid of segments as returned by the slic function defined in skimage library :return: A graph as [vertices, edges] """ try: import numpy as np except I...
def create_graph(grid): """ This function creates a graph of vertices and edges from segments returned by SLIC. :param array grid: A grid of segments as returned by the slic function defined in skimage library :return: A graph as [vertices, edges] """ try: import numpy as np except I...
[ "This", "function", "creates", "a", "graph", "of", "vertices", "and", "edges", "from", "segments", "returned", "by", "SLIC", ".", ":", "param", "array", "grid", ":", "A", "grid", "of", "segments", "as", "returned", "by", "the", "slic", "function", "defined...
alivcor/segraph
python
https://github.com/alivcor/segraph/blob/697c2d7c06bcec80111658ec62058401c2e24797/segraph/segraph.py#L5-L51
[ "def", "create_graph", "(", "grid", ")", ":", "try", ":", "import", "numpy", "as", "np", "except", "ImportError", ":", "print", "(", "\"NumPY is not installed. segraph needs NumPY to function. Please use 'pip install numpy' to install numpy.\"", ")", "exit", "(", "0", ")"...
697c2d7c06bcec80111658ec62058401c2e24797
train
default_record_to_index
Get index/doc_type given a record. It tries to extract from `record['$schema']` the index and doc_type. If it fails, return the default values. :param record: The record object. :returns: Tuple (index, doc_type).
invenio_indexer/utils.py
def default_record_to_index(record): """Get index/doc_type given a record. It tries to extract from `record['$schema']` the index and doc_type. If it fails, return the default values. :param record: The record object. :returns: Tuple (index, doc_type). """ index_names = current_search.mapp...
def default_record_to_index(record): """Get index/doc_type given a record. It tries to extract from `record['$schema']` the index and doc_type. If it fails, return the default values. :param record: The record object. :returns: Tuple (index, doc_type). """ index_names = current_search.mapp...
[ "Get", "index", "/", "doc_type", "given", "a", "record", "." ]
inveniosoftware/invenio-indexer
python
https://github.com/inveniosoftware/invenio-indexer/blob/1460aa8976b449d9a3a99d356322b158e9be6f80/invenio_indexer/utils.py#L16-L36
[ "def", "default_record_to_index", "(", "record", ")", ":", "index_names", "=", "current_search", ".", "mappings", ".", "keys", "(", ")", "schema", "=", "record", ".", "get", "(", "'$schema'", ",", "''", ")", "if", "isinstance", "(", "schema", ",", "dict", ...
1460aa8976b449d9a3a99d356322b158e9be6f80
train
get_postgres_encoding
Python to postgres encoding map.
postpy/pg_encodings.py
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: """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", "to", "postgres", "encoding", "map", "." ]
portfoliome/postpy
python
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/pg_encodings.py#L15-L22
[ "def", "get_postgres_encoding", "(", "python_encoding", ":", "str", ")", "->", "str", ":", "encoding", "=", "normalize_encoding", "(", "python_encoding", ".", "lower", "(", ")", ")", "encoding_", "=", "aliases", ".", "aliases", "[", "encoding", ".", "replace",...
fe26199131b15295fc5f669a0ad2a7f47bf490ee
train
_init
Try loading each binding in turn Please note: the entire Qt module is replaced with this code: sys.modules["Qt"] = binding() This means no functions or variables can be called after this has executed.
pyblish_houdini/vendor/Qt.py
def _init(): """Try loading each binding in turn Please note: the entire Qt module is replaced with this code: sys.modules["Qt"] = binding() This means no functions or variables can be called after this has executed. """ preferred = os.getenv("QT_PREFERRED_BINDING") verbose = os....
def _init(): """Try loading each binding in turn Please note: the entire Qt module is replaced with this code: sys.modules["Qt"] = binding() This means no functions or variables can be called after this has executed. """ preferred = os.getenv("QT_PREFERRED_BINDING") verbose = os....
[ "Try", "loading", "each", "binding", "in", "turn" ]
pyblish/pyblish-houdini
python
https://github.com/pyblish/pyblish-houdini/blob/661b08696f04b4c5d8b03aa0c75cba3ca72f1e8d/pyblish_houdini/vendor/Qt.py#L177-L234
[ "def", "_init", "(", ")", ":", "preferred", "=", "os", ".", "getenv", "(", "\"QT_PREFERRED_BINDING\"", ")", "verbose", "=", "os", ".", "getenv", "(", "\"QT_VERBOSE\"", ")", "is", "not", "None", "if", "preferred", ":", "# Debug mode, used in installer", "if", ...
661b08696f04b4c5d8b03aa0c75cba3ca72f1e8d
train
OrcaOutput.en_last
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...
opan/output.py
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): """ 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 ...
[ "Report", "the", "energies", "from", "the", "last", "SCF", "present", "in", "the", "output", "." ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/output.py#L792-L818
[ "def", "en_last", "(", "self", ")", ":", "# Initialize the return dict", "last_ens", "=", "dict", "(", ")", "# Iterate and store", "for", "(", "k", ",", "l", ")", "in", "self", ".", "en", ".", "items", "(", ")", ":", "last_ens", ".", "update", "(", "{"...
0b1b21662df6abc971407a9386db21a8796fbfe5
train
connect
Create a database connection.
postpy/connections.py
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): """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...
[ "Create", "a", "database", "connection", "." ]
portfoliome/postpy
python
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/connections.py#L8-L20
[ "def", "connect", "(", "host", "=", "None", ",", "database", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "host", "=", "host", "or", "os", ".", "environ", "[", "'PGHOST'", "]", "database", ...
fe26199131b15295fc5f669a0ad2a7f47bf490ee
train
execute_orca
Executes |orca| on a dynamically constructed input file. .. warning:: Function is still under active development! Execution with `wait_to_complete` == |True| should be robust, however. **Execution** Generates an |orca| input file dynamically from information passed into the various arguments,...
opan/utils/execute.py
def execute_orca(inp_tp, work_dir, exec_cmd, subs=None, subs_delims=("<",">"), sim_name="orcarun", inp_ext=_DEF.FILE_EXTS[_E_SW.ORCA][_E_FT.INPUTFILE], out_ext=_DEF.FILE_EXTS[_E_SW.ORCA][_E_FT.OUTPUT], wait_to_complete=True, bohrs=False): """Executes |orca...
def execute_orca(inp_tp, work_dir, exec_cmd, subs=None, subs_delims=("<",">"), sim_name="orcarun", inp_ext=_DEF.FILE_EXTS[_E_SW.ORCA][_E_FT.INPUTFILE], out_ext=_DEF.FILE_EXTS[_E_SW.ORCA][_E_FT.OUTPUT], wait_to_complete=True, bohrs=False): """Executes |orca...
[ "Executes", "|orca|", "on", "a", "dynamically", "constructed", "input", "file", "." ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/execute.py#L36-L311
[ "def", "execute_orca", "(", "inp_tp", ",", "work_dir", ",", "exec_cmd", ",", "subs", "=", "None", ",", "subs_delims", "=", "(", "\"<\"", ",", "\">\"", ")", ",", "sim_name", "=", "\"orcarun\"", ",", "inp_ext", "=", "_DEF", ".", "FILE_EXTS", "[", "_E_SW", ...
0b1b21662df6abc971407a9386db21a8796fbfe5
train
_setup
Set up module. Open a UDP socket, and listen in a thread.
orvibo/s20.py
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(): """ 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()
[ "Set", "up", "module", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L50-L58
[ "def", "_setup", "(", ")", ":", "_SOCKET", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_BROADCAST", ",", "1", ")", "_SOCKET", ".", "bind", "(", "(", "''", ",", "PORT", ")", ")", "udp", "=", "threading", ".", "Thread", ...
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
discover
Discover devices on the local network. :param timeout: Optional timeout in seconds. :returns: Set of discovered host addresses.
orvibo/s20.py
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): """ 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...
[ "Discover", "devices", "on", "the", "local", "network", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L66-L91
[ "def", "discover", "(", "timeout", "=", "DISCOVERY_TIMEOUT", ")", ":", "hosts", "=", "{", "}", "payload", "=", "MAGIC", "+", "DISCOVERY", "for", "_", "in", "range", "(", "RETRIES", ")", ":", "_SOCKET", ".", "sendto", "(", "bytearray", "(", "payload", "...
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
S20._discover_mac
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...
orvibo/s20.py
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): """ 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: ...
[ "Discovers", "MAC", "address", "of", "device", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L167-L188
[ "def", "_discover_mac", "(", "self", ")", ":", "mac", "=", "None", "mac_reversed", "=", "None", "cmd", "=", "MAGIC", "+", "DISCOVERY", "resp", "=", "self", ".", "_udp_transact", "(", "cmd", ",", "self", ".", "_discovery_resp", ",", "broadcast", "=", "Tru...
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
S20._subscribe
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.
orvibo/s20.py
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): """ 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...
[ "Subscribe", "to", "the", "device", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L190-L206
[ "def", "_subscribe", "(", "self", ")", ":", "cmd", "=", "MAGIC", "+", "SUBSCRIBE", "+", "self", ".", "_mac", "+", "PADDING_1", "+", "self", ".", "_mac_reversed", "+", "PADDING_1", "status", "=", "self", ".", "_udp_transact", "(", "cmd", ",", "self", "....
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
S20._control
Control device state. Possible states are ON or OFF. :param state: Switch to this state.
orvibo/s20.py
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): """ 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...
[ "Control", "device", "state", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L215-L233
[ "def", "_control", "(", "self", ",", "state", ")", ":", "# Renew subscription if necessary", "if", "not", "self", ".", "_subscription_is_recent", "(", ")", ":", "self", ".", "_subscribe", "(", ")", "cmd", "=", "MAGIC", "+", "CONTROL", "+", "self", ".", "_m...
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
S20._discovery_resp
Handle a discovery response. :param data: Payload. :param addr: Address tuple. :returns: MAC and reversed MAC.
orvibo/s20.py
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): """ 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, ...
[ "Handle", "a", "discovery", "response", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L235-L245
[ "def", "_discovery_resp", "(", "self", ",", "data", ")", ":", "if", "_is_discovery_response", "(", "data", ")", ":", "_LOGGER", ".", "debug", "(", "\"Discovered MAC of %s: %s\"", ",", "self", ".", "host", ",", "binascii", ".", "hexlify", "(", "data", "[", ...
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
S20._subscribe_resp
Handle a subscribe response. :param data: Payload. :returns: State (ON/OFF)
orvibo/s20.py
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): """ 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", ...
[ "Handle", "a", "subscribe", "response", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L247-L257
[ "def", "_subscribe_resp", "(", "self", ",", "data", ")", ":", "if", "_is_subscribe_response", "(", "data", ")", ":", "status", "=", "bytes", "(", "[", "data", "[", "23", "]", "]", ")", "_LOGGER", ".", "debug", "(", "\"Successfully subscribed to %s, state: %s...
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
S20._control_resp
Handle a control response. :param data: Payload. :param state: Requested state. :returns: Acknowledged state.
orvibo/s20.py
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): """ 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: ...
[ "Handle", "a", "control", "response", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L259-L271
[ "def", "_control_resp", "(", "self", ",", "data", ",", "state", ")", ":", "if", "_is_control_response", "(", "data", ")", ":", "ack_state", "=", "bytes", "(", "[", "data", "[", "22", "]", "]", ")", "if", "state", "==", "ack_state", ":", "_LOGGER", "....
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
S20._udp_transact
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...
orvibo/s20.py
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): """ 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...
[ "Complete", "a", "UDP", "transaction", "." ]
happyleavesaoc/python-orvibo
python
https://github.com/happyleavesaoc/python-orvibo/blob/27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9/orvibo/s20.py#L273-L303
[ "def", "_udp_transact", "(", "self", ",", "payload", ",", "handler", ",", "*", "args", ",", "broadcast", "=", "False", ",", "timeout", "=", "TIMEOUT", ")", ":", "if", "self", ".", "host", "in", "_BUFFER", ":", "del", "_BUFFER", "[", "self", ".", "hos...
27210dfe0c44a9e4f2ef4edf2dac221977d7f5c9
train
load
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
opencorpora/reader_lxml.py
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): """ 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()
[ "Load", "OpenCorpora", "corpus", "." ]
kmike/opencorpora-tools
python
https://github.com/kmike/opencorpora-tools/blob/26fee106aea1180d2975b3825dcf9b3875e80db1/opencorpora/reader_lxml.py#L11-L24
[ "def", "load", "(", "source", ")", ":", "parser", "=", "get_xml_parser", "(", ")", "return", "etree", ".", "parse", "(", "source", ",", "parser", "=", "parser", ")", ".", "getroot", "(", ")" ]
26fee106aea1180d2975b3825dcf9b3875e80db1
train
find_mutant_amino_acid_interval
Parameters ---------- cdna_sequence : skbio.DNA or str cDNA sequence found in RNAseq data cdna_first_codon_offset : int Offset into cDNA sequence to first complete codon, lets us skip past UTR region and incomplete codons. cdna_variant_start_offset : int Interbase start...
isovar/translation.py
def find_mutant_amino_acid_interval( cdna_sequence, cdna_first_codon_offset, cdna_variant_start_offset, cdna_variant_end_offset, n_ref, n_amino_acids): """ Parameters ---------- cdna_sequence : skbio.DNA or str cDNA sequence found in RNAseq data ...
def find_mutant_amino_acid_interval( cdna_sequence, cdna_first_codon_offset, cdna_variant_start_offset, cdna_variant_end_offset, n_ref, n_amino_acids): """ Parameters ---------- cdna_sequence : skbio.DNA or str cDNA sequence found in RNAseq data ...
[ "Parameters", "----------", "cdna_sequence", ":", "skbio", ".", "DNA", "or", "str", "cDNA", "sequence", "found", "in", "RNAseq", "data" ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L261-L352
[ "def", "find_mutant_amino_acid_interval", "(", "cdna_sequence", ",", "cdna_first_codon_offset", ",", "cdna_variant_start_offset", ",", "cdna_variant_end_offset", ",", "n_ref", ",", "n_amino_acids", ")", ":", "cdna_alt_nucleotides", "=", "cdna_sequence", "[", "cdna_variant_sta...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
translation_generator
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...
isovar/translation.py
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): """ Given all detected VariantSequence objects for a particular variant ...
[ "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...
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L355-L405
[ "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"...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
translate_variant_reads
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...
isovar/translation.py
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, min_transcript_prefix_length=MIN_TRANSCRIPT_PREFIX_LENGTH,...
[ "Given", "a", "variant", "and", "its", "associated", "alt", "reads", "construct", "variant", "sequences", "and", "translate", "them", "into", "Translation", "objects", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L408-L505
[ "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", ...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
translate_variants
Translates each coding variant in a collection to one or more protein fragment sequences (if the variant is not filtered and its spanning RNA sequences can be given a reading frame). Parameters ---------- variants_with_reads : sequence or generator Each item of this sequence should be a pai...
isovar/translation.py
def translate_variants( variants_with_supporting_reads, transcript_id_whitelist=None, protein_sequence_length=PROTEIN_SEQUENCE_LENGTH, min_alt_rna_reads=MIN_ALT_RNA_READS, min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE, min_transcript_prefix_length=MIN_TRANSC...
def translate_variants( variants_with_supporting_reads, transcript_id_whitelist=None, protein_sequence_length=PROTEIN_SEQUENCE_LENGTH, min_alt_rna_reads=MIN_ALT_RNA_READS, min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE, min_transcript_prefix_length=MIN_TRANSC...
[ "Translates", "each", "coding", "variant", "in", "a", "collection", "to", "one", "or", "more", "protein", "fragment", "sequences", "(", "if", "the", "variant", "is", "not", "filtered", "and", "its", "spanning", "RNA", "sequences", "can", "be", "given", "a", ...
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L508-L577
[ "def", "translate_variants", "(", "variants_with_supporting_reads", ",", "transcript_id_whitelist", "=", "None", ",", "protein_sequence_length", "=", "PROTEIN_SEQUENCE_LENGTH", ",", "min_alt_rna_reads", "=", "MIN_ALT_RNA_READS", ",", "min_variant_sequence_coverage", "=", "MIN_V...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
translations_generator_to_dataframe
Given a generator of (Variant, [Translation]) pairs, returns a DataFrame of translated protein fragments with columns for each field of a Translation object (and chr/pos/ref/alt per variant).
isovar/translation.py
def translations_generator_to_dataframe(translations_generator): """ Given a generator of (Variant, [Translation]) pairs, returns a DataFrame of translated protein fragments with columns for each field of a Translation object (and chr/pos/ref/alt per variant). """ return dataframe_from_generator...
def translations_generator_to_dataframe(translations_generator): """ Given a generator of (Variant, [Translation]) pairs, returns a DataFrame of translated protein fragments with columns for each field of a Translation object (and chr/pos/ref/alt per variant). """ return dataframe_from_generator...
[ "Given", "a", "generator", "of", "(", "Variant", "[", "Translation", "]", ")", "pairs", "returns", "a", "DataFrame", "of", "translated", "protein", "fragments", "with", "columns", "for", "each", "field", "of", "a", "Translation", "object", "(", "and", "chr",...
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L580-L602
[ "def", "translations_generator_to_dataframe", "(", "translations_generator", ")", ":", "return", "dataframe_from_generator", "(", "element_class", "=", "Translation", ",", "variant_and_elements_generator", "=", "translations_generator", ",", "exclude", "=", "[", "]", ",", ...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
Translation.as_translation_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.
isovar/translation.py
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): """ 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...
[ "Project", "Translation", "object", "or", "any", "other", "derived", "class", "into", "just", "a", "TranslationKey", "which", "has", "fewer", "fields", "and", "can", "be", "used", "as", "a", "dictionary", "key", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L150-L158
[ "def", "as_translation_key", "(", "self", ")", ":", "return", "TranslationKey", "(", "*", "*", "{", "name", ":", "getattr", "(", "self", ",", "name", ")", "for", "name", "in", "TranslationKey", ".", "_fields", "}", ")" ]
b39b684920e3f6b344851d6598a1a1c67bce913b
train
Translation.from_variant_sequence_and_reference_context
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...
isovar/translation.py
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): """ Att...
[ "Attempt", "to", "translate", "a", "single", "VariantSequence", "using", "the", "reading", "frame", "from", "a", "single", "ReferenceContext", "." ]
openvax/isovar
python
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/translation.py#L161-L258
[ "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", ")", ...
b39b684920e3f6b344851d6598a1a1c67bce913b
train
Cachet.postComponents
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 ...
cachet.py
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): '''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...
[ "Create", "a", "new", "component", "." ]
imlonghao/cachet.python
python
https://github.com/imlonghao/cachet.python/blob/624b0d8e09b551a3be45dec207da6aa89f1e56e8/cachet.py#L51-L67
[ "def", "postComponents", "(", "self", ",", "name", ",", "status", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'name'", "]", "=", "name", "kwargs", "[", "'status'", "]", "=", "status", "return", "self", ".", "__postRequest", "(", "'/components'", ...
624b0d8e09b551a3be45dec207da6aa89f1e56e8
train
Cachet.postIncidents
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. ...
cachet.py
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): '''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...
[ "Create", "a", "new", "incident", "." ]
imlonghao/cachet.python
python
https://github.com/imlonghao/cachet.python/blob/624b0d8e09b551a3be45dec207da6aa89f1e56e8/cachet.py#L168-L186
[ "def", "postIncidents", "(", "self", ",", "name", ",", "message", ",", "status", ",", "visible", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'name'", "]", "=", "name", "kwargs", "[", "'message'", "]", "=", "message", "kwargs", "[", "'status'", ...
624b0d8e09b551a3be45dec207da6aa89f1e56e8
train
Cachet.postMetrics
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...
cachet.py
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): '''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...
[ "Create", "a", "new", "metric", "." ]
imlonghao/cachet.python
python
https://github.com/imlonghao/cachet.python/blob/624b0d8e09b551a3be45dec207da6aa89f1e56e8/cachet.py#L223-L239
[ "def", "postMetrics", "(", "self", ",", "name", ",", "suffix", ",", "description", ",", "default_value", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'name'", "]", "=", "name", "kwargs", "[", "'suffix'", "]", "=", "suffix", "kwargs", "[", "'descr...
624b0d8e09b551a3be45dec207da6aa89f1e56e8
train
Cachet.postMetricsPointsByID
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
cachet.py
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): '''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...
[ "Add", "a", "metric", "point", "to", "a", "given", "metric", "." ]
imlonghao/cachet.python
python
https://github.com/imlonghao/cachet.python/blob/624b0d8e09b551a3be45dec207da6aa89f1e56e8/cachet.py#L271-L282
[ "def", "postMetricsPointsByID", "(", "self", ",", "id", ",", "value", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'value'", "]", "=", "value", "return", "self", ".", "__postRequest", "(", "'/metrics/%s/points'", "%", "id", ",", "kwargs", ")" ]
624b0d8e09b551a3be45dec207da6aa89f1e56e8
train
ctr_mass
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...
opan/utils/inertia.py
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): """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...
[ "Calculate", "the", "center", "of", "mass", "of", "the", "indicated", "geometry", "." ]
bskinn/opan
python
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/inertia.py#L52-L113
[ "def", "ctr_mass", "(", "geom", ",", "masses", ")", ":", "# Imports", "import", "numpy", "as", "np", "from", ".", "base", "import", "safe_cast", "as", "scast", "# Shape check", "if", "len", "(", "geom", ".", "shape", ")", "!=", "1", ":", "raise", "Valu...
0b1b21662df6abc971407a9386db21a8796fbfe5