id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
55,800 | acorg/dark-matter | dark/reads.py | SSAARead.newFromSites | def newFromSites(self, sites, exclude=False):
"""
Create a new read from self, with only certain sites.
@param sites: A set of C{int} 0-based sites (i.e., indices) in
sequences that should be kept. If C{None} (the default), all sites
are kept.
@param exclude: If ... | python | def newFromSites(self, sites, exclude=False):
"""
Create a new read from self, with only certain sites.
@param sites: A set of C{int} 0-based sites (i.e., indices) in
sequences that should be kept. If C{None} (the default), all sites
are kept.
@param exclude: If ... | [
"def",
"newFromSites",
"(",
"self",
",",
"sites",
",",
"exclude",
"=",
"False",
")",
":",
"if",
"exclude",
":",
"sites",
"=",
"set",
"(",
"range",
"(",
"len",
"(",
"self",
")",
")",
")",
"-",
"sites",
"newSequence",
"=",
"[",
"]",
"newStructure",
"... | Create a new read from self, with only certain sites.
@param sites: A set of C{int} 0-based sites (i.e., indices) in
sequences that should be kept. If C{None} (the default), all sites
are kept.
@param exclude: If C{True} the C{sites} will be excluded, not
included. | [
"Create",
"a",
"new",
"read",
"from",
"self",
"with",
"only",
"certain",
"sites",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L673-L696 |
55,801 | acorg/dark-matter | dark/reads.py | Reads.filterRead | def filterRead(self, read):
"""
Filter a read, according to our set of filters.
@param read: A C{Read} instance or one of its subclasses.
@return: C{False} if the read fails any of our filters, else the
C{Read} instance returned by our list of filters.
"""
fo... | python | def filterRead(self, read):
"""
Filter a read, according to our set of filters.
@param read: A C{Read} instance or one of its subclasses.
@return: C{False} if the read fails any of our filters, else the
C{Read} instance returned by our list of filters.
"""
fo... | [
"def",
"filterRead",
"(",
"self",
",",
"read",
")",
":",
"for",
"filterFunc",
"in",
"self",
".",
"_filters",
":",
"filteredRead",
"=",
"filterFunc",
"(",
"read",
")",
"if",
"filteredRead",
"is",
"False",
":",
"return",
"False",
"else",
":",
"read",
"=",
... | Filter a read, according to our set of filters.
@param read: A C{Read} instance or one of its subclasses.
@return: C{False} if the read fails any of our filters, else the
C{Read} instance returned by our list of filters. | [
"Filter",
"a",
"read",
"according",
"to",
"our",
"set",
"of",
"filters",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1221-L1235 |
55,802 | acorg/dark-matter | dark/reads.py | Reads.summarizePosition | def summarizePosition(self, index):
"""
Compute residue counts at a specific sequence index.
@param index: an C{int} index into the sequence.
@return: A C{dict} with the count of too-short (excluded) sequences,
and a Counter instance giving the residue counts.
"""
... | python | def summarizePosition(self, index):
"""
Compute residue counts at a specific sequence index.
@param index: an C{int} index into the sequence.
@return: A C{dict} with the count of too-short (excluded) sequences,
and a Counter instance giving the residue counts.
"""
... | [
"def",
"summarizePosition",
"(",
"self",
",",
"index",
")",
":",
"countAtPosition",
"=",
"Counter",
"(",
")",
"excludedCount",
"=",
"0",
"for",
"read",
"in",
"self",
":",
"try",
":",
"countAtPosition",
"[",
"read",
".",
"sequence",
"[",
"index",
"]",
"]"... | Compute residue counts at a specific sequence index.
@param index: an C{int} index into the sequence.
@return: A C{dict} with the count of too-short (excluded) sequences,
and a Counter instance giving the residue counts. | [
"Compute",
"residue",
"counts",
"at",
"a",
"specific",
"sequence",
"index",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1374-L1394 |
55,803 | kyegupov/py-unrar2 | UnRAR2/__init__.py | condition2checker | def condition2checker(condition):
"""Converts different condition types to callback"""
if isinstance(condition, string_types):
def smatcher(info):
return fnmatch.fnmatch(info.filename, condition)
return smatcher
elif isinstance(condition, (list, tuple)) and isinstance(condition[... | python | def condition2checker(condition):
"""Converts different condition types to callback"""
if isinstance(condition, string_types):
def smatcher(info):
return fnmatch.fnmatch(info.filename, condition)
return smatcher
elif isinstance(condition, (list, tuple)) and isinstance(condition[... | [
"def",
"condition2checker",
"(",
"condition",
")",
":",
"if",
"isinstance",
"(",
"condition",
",",
"string_types",
")",
":",
"def",
"smatcher",
"(",
"info",
")",
":",
"return",
"fnmatch",
".",
"fnmatch",
"(",
"info",
".",
"filename",
",",
"condition",
")",... | Converts different condition types to callback | [
"Converts",
"different",
"condition",
"types",
"to",
"callback"
] | 186a4c1feb9ef3d96a2331f8fb3ebf88036e15e5 | https://github.com/kyegupov/py-unrar2/blob/186a4c1feb9ef3d96a2331f8fb3ebf88036e15e5/UnRAR2/__init__.py#L177-L193 |
55,804 | flo-compbio/genometools | genometools/enrichment/analysis.py | GeneSetEnrichmentAnalysis.get_static_enrichment | def get_static_enrichment(
self, genes: Iterable[str],
pval_thresh: float,
adjust_pval_thresh: bool = True,
K_min: int = 3,
gene_set_ids: Iterable[str] = None) -> StaticGSEResult:
"""Find enriched gene sets in a set of genes.
Parameters
... | python | def get_static_enrichment(
self, genes: Iterable[str],
pval_thresh: float,
adjust_pval_thresh: bool = True,
K_min: int = 3,
gene_set_ids: Iterable[str] = None) -> StaticGSEResult:
"""Find enriched gene sets in a set of genes.
Parameters
... | [
"def",
"get_static_enrichment",
"(",
"self",
",",
"genes",
":",
"Iterable",
"[",
"str",
"]",
",",
"pval_thresh",
":",
"float",
",",
"adjust_pval_thresh",
":",
"bool",
"=",
"True",
",",
"K_min",
":",
"int",
"=",
"3",
",",
"gene_set_ids",
":",
"Iterable",
... | Find enriched gene sets in a set of genes.
Parameters
----------
genes : set of str
The set of genes to test for gene set enrichment.
pval_thresh : float
The significance level (p-value threshold) to use in the analysis.
adjust_pval_thresh : bool, optiona... | [
"Find",
"enriched",
"gene",
"sets",
"in",
"a",
"set",
"of",
"genes",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/enrichment/analysis.py#L126-L229 |
55,805 | cebel/pyuniprot | src/pyuniprot/manager/database.py | get_connection_string | def get_connection_string(connection=None):
"""return SQLAlchemy connection string if it is set
:param connection: get the SQLAlchemy connection string #TODO
:rtype: str
"""
if not connection:
config = configparser.ConfigParser()
cfp = defaults.config_file_path
if os.path.ex... | python | def get_connection_string(connection=None):
"""return SQLAlchemy connection string if it is set
:param connection: get the SQLAlchemy connection string #TODO
:rtype: str
"""
if not connection:
config = configparser.ConfigParser()
cfp = defaults.config_file_path
if os.path.ex... | [
"def",
"get_connection_string",
"(",
"connection",
"=",
"None",
")",
":",
"if",
"not",
"connection",
":",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"cfp",
"=",
"defaults",
".",
"config_file_path",
"if",
"os",
".",
"path",
".",
"exists",
... | return SQLAlchemy connection string if it is set
:param connection: get the SQLAlchemy connection string #TODO
:rtype: str | [
"return",
"SQLAlchemy",
"connection",
"string",
"if",
"it",
"is",
"set"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L48-L69 |
55,806 | cebel/pyuniprot | src/pyuniprot/manager/database.py | export_obo | def export_obo(path_to_file, connection=None):
"""export database to obo file
:param path_to_file: path to export file
:param connection: connection string (optional)
:return:
"""
db = DbManager(connection)
db.export_obo(path_to_export_file=path_to_file)
db.session.close() | python | def export_obo(path_to_file, connection=None):
"""export database to obo file
:param path_to_file: path to export file
:param connection: connection string (optional)
:return:
"""
db = DbManager(connection)
db.export_obo(path_to_export_file=path_to_file)
db.session.close() | [
"def",
"export_obo",
"(",
"path_to_file",
",",
"connection",
"=",
"None",
")",
":",
"db",
"=",
"DbManager",
"(",
"connection",
")",
"db",
".",
"export_obo",
"(",
"path_to_export_file",
"=",
"path_to_file",
")",
"db",
".",
"session",
".",
"close",
"(",
")"
... | export database to obo file
:param path_to_file: path to export file
:param connection: connection string (optional)
:return: | [
"export",
"database",
"to",
"obo",
"file"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L879-L888 |
55,807 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.db_import_xml | def db_import_xml(self, url=None, force_download=False, taxids=None, silent=False):
"""Updates the CTD database
1. downloads gzipped XML
2. drops all tables in database
3. creates all tables in database
4. import XML
5. close session
:param Optional[list... | python | def db_import_xml(self, url=None, force_download=False, taxids=None, silent=False):
"""Updates the CTD database
1. downloads gzipped XML
2. drops all tables in database
3. creates all tables in database
4. import XML
5. close session
:param Optional[list... | [
"def",
"db_import_xml",
"(",
"self",
",",
"url",
"=",
"None",
",",
"force_download",
"=",
"False",
",",
"taxids",
"=",
"None",
",",
"silent",
"=",
"False",
")",
":",
"log",
".",
"info",
"(",
"'Update UniProt database from {}'",
".",
"format",
"(",
"url",
... | Updates the CTD database
1. downloads gzipped XML
2. drops all tables in database
3. creates all tables in database
4. import XML
5. close session
:param Optional[list[int]] taxids: list of NCBI taxonomy identifier
:param str url: iterable of URL strings... | [
"Updates",
"the",
"CTD",
"database",
"1",
".",
"downloads",
"gzipped",
"XML",
"2",
".",
"drops",
"all",
"tables",
"in",
"database",
"3",
".",
"creates",
"all",
"tables",
"in",
"database",
"4",
".",
"import",
"XML",
"5",
".",
"close",
"session"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L135-L156 |
55,808 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.insert_entries | def insert_entries(self, entries_xml, taxids=None):
"""Inserts UniProt entries from XML
:param str entries_xml: XML string
:param Optional[list[int]] taxids: NCBI taxonomy IDs
"""
entries = etree.fromstring(entries_xml)
del entries_xml
for entry in entries:
... | python | def insert_entries(self, entries_xml, taxids=None):
"""Inserts UniProt entries from XML
:param str entries_xml: XML string
:param Optional[list[int]] taxids: NCBI taxonomy IDs
"""
entries = etree.fromstring(entries_xml)
del entries_xml
for entry in entries:
... | [
"def",
"insert_entries",
"(",
"self",
",",
"entries_xml",
",",
"taxids",
"=",
"None",
")",
":",
"entries",
"=",
"etree",
".",
"fromstring",
"(",
"entries_xml",
")",
"del",
"entries_xml",
"for",
"entry",
"in",
"entries",
":",
"self",
".",
"insert_entry",
"(... | Inserts UniProt entries from XML
:param str entries_xml: XML string
:param Optional[list[int]] taxids: NCBI taxonomy IDs | [
"Inserts",
"UniProt",
"entries",
"from",
"XML"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L240-L258 |
55,809 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.insert_entry | def insert_entry(self, entry, taxids):
"""Insert UniProt entry"
:param entry: XML node entry
:param taxids: Optional[iter[int]] taxids: NCBI taxonomy IDs
"""
entry_dict = entry.attrib
entry_dict['created'] = datetime.strptime(entry_dict['created'], '%Y-%m-%d')
en... | python | def insert_entry(self, entry, taxids):
"""Insert UniProt entry"
:param entry: XML node entry
:param taxids: Optional[iter[int]] taxids: NCBI taxonomy IDs
"""
entry_dict = entry.attrib
entry_dict['created'] = datetime.strptime(entry_dict['created'], '%Y-%m-%d')
en... | [
"def",
"insert_entry",
"(",
"self",
",",
"entry",
",",
"taxids",
")",
":",
"entry_dict",
"=",
"entry",
".",
"attrib",
"entry_dict",
"[",
"'created'",
"]",
"=",
"datetime",
".",
"strptime",
"(",
"entry_dict",
"[",
"'created'",
"]",
",",
"'%Y-%m-%d'",
")",
... | Insert UniProt entry"
:param entry: XML node entry
:param taxids: Optional[iter[int]] taxids: NCBI taxonomy IDs | [
"Insert",
"UniProt",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L261-L278 |
55,810 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_sequence | def get_sequence(cls, entry):
"""
get models.Sequence object from XML node entry
:param entry: XML node entry
:return: :class:`pyuniprot.manager.models.Sequence` object
"""
seq_tag = entry.find("./sequence")
seq = seq_tag.text
seq_tag.clear()
retu... | python | def get_sequence(cls, entry):
"""
get models.Sequence object from XML node entry
:param entry: XML node entry
:return: :class:`pyuniprot.manager.models.Sequence` object
"""
seq_tag = entry.find("./sequence")
seq = seq_tag.text
seq_tag.clear()
retu... | [
"def",
"get_sequence",
"(",
"cls",
",",
"entry",
")",
":",
"seq_tag",
"=",
"entry",
".",
"find",
"(",
"\"./sequence\"",
")",
"seq",
"=",
"seq_tag",
".",
"text",
"seq_tag",
".",
"clear",
"(",
")",
"return",
"models",
".",
"Sequence",
"(",
"sequence",
"=... | get models.Sequence object from XML node entry
:param entry: XML node entry
:return: :class:`pyuniprot.manager.models.Sequence` object | [
"get",
"models",
".",
"Sequence",
"object",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L336-L346 |
55,811 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_tissue_in_references | def get_tissue_in_references(self, entry):
"""
get list of models.TissueInReference from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.TissueInReference` objects
"""
tissue_in_references = []
query = "./reference/so... | python | def get_tissue_in_references(self, entry):
"""
get list of models.TissueInReference from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.TissueInReference` objects
"""
tissue_in_references = []
query = "./reference/so... | [
"def",
"get_tissue_in_references",
"(",
"self",
",",
"entry",
")",
":",
"tissue_in_references",
"=",
"[",
"]",
"query",
"=",
"\"./reference/source/tissue\"",
"tissues",
"=",
"{",
"x",
".",
"text",
"for",
"x",
"in",
"entry",
".",
"iterfind",
"(",
"query",
")"... | get list of models.TissueInReference from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.TissueInReference` objects | [
"get",
"list",
"of",
"models",
".",
"TissueInReference",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L348-L365 |
55,812 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_subcellular_locations | def get_subcellular_locations(self, entry):
"""
get list of models.SubcellularLocation object from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.SubcellularLocation` object
"""
subcellular_locations = []
query = './... | python | def get_subcellular_locations(self, entry):
"""
get list of models.SubcellularLocation object from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.SubcellularLocation` object
"""
subcellular_locations = []
query = './... | [
"def",
"get_subcellular_locations",
"(",
"self",
",",
"entry",
")",
":",
"subcellular_locations",
"=",
"[",
"]",
"query",
"=",
"'./comment/subcellularLocation/location'",
"sls",
"=",
"{",
"x",
".",
"text",
"for",
"x",
"in",
"entry",
".",
"iterfind",
"(",
"quer... | get list of models.SubcellularLocation object from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.SubcellularLocation` object | [
"get",
"list",
"of",
"models",
".",
"SubcellularLocation",
"object",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L384-L401 |
55,813 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_keywords | def get_keywords(self, entry):
"""
get list of models.Keyword objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Keyword` objects
"""
keyword_objects = []
for keyword in entry.iterfind("./keyword"):
... | python | def get_keywords(self, entry):
"""
get list of models.Keyword objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Keyword` objects
"""
keyword_objects = []
for keyword in entry.iterfind("./keyword"):
... | [
"def",
"get_keywords",
"(",
"self",
",",
"entry",
")",
":",
"keyword_objects",
"=",
"[",
"]",
"for",
"keyword",
"in",
"entry",
".",
"iterfind",
"(",
"\"./keyword\"",
")",
":",
"identifier",
"=",
"keyword",
".",
"get",
"(",
"'id'",
")",
"name",
"=",
"ke... | get list of models.Keyword objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Keyword` objects | [
"get",
"list",
"of",
"models",
".",
"Keyword",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L403-L422 |
55,814 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_disease_comments | def get_disease_comments(self, entry):
"""
get list of models.Disease objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Disease` objects
"""
disease_comments = []
query = "./comment[@type='disease']"
... | python | def get_disease_comments(self, entry):
"""
get list of models.Disease objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Disease` objects
"""
disease_comments = []
query = "./comment[@type='disease']"
... | [
"def",
"get_disease_comments",
"(",
"self",
",",
"entry",
")",
":",
"disease_comments",
"=",
"[",
"]",
"query",
"=",
"\"./comment[@type='disease']\"",
"for",
"disease_comment",
"in",
"entry",
".",
"iterfind",
"(",
"query",
")",
":",
"value_dict",
"=",
"{",
"'c... | get list of models.Disease objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Disease` objects | [
"get",
"list",
"of",
"models",
".",
"Disease",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L435-L470 |
55,815 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_alternative_full_names | def get_alternative_full_names(cls, entry):
"""
get list of models.AlternativeFullName objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.AlternativeFullName` objects
"""
names = []
query = "./protein/altern... | python | def get_alternative_full_names(cls, entry):
"""
get list of models.AlternativeFullName objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.AlternativeFullName` objects
"""
names = []
query = "./protein/altern... | [
"def",
"get_alternative_full_names",
"(",
"cls",
",",
"entry",
")",
":",
"names",
"=",
"[",
"]",
"query",
"=",
"\"./protein/alternativeName/fullName\"",
"for",
"name",
"in",
"entry",
".",
"iterfind",
"(",
"query",
")",
":",
"names",
".",
"append",
"(",
"mode... | get list of models.AlternativeFullName objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.AlternativeFullName` objects | [
"get",
"list",
"of",
"models",
".",
"AlternativeFullName",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L473-L485 |
55,816 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_alternative_short_names | def get_alternative_short_names(cls, entry):
"""
get list of models.AlternativeShortName objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.AlternativeShortName` objects
"""
names = []
query = "./protein/alt... | python | def get_alternative_short_names(cls, entry):
"""
get list of models.AlternativeShortName objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.AlternativeShortName` objects
"""
names = []
query = "./protein/alt... | [
"def",
"get_alternative_short_names",
"(",
"cls",
",",
"entry",
")",
":",
"names",
"=",
"[",
"]",
"query",
"=",
"\"./protein/alternativeName/shortName\"",
"for",
"name",
"in",
"entry",
".",
"iterfind",
"(",
"query",
")",
":",
"names",
".",
"append",
"(",
"mo... | get list of models.AlternativeShortName objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.AlternativeShortName` objects | [
"get",
"list",
"of",
"models",
".",
"AlternativeShortName",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L488-L500 |
55,817 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_ec_numbers | def get_ec_numbers(cls, entry):
"""
get list of models.ECNumber objects from XML node entry
:param entry: XML node entry
:return: list of models.ECNumber objects
"""
ec_numbers = []
for ec in entry.iterfind("./protein/recommendedName/ecNumber"):
ec_... | python | def get_ec_numbers(cls, entry):
"""
get list of models.ECNumber objects from XML node entry
:param entry: XML node entry
:return: list of models.ECNumber objects
"""
ec_numbers = []
for ec in entry.iterfind("./protein/recommendedName/ecNumber"):
ec_... | [
"def",
"get_ec_numbers",
"(",
"cls",
",",
"entry",
")",
":",
"ec_numbers",
"=",
"[",
"]",
"for",
"ec",
"in",
"entry",
".",
"iterfind",
"(",
"\"./protein/recommendedName/ecNumber\"",
")",
":",
"ec_numbers",
".",
"append",
"(",
"models",
".",
"ECNumber",
"(",
... | get list of models.ECNumber objects from XML node entry
:param entry: XML node entry
:return: list of models.ECNumber objects | [
"get",
"list",
"of",
"models",
".",
"ECNumber",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L503-L514 |
55,818 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_gene_name | def get_gene_name(cls, entry):
"""
get primary gene name from XML node entry
:param entry: XML node entry
:return: str
"""
gene_name = entry.find("./gene/name[@type='primary']")
return gene_name.text if gene_name is not None and gene_name.text.strip() else None | python | def get_gene_name(cls, entry):
"""
get primary gene name from XML node entry
:param entry: XML node entry
:return: str
"""
gene_name = entry.find("./gene/name[@type='primary']")
return gene_name.text if gene_name is not None and gene_name.text.strip() else None | [
"def",
"get_gene_name",
"(",
"cls",
",",
"entry",
")",
":",
"gene_name",
"=",
"entry",
".",
"find",
"(",
"\"./gene/name[@type='primary']\"",
")",
"return",
"gene_name",
".",
"text",
"if",
"gene_name",
"is",
"not",
"None",
"and",
"gene_name",
".",
"text",
"."... | get primary gene name from XML node entry
:param entry: XML node entry
:return: str | [
"get",
"primary",
"gene",
"name",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L517-L526 |
55,819 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_other_gene_names | def get_other_gene_names(cls, entry):
"""
get list of `models.OtherGeneName` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.models.OtherGeneName` objects
"""
alternative_gene_names = []
for alternative_... | python | def get_other_gene_names(cls, entry):
"""
get list of `models.OtherGeneName` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.models.OtherGeneName` objects
"""
alternative_gene_names = []
for alternative_... | [
"def",
"get_other_gene_names",
"(",
"cls",
",",
"entry",
")",
":",
"alternative_gene_names",
"=",
"[",
"]",
"for",
"alternative_gene_name",
"in",
"entry",
".",
"iterfind",
"(",
"\"./gene/name\"",
")",
":",
"if",
"alternative_gene_name",
".",
"attrib",
"[",
"'typ... | get list of `models.OtherGeneName` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.models.OtherGeneName` objects | [
"get",
"list",
"of",
"models",
".",
"OtherGeneName",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L529-L549 |
55,820 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_accessions | def get_accessions(cls, entry):
"""
get list of models.Accession from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Accession` objects
"""
return [models.Accession(accession=x.text) for x in entry.iterfind("./accession")] | python | def get_accessions(cls, entry):
"""
get list of models.Accession from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Accession` objects
"""
return [models.Accession(accession=x.text) for x in entry.iterfind("./accession")] | [
"def",
"get_accessions",
"(",
"cls",
",",
"entry",
")",
":",
"return",
"[",
"models",
".",
"Accession",
"(",
"accession",
"=",
"x",
".",
"text",
")",
"for",
"x",
"in",
"entry",
".",
"iterfind",
"(",
"\"./accession\"",
")",
"]"
] | get list of models.Accession from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Accession` objects | [
"get",
"list",
"of",
"models",
".",
"Accession",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L552-L559 |
55,821 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_db_references | def get_db_references(cls, entry):
"""
get list of `models.DbReference` from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.DbReference`
"""
db_refs = []
for db_ref in entry.iterfind("./dbReference"):
d... | python | def get_db_references(cls, entry):
"""
get list of `models.DbReference` from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.DbReference`
"""
db_refs = []
for db_ref in entry.iterfind("./dbReference"):
d... | [
"def",
"get_db_references",
"(",
"cls",
",",
"entry",
")",
":",
"db_refs",
"=",
"[",
"]",
"for",
"db_ref",
"in",
"entry",
".",
"iterfind",
"(",
"\"./dbReference\"",
")",
":",
"db_ref_dict",
"=",
"{",
"'identifier'",
":",
"db_ref",
".",
"attrib",
"[",
"'i... | get list of `models.DbReference` from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.DbReference` | [
"get",
"list",
"of",
"models",
".",
"DbReference",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L562-L576 |
55,822 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_features | def get_features(cls, entry):
"""
get list of `models.Feature` from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Feature`
"""
features = []
for feature in entry.iterfind("./feature"):
feature_dict = {... | python | def get_features(cls, entry):
"""
get list of `models.Feature` from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Feature`
"""
features = []
for feature in entry.iterfind("./feature"):
feature_dict = {... | [
"def",
"get_features",
"(",
"cls",
",",
"entry",
")",
":",
"features",
"=",
"[",
"]",
"for",
"feature",
"in",
"entry",
".",
"iterfind",
"(",
"\"./feature\"",
")",
":",
"feature_dict",
"=",
"{",
"'description'",
":",
"feature",
".",
"attrib",
".",
"get",
... | get list of `models.Feature` from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Feature` | [
"get",
"list",
"of",
"models",
".",
"Feature",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L589-L608 |
55,823 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_recommended_protein_name | def get_recommended_protein_name(cls, entry):
"""
get recommended full and short protein name as tuple from XML node
:param entry: XML node entry
:return: (str, str) => (full, short)
"""
query_full = "./protein/recommendedName/fullName"
full_name = entry.find(que... | python | def get_recommended_protein_name(cls, entry):
"""
get recommended full and short protein name as tuple from XML node
:param entry: XML node entry
:return: (str, str) => (full, short)
"""
query_full = "./protein/recommendedName/fullName"
full_name = entry.find(que... | [
"def",
"get_recommended_protein_name",
"(",
"cls",
",",
"entry",
")",
":",
"query_full",
"=",
"\"./protein/recommendedName/fullName\"",
"full_name",
"=",
"entry",
".",
"find",
"(",
"query_full",
")",
".",
"text",
"short_name",
"=",
"None",
"query_short",
"=",
"\".... | get recommended full and short protein name as tuple from XML node
:param entry: XML node entry
:return: (str, str) => (full, short) | [
"get",
"recommended",
"full",
"and",
"short",
"protein",
"name",
"as",
"tuple",
"from",
"XML",
"node"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L621-L637 |
55,824 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_organism_hosts | def get_organism_hosts(cls, entry):
"""
get list of `models.OrganismHost` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.OrganismHost` objects
"""
query = "./organismHost/dbReference[@type='NCBI Taxonomy']"
... | python | def get_organism_hosts(cls, entry):
"""
get list of `models.OrganismHost` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.OrganismHost` objects
"""
query = "./organismHost/dbReference[@type='NCBI Taxonomy']"
... | [
"def",
"get_organism_hosts",
"(",
"cls",
",",
"entry",
")",
":",
"query",
"=",
"\"./organismHost/dbReference[@type='NCBI Taxonomy']\"",
"return",
"[",
"models",
".",
"OrganismHost",
"(",
"taxid",
"=",
"x",
".",
"get",
"(",
"'id'",
")",
")",
"for",
"x",
"in",
... | get list of `models.OrganismHost` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.OrganismHost` objects | [
"get",
"list",
"of",
"models",
".",
"OrganismHost",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L640-L649 |
55,825 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_pmids | def get_pmids(self, entry):
"""
get `models.Pmid` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Pmid` objects
"""
pmids = []
for citation in entry.iterfind("./reference/citation"):
for pub... | python | def get_pmids(self, entry):
"""
get `models.Pmid` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Pmid` objects
"""
pmids = []
for citation in entry.iterfind("./reference/citation"):
for pub... | [
"def",
"get_pmids",
"(",
"self",
",",
"entry",
")",
":",
"pmids",
"=",
"[",
"]",
"for",
"citation",
"in",
"entry",
".",
"iterfind",
"(",
"\"./reference/citation\"",
")",
":",
"for",
"pubmed_ref",
"in",
"citation",
".",
"iterfind",
"(",
"'dbReference[@type=\"... | get `models.Pmid` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Pmid` objects | [
"get",
"models",
".",
"Pmid",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L651-L694 |
55,826 | cebel/pyuniprot | src/pyuniprot/manager/database.py | DbManager.get_functions | def get_functions(cls, entry):
"""
get `models.Function` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Function` objects
"""
comments = []
query = "./comment[@type='function']"
for comment in en... | python | def get_functions(cls, entry):
"""
get `models.Function` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Function` objects
"""
comments = []
query = "./comment[@type='function']"
for comment in en... | [
"def",
"get_functions",
"(",
"cls",
",",
"entry",
")",
":",
"comments",
"=",
"[",
"]",
"query",
"=",
"\"./comment[@type='function']\"",
"for",
"comment",
"in",
"entry",
".",
"iterfind",
"(",
"query",
")",
":",
"text",
"=",
"comment",
".",
"find",
"(",
"'... | get `models.Function` objects from XML node entry
:param entry: XML node entry
:return: list of :class:`pyuniprot.manager.models.Function` objects | [
"get",
"models",
".",
"Function",
"objects",
"from",
"XML",
"node",
"entry"
] | 9462a6042c7c9295415a5eb589b77b27cb7c142b | https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/database.py#L697-L710 |
55,827 | Peter-Slump/django-dynamic-fixtures | src/dynamic_fixtures/fixtures/loader.py | Graph.resolve_nodes | def resolve_nodes(self, nodes):
"""
Resolve a given set of nodes.
Dependencies of the nodes, even if they are not in the given list will
also be resolved!
:param list nodes: List of nodes to be resolved
:return: A list of resolved nodes
"""
if not nodes:... | python | def resolve_nodes(self, nodes):
"""
Resolve a given set of nodes.
Dependencies of the nodes, even if they are not in the given list will
also be resolved!
:param list nodes: List of nodes to be resolved
:return: A list of resolved nodes
"""
if not nodes:... | [
"def",
"resolve_nodes",
"(",
"self",
",",
"nodes",
")",
":",
"if",
"not",
"nodes",
":",
"return",
"[",
"]",
"resolved",
"=",
"[",
"]",
"for",
"node",
"in",
"nodes",
":",
"if",
"node",
"in",
"resolved",
":",
"continue",
"self",
".",
"resolve_node",
"(... | Resolve a given set of nodes.
Dependencies of the nodes, even if they are not in the given list will
also be resolved!
:param list nodes: List of nodes to be resolved
:return: A list of resolved nodes | [
"Resolve",
"a",
"given",
"set",
"of",
"nodes",
"."
] | da99b4b12b11be28ea4b36b6cf2896ca449c73c1 | https://github.com/Peter-Slump/django-dynamic-fixtures/blob/da99b4b12b11be28ea4b36b6cf2896ca449c73c1/src/dynamic_fixtures/fixtures/loader.py#L117-L134 |
55,828 | Peter-Slump/django-dynamic-fixtures | src/dynamic_fixtures/fixtures/loader.py | Graph.resolve_node | def resolve_node(self, node=None, resolved=None, seen=None):
"""
Resolve a single node or all when node is omitted.
"""
if seen is None:
seen = []
if resolved is None:
resolved = []
if node is None:
dependencies = sorted(self._nodes.key... | python | def resolve_node(self, node=None, resolved=None, seen=None):
"""
Resolve a single node or all when node is omitted.
"""
if seen is None:
seen = []
if resolved is None:
resolved = []
if node is None:
dependencies = sorted(self._nodes.key... | [
"def",
"resolve_node",
"(",
"self",
",",
"node",
"=",
"None",
",",
"resolved",
"=",
"None",
",",
"seen",
"=",
"None",
")",
":",
"if",
"seen",
"is",
"None",
":",
"seen",
"=",
"[",
"]",
"if",
"resolved",
"is",
"None",
":",
"resolved",
"=",
"[",
"]"... | Resolve a single node or all when node is omitted. | [
"Resolve",
"a",
"single",
"node",
"or",
"all",
"when",
"node",
"is",
"omitted",
"."
] | da99b4b12b11be28ea4b36b6cf2896ca449c73c1 | https://github.com/Peter-Slump/django-dynamic-fixtures/blob/da99b4b12b11be28ea4b36b6cf2896ca449c73c1/src/dynamic_fixtures/fixtures/loader.py#L136-L158 |
55,829 | acorg/dark-matter | dark/orfs.py | findCodons | def findCodons(seq, codons):
"""
Find all instances of the codons in 'codons' in the given sequence.
seq: A Bio.Seq.Seq instance.
codons: A set of codon strings.
Return: a generator yielding matching codon offsets.
"""
seqLen = len(seq)
start = 0
while start < seqLen:
tripl... | python | def findCodons(seq, codons):
"""
Find all instances of the codons in 'codons' in the given sequence.
seq: A Bio.Seq.Seq instance.
codons: A set of codon strings.
Return: a generator yielding matching codon offsets.
"""
seqLen = len(seq)
start = 0
while start < seqLen:
tripl... | [
"def",
"findCodons",
"(",
"seq",
",",
"codons",
")",
":",
"seqLen",
"=",
"len",
"(",
"seq",
")",
"start",
"=",
"0",
"while",
"start",
"<",
"seqLen",
":",
"triplet",
"=",
"str",
"(",
"seq",
"[",
"start",
":",
"start",
"+",
"3",
"]",
")",
"if",
"... | Find all instances of the codons in 'codons' in the given sequence.
seq: A Bio.Seq.Seq instance.
codons: A set of codon strings.
Return: a generator yielding matching codon offsets. | [
"Find",
"all",
"instances",
"of",
"the",
"codons",
"in",
"codons",
"in",
"the",
"given",
"sequence",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/orfs.py#L7-L22 |
55,830 | acorg/dark-matter | bin/compare-sequences.py | needle | def needle(reads):
"""
Run a Needleman-Wunsch alignment and return the two sequences.
@param reads: An iterable of two reads.
@return: A C{Reads} instance with the two aligned sequences.
"""
from tempfile import mkdtemp
from shutil import rmtree
dir = mkdtemp()
file1 = join(dir, '... | python | def needle(reads):
"""
Run a Needleman-Wunsch alignment and return the two sequences.
@param reads: An iterable of two reads.
@return: A C{Reads} instance with the two aligned sequences.
"""
from tempfile import mkdtemp
from shutil import rmtree
dir = mkdtemp()
file1 = join(dir, '... | [
"def",
"needle",
"(",
"reads",
")",
":",
"from",
"tempfile",
"import",
"mkdtemp",
"from",
"shutil",
"import",
"rmtree",
"dir",
"=",
"mkdtemp",
"(",
")",
"file1",
"=",
"join",
"(",
"dir",
",",
"'file1.fasta'",
")",
"with",
"open",
"(",
"file1",
",",
"'w... | Run a Needleman-Wunsch alignment and return the two sequences.
@param reads: An iterable of two reads.
@return: A C{Reads} instance with the two aligned sequences. | [
"Run",
"a",
"Needleman",
"-",
"Wunsch",
"alignment",
"and",
"return",
"the",
"two",
"sequences",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/bin/compare-sequences.py#L18-L48 |
55,831 | vovanec/httputil | httputil/httputil.py | read_until | def read_until(stream, delimiter, max_bytes=16):
"""Read until we have found the given delimiter.
:param file stream: readable file-like object.
:param bytes delimiter: delimiter string.
:param int max_bytes: maximum bytes to read.
:rtype: bytes|None
"""
buf = bytearray()
delim_len = ... | python | def read_until(stream, delimiter, max_bytes=16):
"""Read until we have found the given delimiter.
:param file stream: readable file-like object.
:param bytes delimiter: delimiter string.
:param int max_bytes: maximum bytes to read.
:rtype: bytes|None
"""
buf = bytearray()
delim_len = ... | [
"def",
"read_until",
"(",
"stream",
",",
"delimiter",
",",
"max_bytes",
"=",
"16",
")",
":",
"buf",
"=",
"bytearray",
"(",
")",
"delim_len",
"=",
"len",
"(",
"delimiter",
")",
"while",
"len",
"(",
"buf",
")",
"<",
"max_bytes",
":",
"c",
"=",
"stream"... | Read until we have found the given delimiter.
:param file stream: readable file-like object.
:param bytes delimiter: delimiter string.
:param int max_bytes: maximum bytes to read.
:rtype: bytes|None | [
"Read",
"until",
"we",
"have",
"found",
"the",
"given",
"delimiter",
"."
] | 0b8dab5a23166cceb7dbc2a1dbc802ab5b311347 | https://github.com/vovanec/httputil/blob/0b8dab5a23166cceb7dbc2a1dbc802ab5b311347/httputil/httputil.py#L94-L115 |
55,832 | vovanec/httputil | httputil/httputil.py | dechunk | def dechunk(stream):
"""De-chunk HTTP body stream.
:param file stream: readable file-like object.
:rtype: __generator[bytes]
:raise: DechunkError
"""
# TODO(vovan): Add support for chunk extensions:
# TODO(vovan): http://tools.ietf.org/html/rfc2616#section-3.6.1
while True:
c... | python | def dechunk(stream):
"""De-chunk HTTP body stream.
:param file stream: readable file-like object.
:rtype: __generator[bytes]
:raise: DechunkError
"""
# TODO(vovan): Add support for chunk extensions:
# TODO(vovan): http://tools.ietf.org/html/rfc2616#section-3.6.1
while True:
c... | [
"def",
"dechunk",
"(",
"stream",
")",
":",
"# TODO(vovan): Add support for chunk extensions:",
"# TODO(vovan): http://tools.ietf.org/html/rfc2616#section-3.6.1",
"while",
"True",
":",
"chunk_len",
"=",
"read_until",
"(",
"stream",
",",
"b'\\r\\n'",
")",
"if",
"chunk_len",
"... | De-chunk HTTP body stream.
:param file stream: readable file-like object.
:rtype: __generator[bytes]
:raise: DechunkError | [
"De",
"-",
"chunk",
"HTTP",
"body",
"stream",
"."
] | 0b8dab5a23166cceb7dbc2a1dbc802ab5b311347 | https://github.com/vovanec/httputil/blob/0b8dab5a23166cceb7dbc2a1dbc802ab5b311347/httputil/httputil.py#L118-L154 |
55,833 | vovanec/httputil | httputil/httputil.py | to_chunks | def to_chunks(stream_or_generator):
"""This generator function receives file-like or generator as input
and returns generator.
:param file|__generator[bytes] stream_or_generator: readable stream or
generator.
:rtype: __generator[bytes]
:raise: TypeError
"""
if isinstance(strea... | python | def to_chunks(stream_or_generator):
"""This generator function receives file-like or generator as input
and returns generator.
:param file|__generator[bytes] stream_or_generator: readable stream or
generator.
:rtype: __generator[bytes]
:raise: TypeError
"""
if isinstance(strea... | [
"def",
"to_chunks",
"(",
"stream_or_generator",
")",
":",
"if",
"isinstance",
"(",
"stream_or_generator",
",",
"types",
".",
"GeneratorType",
")",
":",
"yield",
"from",
"stream_or_generator",
"elif",
"hasattr",
"(",
"stream_or_generator",
",",
"'read'",
")",
":",
... | This generator function receives file-like or generator as input
and returns generator.
:param file|__generator[bytes] stream_or_generator: readable stream or
generator.
:rtype: __generator[bytes]
:raise: TypeError | [
"This",
"generator",
"function",
"receives",
"file",
"-",
"like",
"or",
"generator",
"as",
"input",
"and",
"returns",
"generator",
"."
] | 0b8dab5a23166cceb7dbc2a1dbc802ab5b311347 | https://github.com/vovanec/httputil/blob/0b8dab5a23166cceb7dbc2a1dbc802ab5b311347/httputil/httputil.py#L157-L180 |
55,834 | vovanec/httputil | httputil/httputil.py | read_body_stream | def read_body_stream(stream, chunked=False, compression=None):
"""Read HTTP body stream, yielding blocks of bytes. De-chunk and
de-compress data if needed.
:param file stream: readable stream.
:param bool chunked: whether stream is chunked.
:param str|None compression: compression type is stream is... | python | def read_body_stream(stream, chunked=False, compression=None):
"""Read HTTP body stream, yielding blocks of bytes. De-chunk and
de-compress data if needed.
:param file stream: readable stream.
:param bool chunked: whether stream is chunked.
:param str|None compression: compression type is stream is... | [
"def",
"read_body_stream",
"(",
"stream",
",",
"chunked",
"=",
"False",
",",
"compression",
"=",
"None",
")",
":",
"if",
"not",
"(",
"chunked",
"or",
"compression",
")",
":",
"return",
"to_chunks",
"(",
"stream",
")",
"generator",
"=",
"stream",
"if",
"c... | Read HTTP body stream, yielding blocks of bytes. De-chunk and
de-compress data if needed.
:param file stream: readable stream.
:param bool chunked: whether stream is chunked.
:param str|None compression: compression type is stream is
compressed, otherwise None.
:rtype: __generator[bytes... | [
"Read",
"HTTP",
"body",
"stream",
"yielding",
"blocks",
"of",
"bytes",
".",
"De",
"-",
"chunk",
"and",
"de",
"-",
"compress",
"data",
"if",
"needed",
"."
] | 0b8dab5a23166cceb7dbc2a1dbc802ab5b311347 | https://github.com/vovanec/httputil/blob/0b8dab5a23166cceb7dbc2a1dbc802ab5b311347/httputil/httputil.py#L215-L238 |
55,835 | vovanec/httputil | httputil/httputil.py | DeflateDecompressor.decompress | def decompress(self, chunk):
"""Decompress the chunk of data.
:param bytes chunk: data chunk
:rtype: bytes
"""
try:
return self._decompressobj.decompress(chunk)
except zlib.error:
# ugly hack to work with raw deflate content that may
... | python | def decompress(self, chunk):
"""Decompress the chunk of data.
:param bytes chunk: data chunk
:rtype: bytes
"""
try:
return self._decompressobj.decompress(chunk)
except zlib.error:
# ugly hack to work with raw deflate content that may
... | [
"def",
"decompress",
"(",
"self",
",",
"chunk",
")",
":",
"try",
":",
"return",
"self",
".",
"_decompressobj",
".",
"decompress",
"(",
"chunk",
")",
"except",
"zlib",
".",
"error",
":",
"# ugly hack to work with raw deflate content that may",
"# be sent by microsoft... | Decompress the chunk of data.
:param bytes chunk: data chunk
:rtype: bytes | [
"Decompress",
"the",
"chunk",
"of",
"data",
"."
] | 0b8dab5a23166cceb7dbc2a1dbc802ab5b311347 | https://github.com/vovanec/httputil/blob/0b8dab5a23166cceb7dbc2a1dbc802ab5b311347/httputil/httputil.py#L31-L53 |
55,836 | acorg/dark-matter | bin/compare-consensuses.py | makeOuputDir | def makeOuputDir(outputDir, force):
"""
Create or check for an output directory.
@param outputDir: A C{str} output directory name, or C{None}.
@param force: If C{True}, allow overwriting of pre-existing files.
@return: The C{str} output directory name.
"""
if outputDir:
if exists(ou... | python | def makeOuputDir(outputDir, force):
"""
Create or check for an output directory.
@param outputDir: A C{str} output directory name, or C{None}.
@param force: If C{True}, allow overwriting of pre-existing files.
@return: The C{str} output directory name.
"""
if outputDir:
if exists(ou... | [
"def",
"makeOuputDir",
"(",
"outputDir",
",",
"force",
")",
":",
"if",
"outputDir",
":",
"if",
"exists",
"(",
"outputDir",
")",
":",
"if",
"not",
"force",
":",
"print",
"(",
"'Will not overwrite pre-existing files. Use --force to '",
"'make me.'",
",",
"file",
"... | Create or check for an output directory.
@param outputDir: A C{str} output directory name, or C{None}.
@param force: If C{True}, allow overwriting of pre-existing files.
@return: The C{str} output directory name. | [
"Create",
"or",
"check",
"for",
"an",
"output",
"directory",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/bin/compare-consensuses.py#L14-L34 |
55,837 | acorg/dark-matter | bin/compare-consensuses.py | samtoolsMpileup | def samtoolsMpileup(outFile, referenceFile, alignmentFile, executor):
"""
Use samtools mpileup to generate VCF.
@param outFile: The C{str} name to write the output to.
@param referenceFile: The C{str} name of the FASTA file with the reference
sequence.
@param alignmentFile: The C{str} name ... | python | def samtoolsMpileup(outFile, referenceFile, alignmentFile, executor):
"""
Use samtools mpileup to generate VCF.
@param outFile: The C{str} name to write the output to.
@param referenceFile: The C{str} name of the FASTA file with the reference
sequence.
@param alignmentFile: The C{str} name ... | [
"def",
"samtoolsMpileup",
"(",
"outFile",
",",
"referenceFile",
",",
"alignmentFile",
",",
"executor",
")",
":",
"executor",
".",
"execute",
"(",
"'samtools mpileup -u -v -f %s %s > %s'",
"%",
"(",
"referenceFile",
",",
"alignmentFile",
",",
"outFile",
")",
")"
] | Use samtools mpileup to generate VCF.
@param outFile: The C{str} name to write the output to.
@param referenceFile: The C{str} name of the FASTA file with the reference
sequence.
@param alignmentFile: The C{str} name of the SAM or BAM alignment file.
@param executor: An C{Executor} instance. | [
"Use",
"samtools",
"mpileup",
"to",
"generate",
"VCF",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/bin/compare-consensuses.py#L37-L49 |
55,838 | acorg/dark-matter | bin/compare-consensuses.py | bcftoolsMpileup | def bcftoolsMpileup(outFile, referenceFile, alignmentFile, executor):
"""
Use bcftools mpileup to generate VCF.
@param outFile: The C{str} name to write the output to.
@param referenceFile: The C{str} name of the FASTA file with the reference
sequence.
@param alignmentFile: The C{str} name ... | python | def bcftoolsMpileup(outFile, referenceFile, alignmentFile, executor):
"""
Use bcftools mpileup to generate VCF.
@param outFile: The C{str} name to write the output to.
@param referenceFile: The C{str} name of the FASTA file with the reference
sequence.
@param alignmentFile: The C{str} name ... | [
"def",
"bcftoolsMpileup",
"(",
"outFile",
",",
"referenceFile",
",",
"alignmentFile",
",",
"executor",
")",
":",
"executor",
".",
"execute",
"(",
"'bcftools mpileup -Ov -f %s %s > %s'",
"%",
"(",
"referenceFile",
",",
"alignmentFile",
",",
"outFile",
")",
")"
] | Use bcftools mpileup to generate VCF.
@param outFile: The C{str} name to write the output to.
@param referenceFile: The C{str} name of the FASTA file with the reference
sequence.
@param alignmentFile: The C{str} name of the SAM or BAM alignment file.
@param executor: An C{Executor} instance. | [
"Use",
"bcftools",
"mpileup",
"to",
"generate",
"VCF",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/bin/compare-consensuses.py#L52-L64 |
55,839 | acorg/dark-matter | bin/compare-consensuses.py | bcftoolsConsensus | def bcftoolsConsensus(outFile, vcfFile, id_, referenceFile, executor):
"""
Use bcftools to extract consensus FASTA.
@param outFile: The C{str} name to write the output to.
@param vcfFile: The C{str} name of the VCF file with the calls from
the pileup.
@param id_: The C{str} identifier to us... | python | def bcftoolsConsensus(outFile, vcfFile, id_, referenceFile, executor):
"""
Use bcftools to extract consensus FASTA.
@param outFile: The C{str} name to write the output to.
@param vcfFile: The C{str} name of the VCF file with the calls from
the pileup.
@param id_: The C{str} identifier to us... | [
"def",
"bcftoolsConsensus",
"(",
"outFile",
",",
"vcfFile",
",",
"id_",
",",
"referenceFile",
",",
"executor",
")",
":",
"bgz",
"=",
"vcfFile",
"+",
"'.gz'",
"executor",
".",
"execute",
"(",
"'bgzip -c %s > %s'",
"%",
"(",
"vcfFile",
",",
"bgz",
")",
")",
... | Use bcftools to extract consensus FASTA.
@param outFile: The C{str} name to write the output to.
@param vcfFile: The C{str} name of the VCF file with the calls from
the pileup.
@param id_: The C{str} identifier to use in the resulting FASTA sequence.
@param referenceFile: The C{str} name of the... | [
"Use",
"bcftools",
"to",
"extract",
"consensus",
"FASTA",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/bin/compare-consensuses.py#L95-L113 |
55,840 | acorg/dark-matter | bin/compare-consensuses.py | vcfutilsConsensus | def vcfutilsConsensus(outFile, vcfFile, id_, _, executor):
"""
Use vcftools to extract consensus FASTA.
@param outFile: The C{str} name to write the output to.
@param vcfFile: The C{str} name of the VCF file with the calls from
the pileup.
@param id_: The C{str} identifier to use in the res... | python | def vcfutilsConsensus(outFile, vcfFile, id_, _, executor):
"""
Use vcftools to extract consensus FASTA.
@param outFile: The C{str} name to write the output to.
@param vcfFile: The C{str} name of the VCF file with the calls from
the pileup.
@param id_: The C{str} identifier to use in the res... | [
"def",
"vcfutilsConsensus",
"(",
"outFile",
",",
"vcfFile",
",",
"id_",
",",
"_",
",",
"executor",
")",
":",
"executor",
".",
"execute",
"(",
"'vcfutils.pl vcf2fq < %s | '",
"'filter-fasta.py --fastq --quiet --saveAs fasta '",
"'--idLambda \\'lambda id: \"%s\"\\' > %s'",
"%... | Use vcftools to extract consensus FASTA.
@param outFile: The C{str} name to write the output to.
@param vcfFile: The C{str} name of the VCF file with the calls from
the pileup.
@param id_: The C{str} identifier to use in the resulting FASTA sequence.
@param executor: An C{Executor} instance. | [
"Use",
"vcftools",
"to",
"extract",
"consensus",
"FASTA",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/bin/compare-consensuses.py#L116-L130 |
55,841 | openfisca/openfisca-web-api | openfisca_web_api/contexts.py | Ctx.translator | def translator(self):
"""Get a valid translator object from one or several languages names."""
if self._translator is None:
languages = self.lang
if not languages:
return gettext.NullTranslations()
if not isinstance(languages, list):
la... | python | def translator(self):
"""Get a valid translator object from one or several languages names."""
if self._translator is None:
languages = self.lang
if not languages:
return gettext.NullTranslations()
if not isinstance(languages, list):
la... | [
"def",
"translator",
"(",
"self",
")",
":",
"if",
"self",
".",
"_translator",
"is",
"None",
":",
"languages",
"=",
"self",
".",
"lang",
"if",
"not",
"languages",
":",
"return",
"gettext",
".",
"NullTranslations",
"(",
")",
"if",
"not",
"isinstance",
"(",... | Get a valid translator object from one or several languages names. | [
"Get",
"a",
"valid",
"translator",
"object",
"from",
"one",
"or",
"several",
"languages",
"names",
"."
] | d1cd3bfacac338e80bb0df7e0465b65649dd893b | https://github.com/openfisca/openfisca-web-api/blob/d1cd3bfacac338e80bb0df7e0465b65649dd893b/openfisca_web_api/contexts.py#L141-L165 |
55,842 | acorg/dark-matter | dark/taxonomy.py | LineageFetcher.lineage | def lineage(self, title):
"""
Get lineage information from the taxonomy database for a given title.
@param title: A C{str} sequence title (e.g., from a BLAST hit). Of the
form 'gi|63148399|gb|DQ011818.1| Description...'. It is the gi
number (63148399 in this example) tha... | python | def lineage(self, title):
"""
Get lineage information from the taxonomy database for a given title.
@param title: A C{str} sequence title (e.g., from a BLAST hit). Of the
form 'gi|63148399|gb|DQ011818.1| Description...'. It is the gi
number (63148399 in this example) tha... | [
"def",
"lineage",
"(",
"self",
",",
"title",
")",
":",
"if",
"title",
"in",
"self",
".",
"_cache",
":",
"return",
"self",
".",
"_cache",
"[",
"title",
"]",
"lineage",
"=",
"[",
"]",
"gi",
"=",
"int",
"(",
"title",
".",
"split",
"(",
"'|'",
")",
... | Get lineage information from the taxonomy database for a given title.
@param title: A C{str} sequence title (e.g., from a BLAST hit). Of the
form 'gi|63148399|gb|DQ011818.1| Description...'. It is the gi
number (63148399 in this example) that is looked up in the taxonomy
dat... | [
"Get",
"lineage",
"information",
"from",
"the",
"taxonomy",
"database",
"for",
"a",
"given",
"title",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/taxonomy.py#L14-L53 |
55,843 | acorg/dark-matter | dark/taxonomy.py | LineageFetcher.close | def close(self):
"""
Close the database connection and render self invalid. Any subsequent
re-use of self will raise an error.
"""
self._cursor.close()
self._db.close()
self._cursor = self._db = self._cache = None | python | def close(self):
"""
Close the database connection and render self invalid. Any subsequent
re-use of self will raise an error.
"""
self._cursor.close()
self._db.close()
self._cursor = self._db = self._cache = None | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_cursor",
".",
"close",
"(",
")",
"self",
".",
"_db",
".",
"close",
"(",
")",
"self",
".",
"_cursor",
"=",
"self",
".",
"_db",
"=",
"self",
".",
"_cache",
"=",
"None"
] | Close the database connection and render self invalid. Any subsequent
re-use of self will raise an error. | [
"Close",
"the",
"database",
"connection",
"and",
"render",
"self",
"invalid",
".",
"Any",
"subsequent",
"re",
"-",
"use",
"of",
"self",
"will",
"raise",
"an",
"error",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/taxonomy.py#L55-L62 |
55,844 | invenia/Arbiter | arbiter/utils.py | retry_handler | def retry_handler(retries=0, delay=timedelta(), conditions=[]):
"""
A simple wrapper function that creates a handler function by using
on the retry_loop function.
Args:
retries (Integral): The number of times to retry if a failure occurs.
delay (timedelta, optional, 0 seconds): A timede... | python | def retry_handler(retries=0, delay=timedelta(), conditions=[]):
"""
A simple wrapper function that creates a handler function by using
on the retry_loop function.
Args:
retries (Integral): The number of times to retry if a failure occurs.
delay (timedelta, optional, 0 seconds): A timede... | [
"def",
"retry_handler",
"(",
"retries",
"=",
"0",
",",
"delay",
"=",
"timedelta",
"(",
")",
",",
"conditions",
"=",
"[",
"]",
")",
":",
"delay_in_seconds",
"=",
"delay",
".",
"total_seconds",
"(",
")",
"return",
"partial",
"(",
"retry_loop",
",",
"retrie... | A simple wrapper function that creates a handler function by using
on the retry_loop function.
Args:
retries (Integral): The number of times to retry if a failure occurs.
delay (timedelta, optional, 0 seconds): A timedelta representing
the amount time to delay between retries.
... | [
"A",
"simple",
"wrapper",
"function",
"that",
"creates",
"a",
"handler",
"function",
"by",
"using",
"on",
"the",
"retry_loop",
"function",
"."
] | 51008393ae8797da85bcd67807259a157f941dfd | https://github.com/invenia/Arbiter/blob/51008393ae8797da85bcd67807259a157f941dfd/arbiter/utils.py#L57-L71 |
55,845 | invenia/Arbiter | arbiter/utils.py | retry | def retry(retries=0, delay=timedelta(), conditions=[]):
"""
A decorator for making a function that retries on failure.
Args:
retries (Integral): The number of times to retry if a failure occurs.
delay (timedelta, optional, 0 seconds): A timedelta representing
the amount of time ... | python | def retry(retries=0, delay=timedelta(), conditions=[]):
"""
A decorator for making a function that retries on failure.
Args:
retries (Integral): The number of times to retry if a failure occurs.
delay (timedelta, optional, 0 seconds): A timedelta representing
the amount of time ... | [
"def",
"retry",
"(",
"retries",
"=",
"0",
",",
"delay",
"=",
"timedelta",
"(",
")",
",",
"conditions",
"=",
"[",
"]",
")",
":",
"delay_in_seconds",
"=",
"delay",
".",
"total_seconds",
"(",
")",
"def",
"decorator",
"(",
"function",
")",
":",
"\"\"\"\n ... | A decorator for making a function that retries on failure.
Args:
retries (Integral): The number of times to retry if a failure occurs.
delay (timedelta, optional, 0 seconds): A timedelta representing
the amount of time to delay between retries.
conditions (list): A list of retry... | [
"A",
"decorator",
"for",
"making",
"a",
"function",
"that",
"retries",
"on",
"failure",
"."
] | 51008393ae8797da85bcd67807259a157f941dfd | https://github.com/invenia/Arbiter/blob/51008393ae8797da85bcd67807259a157f941dfd/arbiter/utils.py#L74-L100 |
55,846 | invenia/Arbiter | arbiter/utils.py | retry_loop | def retry_loop(retries, delay_in_seconds, conditions, function):
"""
Actually performs the retry loop used by the retry decorator
and handler functions. Failures for retrying are defined by
the RetryConditions passed in. If the maximum number of
retries has been reached then it raises the most recen... | python | def retry_loop(retries, delay_in_seconds, conditions, function):
"""
Actually performs the retry loop used by the retry decorator
and handler functions. Failures for retrying are defined by
the RetryConditions passed in. If the maximum number of
retries has been reached then it raises the most recen... | [
"def",
"retry_loop",
"(",
"retries",
",",
"delay_in_seconds",
",",
"conditions",
",",
"function",
")",
":",
"if",
"not",
"isinstance",
"(",
"retries",
",",
"Integral",
")",
":",
"raise",
"TypeError",
"(",
"retries",
")",
"if",
"delay_in_seconds",
"<",
"0",
... | Actually performs the retry loop used by the retry decorator
and handler functions. Failures for retrying are defined by
the RetryConditions passed in. If the maximum number of
retries has been reached then it raises the most recent
error or a ValueError on the most recent result value.
Args:
... | [
"Actually",
"performs",
"the",
"retry",
"loop",
"used",
"by",
"the",
"retry",
"decorator",
"and",
"handler",
"functions",
".",
"Failures",
"for",
"retrying",
"are",
"defined",
"by",
"the",
"RetryConditions",
"passed",
"in",
".",
"If",
"the",
"maximum",
"number... | 51008393ae8797da85bcd67807259a157f941dfd | https://github.com/invenia/Arbiter/blob/51008393ae8797da85bcd67807259a157f941dfd/arbiter/utils.py#L103-L158 |
55,847 | acorg/dark-matter | dark/diamond/conversion.py | DiamondTabularFormatReader.saveAsJSON | def saveAsJSON(self, fp, writeBytes=False):
"""
Write the records out as JSON. The first JSON object saved contains
information about the DIAMOND algorithm.
@param fp: A C{str} file pointer to write to.
@param writeBytes: If C{True}, the JSON will be written out as bytes
... | python | def saveAsJSON(self, fp, writeBytes=False):
"""
Write the records out as JSON. The first JSON object saved contains
information about the DIAMOND algorithm.
@param fp: A C{str} file pointer to write to.
@param writeBytes: If C{True}, the JSON will be written out as bytes
... | [
"def",
"saveAsJSON",
"(",
"self",
",",
"fp",
",",
"writeBytes",
"=",
"False",
")",
":",
"if",
"writeBytes",
":",
"fp",
".",
"write",
"(",
"dumps",
"(",
"self",
".",
"params",
",",
"sort_keys",
"=",
"True",
")",
".",
"encode",
"(",
"'UTF-8'",
")",
"... | Write the records out as JSON. The first JSON object saved contains
information about the DIAMOND algorithm.
@param fp: A C{str} file pointer to write to.
@param writeBytes: If C{True}, the JSON will be written out as bytes
(not strings). This is required when we are writing to a BZ... | [
"Write",
"the",
"records",
"out",
"as",
"JSON",
".",
"The",
"first",
"JSON",
"object",
"saved",
"contains",
"information",
"about",
"the",
"DIAMOND",
"algorithm",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/diamond/conversion.py#L229-L249 |
55,848 | closeio/cleancat | cleancat/sqla.py | object_as_dict | def object_as_dict(obj):
"""Turn an SQLAlchemy model into a dict of field names and values.
Based on https://stackoverflow.com/a/37350445/1579058
"""
return {c.key: getattr(obj, c.key)
for c in inspect(obj).mapper.column_attrs} | python | def object_as_dict(obj):
"""Turn an SQLAlchemy model into a dict of field names and values.
Based on https://stackoverflow.com/a/37350445/1579058
"""
return {c.key: getattr(obj, c.key)
for c in inspect(obj).mapper.column_attrs} | [
"def",
"object_as_dict",
"(",
"obj",
")",
":",
"return",
"{",
"c",
".",
"key",
":",
"getattr",
"(",
"obj",
",",
"c",
".",
"key",
")",
"for",
"c",
"in",
"inspect",
"(",
"obj",
")",
".",
"mapper",
".",
"column_attrs",
"}"
] | Turn an SQLAlchemy model into a dict of field names and values.
Based on https://stackoverflow.com/a/37350445/1579058 | [
"Turn",
"an",
"SQLAlchemy",
"model",
"into",
"a",
"dict",
"of",
"field",
"names",
"and",
"values",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/sqla.py#L12-L18 |
55,849 | closeio/cleancat | cleancat/sqla.py | SQLAReference.fetch_object | def fetch_object(self, model_id):
"""Fetch the model by its ID."""
pk_field_instance = getattr(self.object_class, self.pk_field)
qs = self.object_class.query.filter(pk_field_instance == model_id)
model = qs.one_or_none()
if not model:
raise ReferenceNotFoundError
... | python | def fetch_object(self, model_id):
"""Fetch the model by its ID."""
pk_field_instance = getattr(self.object_class, self.pk_field)
qs = self.object_class.query.filter(pk_field_instance == model_id)
model = qs.one_or_none()
if not model:
raise ReferenceNotFoundError
... | [
"def",
"fetch_object",
"(",
"self",
",",
"model_id",
")",
":",
"pk_field_instance",
"=",
"getattr",
"(",
"self",
".",
"object_class",
",",
"self",
".",
"pk_field",
")",
"qs",
"=",
"self",
".",
"object_class",
".",
"query",
".",
"filter",
"(",
"pk_field_ins... | Fetch the model by its ID. | [
"Fetch",
"the",
"model",
"by",
"its",
"ID",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/sqla.py#L54-L61 |
55,850 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | init_ixe | def init_ixe(logger, host, port=4555, rsa_id=None):
""" Connect to Tcl Server and Create IxExplorer object.
:param logger: python logger object
:param host: host (IxTclServer) IP address
:param port: Tcl Server port
:param rsa_id: full path to RSA ID file for Linux based IxVM
:return: IXE objec... | python | def init_ixe(logger, host, port=4555, rsa_id=None):
""" Connect to Tcl Server and Create IxExplorer object.
:param logger: python logger object
:param host: host (IxTclServer) IP address
:param port: Tcl Server port
:param rsa_id: full path to RSA ID file for Linux based IxVM
:return: IXE objec... | [
"def",
"init_ixe",
"(",
"logger",
",",
"host",
",",
"port",
"=",
"4555",
",",
"rsa_id",
"=",
"None",
")",
":",
"return",
"IxeApp",
"(",
"logger",
",",
"IxTclHalApi",
"(",
"TclClient",
"(",
"logger",
",",
"host",
",",
"port",
",",
"rsa_id",
")",
")",
... | Connect to Tcl Server and Create IxExplorer object.
:param logger: python logger object
:param host: host (IxTclServer) IP address
:param port: Tcl Server port
:param rsa_id: full path to RSA ID file for Linux based IxVM
:return: IXE object | [
"Connect",
"to",
"Tcl",
"Server",
"and",
"Create",
"IxExplorer",
"object",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L17-L27 |
55,851 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | IxeApp.connect | def connect(self, user=None):
""" Connect to host.
:param user: if user - login session.
"""
self.api._tcl_handler.connect()
if user:
self.session.login(user) | python | def connect(self, user=None):
""" Connect to host.
:param user: if user - login session.
"""
self.api._tcl_handler.connect()
if user:
self.session.login(user) | [
"def",
"connect",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"self",
".",
"api",
".",
"_tcl_handler",
".",
"connect",
"(",
")",
"if",
"user",
":",
"self",
".",
"session",
".",
"login",
"(",
"user",
")"
] | Connect to host.
:param user: if user - login session. | [
"Connect",
"to",
"host",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L42-L50 |
55,852 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | IxeApp.add | def add(self, chassis):
""" add chassis.
:param chassis: chassis IP address.
"""
self.chassis_chain[chassis] = IxeChassis(self.session, chassis, len(self.chassis_chain) + 1)
self.chassis_chain[chassis].connect() | python | def add(self, chassis):
""" add chassis.
:param chassis: chassis IP address.
"""
self.chassis_chain[chassis] = IxeChassis(self.session, chassis, len(self.chassis_chain) + 1)
self.chassis_chain[chassis].connect() | [
"def",
"add",
"(",
"self",
",",
"chassis",
")",
":",
"self",
".",
"chassis_chain",
"[",
"chassis",
"]",
"=",
"IxeChassis",
"(",
"self",
".",
"session",
",",
"chassis",
",",
"len",
"(",
"self",
".",
"chassis_chain",
")",
"+",
"1",
")",
"self",
".",
... | add chassis.
:param chassis: chassis IP address. | [
"add",
"chassis",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L58-L65 |
55,853 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | IxeSession.wait_for_up | def wait_for_up(self, timeout=16, ports=None):
""" Wait until ports reach up state.
:param timeout: seconds to wait.
:param ports: list of ports to wait for.
:return:
"""
port_list = []
for port in ports:
port_list.append(self.set_ports_list(port))
... | python | def wait_for_up(self, timeout=16, ports=None):
""" Wait until ports reach up state.
:param timeout: seconds to wait.
:param ports: list of ports to wait for.
:return:
"""
port_list = []
for port in ports:
port_list.append(self.set_ports_list(port))
... | [
"def",
"wait_for_up",
"(",
"self",
",",
"timeout",
"=",
"16",
",",
"ports",
"=",
"None",
")",
":",
"port_list",
"=",
"[",
"]",
"for",
"port",
"in",
"ports",
":",
"port_list",
".",
"append",
"(",
"self",
".",
"set_ports_list",
"(",
"port",
")",
")",
... | Wait until ports reach up state.
:param timeout: seconds to wait.
:param ports: list of ports to wait for.
:return: | [
"Wait",
"until",
"ports",
"reach",
"up",
"state",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L116-L144 |
55,854 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | IxeSession.start_transmit | def start_transmit(self, blocking=False, start_packet_groups=True, *ports):
""" Start transmit on ports.
:param blocking: True - wait for traffic end, False - return after traffic start.
:param start_packet_groups: True - clear time stamps and start collecting packet groups stats, False - don't... | python | def start_transmit(self, blocking=False, start_packet_groups=True, *ports):
""" Start transmit on ports.
:param blocking: True - wait for traffic end, False - return after traffic start.
:param start_packet_groups: True - clear time stamps and start collecting packet groups stats, False - don't... | [
"def",
"start_transmit",
"(",
"self",
",",
"blocking",
"=",
"False",
",",
"start_packet_groups",
"=",
"True",
",",
"*",
"ports",
")",
":",
"port_list",
"=",
"self",
".",
"set_ports_list",
"(",
"*",
"ports",
")",
"if",
"start_packet_groups",
":",
"port_list_f... | Start transmit on ports.
:param blocking: True - wait for traffic end, False - return after traffic start.
:param start_packet_groups: True - clear time stamps and start collecting packet groups stats, False - don't.
:param ports: list of ports to start traffic on, if empty start on all ports. | [
"Start",
"transmit",
"on",
"ports",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L156-L174 |
55,855 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | IxeSession.start_packet_groups | def start_packet_groups(self, clear_time_stamps=True, *ports):
""" Start packet groups on ports.
:param clear_time_stamps: True - clear time stamps, False - don't.
:param ports: list of ports to start traffic on, if empty start on all ports.
"""
port_list = self.set_ports_list(*... | python | def start_packet_groups(self, clear_time_stamps=True, *ports):
""" Start packet groups on ports.
:param clear_time_stamps: True - clear time stamps, False - don't.
:param ports: list of ports to start traffic on, if empty start on all ports.
"""
port_list = self.set_ports_list(*... | [
"def",
"start_packet_groups",
"(",
"self",
",",
"clear_time_stamps",
"=",
"True",
",",
"*",
"ports",
")",
":",
"port_list",
"=",
"self",
".",
"set_ports_list",
"(",
"*",
"ports",
")",
"if",
"clear_time_stamps",
":",
"self",
".",
"api",
".",
"call_rc",
"(",... | Start packet groups on ports.
:param clear_time_stamps: True - clear time stamps, False - don't.
:param ports: list of ports to start traffic on, if empty start on all ports. | [
"Start",
"packet",
"groups",
"on",
"ports",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L176-L185 |
55,856 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | IxeSession.stop_transmit | def stop_transmit(self, *ports):
""" Stop traffic on ports.
:param ports: list of ports to stop traffic on, if empty start on all ports.
"""
port_list = self.set_ports_list(*ports)
self.api.call_rc('ixStopTransmit {}'.format(port_list))
time.sleep(0.2) | python | def stop_transmit(self, *ports):
""" Stop traffic on ports.
:param ports: list of ports to stop traffic on, if empty start on all ports.
"""
port_list = self.set_ports_list(*ports)
self.api.call_rc('ixStopTransmit {}'.format(port_list))
time.sleep(0.2) | [
"def",
"stop_transmit",
"(",
"self",
",",
"*",
"ports",
")",
":",
"port_list",
"=",
"self",
".",
"set_ports_list",
"(",
"*",
"ports",
")",
"self",
".",
"api",
".",
"call_rc",
"(",
"'ixStopTransmit {}'",
".",
"format",
"(",
"port_list",
")",
")",
"time",
... | Stop traffic on ports.
:param ports: list of ports to stop traffic on, if empty start on all ports. | [
"Stop",
"traffic",
"on",
"ports",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L187-L195 |
55,857 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | IxeSession.wait_transmit | def wait_transmit(self, *ports):
""" Wait for traffic end on ports.
:param ports: list of ports to wait for, if empty wait for all ports.
"""
port_list = self.set_ports_list(*ports)
self.api.call_rc('ixCheckTransmitDone {}'.format(port_list)) | python | def wait_transmit(self, *ports):
""" Wait for traffic end on ports.
:param ports: list of ports to wait for, if empty wait for all ports.
"""
port_list = self.set_ports_list(*ports)
self.api.call_rc('ixCheckTransmitDone {}'.format(port_list)) | [
"def",
"wait_transmit",
"(",
"self",
",",
"*",
"ports",
")",
":",
"port_list",
"=",
"self",
".",
"set_ports_list",
"(",
"*",
"ports",
")",
"self",
".",
"api",
".",
"call_rc",
"(",
"'ixCheckTransmitDone {}'",
".",
"format",
"(",
"port_list",
")",
")"
] | Wait for traffic end on ports.
:param ports: list of ports to wait for, if empty wait for all ports. | [
"Wait",
"for",
"traffic",
"end",
"on",
"ports",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L197-L204 |
55,858 | shmir/PyIxExplorer | ixexplorer/ixe_app.py | IxeSession.start_capture | def start_capture(self, *ports):
""" Start capture on ports.
:param ports: list of ports to start capture on, if empty start on all ports.
"""
IxeCapture.current_object = None
IxeCaptureBuffer.current_object = None
if not ports:
ports = self.ports.values()
... | python | def start_capture(self, *ports):
""" Start capture on ports.
:param ports: list of ports to start capture on, if empty start on all ports.
"""
IxeCapture.current_object = None
IxeCaptureBuffer.current_object = None
if not ports:
ports = self.ports.values()
... | [
"def",
"start_capture",
"(",
"self",
",",
"*",
"ports",
")",
":",
"IxeCapture",
".",
"current_object",
"=",
"None",
"IxeCaptureBuffer",
".",
"current_object",
"=",
"None",
"if",
"not",
"ports",
":",
"ports",
"=",
"self",
".",
"ports",
".",
"values",
"(",
... | Start capture on ports.
:param ports: list of ports to start capture on, if empty start on all ports. | [
"Start",
"capture",
"on",
"ports",
"."
] | d6946b9ce0e8961507cc912062e10c365d4beee2 | https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L206-L219 |
55,859 | biocommons/bioutils | src/bioutils/accessions.py | chr22XY | def chr22XY(c):
"""force to name from 1..22, 23, 24, X, Y, M
to in chr1..chr22, chrX, chrY, chrM
str or ints accepted
>>> chr22XY('1')
'chr1'
>>> chr22XY(1)
'chr1'
>>> chr22XY('chr1')
'chr1'
>>> chr22XY(23)
'chrX'
>>> chr22XY(24)
'chrY'
>>> chr22XY("X")
'chr... | python | def chr22XY(c):
"""force to name from 1..22, 23, 24, X, Y, M
to in chr1..chr22, chrX, chrY, chrM
str or ints accepted
>>> chr22XY('1')
'chr1'
>>> chr22XY(1)
'chr1'
>>> chr22XY('chr1')
'chr1'
>>> chr22XY(23)
'chrX'
>>> chr22XY(24)
'chrY'
>>> chr22XY("X")
'chr... | [
"def",
"chr22XY",
"(",
"c",
")",
":",
"c",
"=",
"str",
"(",
"c",
")",
"if",
"c",
"[",
"0",
":",
"3",
"]",
"==",
"'chr'",
":",
"c",
"=",
"c",
"[",
"3",
":",
"]",
"if",
"c",
"==",
"'23'",
":",
"c",
"=",
"'X'",
"if",
"c",
"==",
"'24'",
"... | force to name from 1..22, 23, 24, X, Y, M
to in chr1..chr22, chrX, chrY, chrM
str or ints accepted
>>> chr22XY('1')
'chr1'
>>> chr22XY(1)
'chr1'
>>> chr22XY('chr1')
'chr1'
>>> chr22XY(23)
'chrX'
>>> chr22XY(24)
'chrY'
>>> chr22XY("X")
'chrX'
>>> chr22XY("23"... | [
"force",
"to",
"name",
"from",
"1",
"..",
"22",
"23",
"24",
"X",
"Y",
"M",
"to",
"in",
"chr1",
"..",
"chr22",
"chrX",
"chrY",
"chrM",
"str",
"or",
"ints",
"accepted"
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/accessions.py#L81-L111 |
55,860 | biocommons/bioutils | src/bioutils/accessions.py | infer_namespace | def infer_namespace(ac):
"""Infer the single namespace of the given accession
This function is convenience wrapper around infer_namespaces().
Returns:
* None if no namespaces are inferred
* The (single) namespace if only one namespace is inferred
* Raises an exception if more than one nam... | python | def infer_namespace(ac):
"""Infer the single namespace of the given accession
This function is convenience wrapper around infer_namespaces().
Returns:
* None if no namespaces are inferred
* The (single) namespace if only one namespace is inferred
* Raises an exception if more than one nam... | [
"def",
"infer_namespace",
"(",
"ac",
")",
":",
"namespaces",
"=",
"infer_namespaces",
"(",
"ac",
")",
"if",
"not",
"namespaces",
":",
"return",
"None",
"if",
"len",
"(",
"namespaces",
")",
">",
"1",
":",
"raise",
"BioutilsError",
"(",
"\"Multiple namespaces ... | Infer the single namespace of the given accession
This function is convenience wrapper around infer_namespaces().
Returns:
* None if no namespaces are inferred
* The (single) namespace if only one namespace is inferred
* Raises an exception if more than one namespace is inferred
>>> infe... | [
"Infer",
"the",
"single",
"namespace",
"of",
"the",
"given",
"accession"
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/accessions.py#L114-L149 |
55,861 | biocommons/bioutils | src/bioutils/accessions.py | infer_namespaces | def infer_namespaces(ac):
"""infer possible namespaces of given accession based on syntax
Always returns a list, possibly empty
>>> infer_namespaces("ENST00000530893.6")
['ensembl']
>>> infer_namespaces("ENST00000530893")
['ensembl']
>>> infer_namespaces("ENSQ00000530893")
[]
>>> in... | python | def infer_namespaces(ac):
"""infer possible namespaces of given accession based on syntax
Always returns a list, possibly empty
>>> infer_namespaces("ENST00000530893.6")
['ensembl']
>>> infer_namespaces("ENST00000530893")
['ensembl']
>>> infer_namespaces("ENSQ00000530893")
[]
>>> in... | [
"def",
"infer_namespaces",
"(",
"ac",
")",
":",
"return",
"[",
"v",
"for",
"k",
",",
"v",
"in",
"ac_namespace_regexps",
".",
"items",
"(",
")",
"if",
"k",
".",
"match",
"(",
"ac",
")",
"]"
] | infer possible namespaces of given accession based on syntax
Always returns a list, possibly empty
>>> infer_namespaces("ENST00000530893.6")
['ensembl']
>>> infer_namespaces("ENST00000530893")
['ensembl']
>>> infer_namespaces("ENSQ00000530893")
[]
>>> infer_namespaces("NM_01234")
['... | [
"infer",
"possible",
"namespaces",
"of",
"given",
"accession",
"based",
"on",
"syntax",
"Always",
"returns",
"a",
"list",
"possibly",
"empty"
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/accessions.py#L152-L177 |
55,862 | intiocean/pyinter | pyinter/interval_set.py | IntervalSet.add | def add(self, other):
"""
Add an Interval to the IntervalSet by taking the union of the given Interval object with the existing
Interval objects in self.
This has no effect if the Interval is already represented.
:param other: an Interval to add to this IntervalSet.
"""
... | python | def add(self, other):
"""
Add an Interval to the IntervalSet by taking the union of the given Interval object with the existing
Interval objects in self.
This has no effect if the Interval is already represented.
:param other: an Interval to add to this IntervalSet.
"""
... | [
"def",
"add",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
".",
"empty",
"(",
")",
":",
"return",
"to_add",
"=",
"set",
"(",
")",
"for",
"inter",
"in",
"self",
":",
"if",
"inter",
".",
"overlaps",
"(",
"other",
")",
":",
"# if it overlaps wi... | Add an Interval to the IntervalSet by taking the union of the given Interval object with the existing
Interval objects in self.
This has no effect if the Interval is already represented.
:param other: an Interval to add to this IntervalSet. | [
"Add",
"an",
"Interval",
"to",
"the",
"IntervalSet",
"by",
"taking",
"the",
"union",
"of",
"the",
"given",
"Interval",
"object",
"with",
"the",
"existing",
"Interval",
"objects",
"in",
"self",
"."
] | fb6e904307477fa43123cc9ab326680aa1a8cd62 | https://github.com/intiocean/pyinter/blob/fb6e904307477fa43123cc9ab326680aa1a8cd62/pyinter/interval_set.py#L84-L107 |
55,863 | intiocean/pyinter | pyinter/interval_set.py | IntervalSet.difference | def difference(self, other):
"""
Subtract an Interval or IntervalSet from the intervals in the set.
"""
intervals = other if isinstance(other, IntervalSet) else IntervalSet((other,))
result = IntervalSet()
for left in self:
for right in intervals:
... | python | def difference(self, other):
"""
Subtract an Interval or IntervalSet from the intervals in the set.
"""
intervals = other if isinstance(other, IntervalSet) else IntervalSet((other,))
result = IntervalSet()
for left in self:
for right in intervals:
... | [
"def",
"difference",
"(",
"self",
",",
"other",
")",
":",
"intervals",
"=",
"other",
"if",
"isinstance",
"(",
"other",
",",
"IntervalSet",
")",
"else",
"IntervalSet",
"(",
"(",
"other",
",",
")",
")",
"result",
"=",
"IntervalSet",
"(",
")",
"for",
"lef... | Subtract an Interval or IntervalSet from the intervals in the set. | [
"Subtract",
"an",
"Interval",
"or",
"IntervalSet",
"from",
"the",
"intervals",
"in",
"the",
"set",
"."
] | fb6e904307477fa43123cc9ab326680aa1a8cd62 | https://github.com/intiocean/pyinter/blob/fb6e904307477fa43123cc9ab326680aa1a8cd62/pyinter/interval_set.py#L112-L126 |
55,864 | pebble/libpebble2 | libpebble2/services/notifications.py | Notifications.send_notification | def send_notification(self, subject="", message="", sender="", source=None, actions=None):
"""
Sends a notification. Blocks as long as necessary.
:param subject: The subject.
:type subject: str
:param message: The message.
:type message: str
:param sender: The se... | python | def send_notification(self, subject="", message="", sender="", source=None, actions=None):
"""
Sends a notification. Blocks as long as necessary.
:param subject: The subject.
:type subject: str
:param message: The message.
:type message: str
:param sender: The se... | [
"def",
"send_notification",
"(",
"self",
",",
"subject",
"=",
"\"\"",
",",
"message",
"=",
"\"\"",
",",
"sender",
"=",
"\"\"",
",",
"source",
"=",
"None",
",",
"actions",
"=",
"None",
")",
":",
"if",
"self",
".",
"_pebble",
".",
"firmware_version",
"."... | Sends a notification. Blocks as long as necessary.
:param subject: The subject.
:type subject: str
:param message: The message.
:type message: str
:param sender: The sender.
:type sender: str
:param source: The source of the notification
:type source: .Le... | [
"Sends",
"a",
"notification",
".",
"Blocks",
"as",
"long",
"as",
"necessary",
"."
] | 23e2eb92cfc084e6f9e8c718711ac994ef606d18 | https://github.com/pebble/libpebble2/blob/23e2eb92cfc084e6f9e8c718711ac994ef606d18/libpebble2/services/notifications.py#L33-L51 |
55,865 | agusmakmun/djipsum | djipsum/fields.py | DjipsumFields.randomBinaryField | def randomBinaryField(self):
"""
Return random bytes format.
"""
lst = [
b"hello world",
b"this is bytes",
b"awesome django",
b"djipsum is awesome",
b"\x00\x01\x02\x03\x04\x05\x06\x07",
b"\x0b\x0c\x0e\x0f"
]
... | python | def randomBinaryField(self):
"""
Return random bytes format.
"""
lst = [
b"hello world",
b"this is bytes",
b"awesome django",
b"djipsum is awesome",
b"\x00\x01\x02\x03\x04\x05\x06\x07",
b"\x0b\x0c\x0e\x0f"
]
... | [
"def",
"randomBinaryField",
"(",
"self",
")",
":",
"lst",
"=",
"[",
"b\"hello world\"",
",",
"b\"this is bytes\"",
",",
"b\"awesome django\"",
",",
"b\"djipsum is awesome\"",
",",
"b\"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\"",
",",
"b\"\\x0b\\x0c\\x0e\\x0f\"",
"]",
"retur... | Return random bytes format. | [
"Return",
"random",
"bytes",
"format",
"."
] | e7950556422b4039092db2083db7a83728230977 | https://github.com/agusmakmun/djipsum/blob/e7950556422b4039092db2083db7a83728230977/djipsum/fields.py#L27-L39 |
55,866 | agusmakmun/djipsum | djipsum/fields.py | DjipsumFields.randomUUIDField | def randomUUIDField(self):
"""
Return the unique uuid from uuid1, uuid3, uuid4, or uuid5.
"""
uuid1 = uuid.uuid1().hex
uuid3 = uuid.uuid3(
uuid.NAMESPACE_URL,
self.randomize(['python', 'django', 'awesome'])
).hex
uuid4 = uuid.uuid4().hex
... | python | def randomUUIDField(self):
"""
Return the unique uuid from uuid1, uuid3, uuid4, or uuid5.
"""
uuid1 = uuid.uuid1().hex
uuid3 = uuid.uuid3(
uuid.NAMESPACE_URL,
self.randomize(['python', 'django', 'awesome'])
).hex
uuid4 = uuid.uuid4().hex
... | [
"def",
"randomUUIDField",
"(",
"self",
")",
":",
"uuid1",
"=",
"uuid",
".",
"uuid1",
"(",
")",
".",
"hex",
"uuid3",
"=",
"uuid",
".",
"uuid3",
"(",
"uuid",
".",
"NAMESPACE_URL",
",",
"self",
".",
"randomize",
"(",
"[",
"'python'",
",",
"'django'",
",... | Return the unique uuid from uuid1, uuid3, uuid4, or uuid5. | [
"Return",
"the",
"unique",
"uuid",
"from",
"uuid1",
"uuid3",
"uuid4",
"or",
"uuid5",
"."
] | e7950556422b4039092db2083db7a83728230977 | https://github.com/agusmakmun/djipsum/blob/e7950556422b4039092db2083db7a83728230977/djipsum/fields.py#L226-L240 |
55,867 | alpha-xone/xone | xone/utils.py | trade_day | def trade_day(dt, cal='US'):
"""
Latest trading day w.r.t given dt
Args:
dt: date of reference
cal: trading calendar
Returns:
pd.Timestamp: last trading day
Examples:
>>> trade_day('2018-12-25').strftime('%Y-%m-%d')
'2018-12-24'
"""
from xone import... | python | def trade_day(dt, cal='US'):
"""
Latest trading day w.r.t given dt
Args:
dt: date of reference
cal: trading calendar
Returns:
pd.Timestamp: last trading day
Examples:
>>> trade_day('2018-12-25').strftime('%Y-%m-%d')
'2018-12-24'
"""
from xone import... | [
"def",
"trade_day",
"(",
"dt",
",",
"cal",
"=",
"'US'",
")",
":",
"from",
"xone",
"import",
"calendar",
"dt",
"=",
"pd",
".",
"Timestamp",
"(",
"dt",
")",
".",
"date",
"(",
")",
"return",
"calendar",
".",
"trading_dates",
"(",
"start",
"=",
"dt",
"... | Latest trading day w.r.t given dt
Args:
dt: date of reference
cal: trading calendar
Returns:
pd.Timestamp: last trading day
Examples:
>>> trade_day('2018-12-25').strftime('%Y-%m-%d')
'2018-12-24' | [
"Latest",
"trading",
"day",
"w",
".",
"r",
".",
"t",
"given",
"dt"
] | 68534a30f7f1760b220ba58040be3927f7dfbcf4 | https://github.com/alpha-xone/xone/blob/68534a30f7f1760b220ba58040be3927f7dfbcf4/xone/utils.py#L52-L70 |
55,868 | alpha-xone/xone | xone/utils.py | align_data | def align_data(*args):
"""
Resample and aligh data for defined frequency
Args:
*args: DataFrame of data to be aligned
Returns:
pd.DataFrame: aligned data with renamed columns
Examples:
>>> start = '2018-09-10T10:10:00'
>>> tz = 'Australia/Sydney'
>>> idx = ... | python | def align_data(*args):
"""
Resample and aligh data for defined frequency
Args:
*args: DataFrame of data to be aligned
Returns:
pd.DataFrame: aligned data with renamed columns
Examples:
>>> start = '2018-09-10T10:10:00'
>>> tz = 'Australia/Sydney'
>>> idx = ... | [
"def",
"align_data",
"(",
"*",
"args",
")",
":",
"res",
"=",
"pd",
".",
"DataFrame",
"(",
"pd",
".",
"concat",
"(",
"[",
"d",
".",
"loc",
"[",
"~",
"d",
".",
"index",
".",
"duplicated",
"(",
"keep",
"=",
"'first'",
")",
"]",
".",
"rename",
"(",... | Resample and aligh data for defined frequency
Args:
*args: DataFrame of data to be aligned
Returns:
pd.DataFrame: aligned data with renamed columns
Examples:
>>> start = '2018-09-10T10:10:00'
>>> tz = 'Australia/Sydney'
>>> idx = pd.date_range(start=start, periods=... | [
"Resample",
"and",
"aligh",
"data",
"for",
"defined",
"frequency"
] | 68534a30f7f1760b220ba58040be3927f7dfbcf4 | https://github.com/alpha-xone/xone/blob/68534a30f7f1760b220ba58040be3927f7dfbcf4/xone/utils.py#L114-L167 |
55,869 | alpha-xone/xone | xone/utils.py | cat_data | def cat_data(data_kw):
"""
Concatenate data with ticker as sub column index
Args:
data_kw: key = ticker, value = pd.DataFrame
Returns:
pd.DataFrame
Examples:
>>> start = '2018-09-10T10:10:00'
>>> tz = 'Australia/Sydney'
>>> idx = pd.date_range(start=start, ... | python | def cat_data(data_kw):
"""
Concatenate data with ticker as sub column index
Args:
data_kw: key = ticker, value = pd.DataFrame
Returns:
pd.DataFrame
Examples:
>>> start = '2018-09-10T10:10:00'
>>> tz = 'Australia/Sydney'
>>> idx = pd.date_range(start=start, ... | [
"def",
"cat_data",
"(",
"data_kw",
")",
":",
"if",
"len",
"(",
"data_kw",
")",
"==",
"0",
":",
"return",
"pd",
".",
"DataFrame",
"(",
")",
"return",
"pd",
".",
"DataFrame",
"(",
"pd",
".",
"concat",
"(",
"[",
"data",
".",
"assign",
"(",
"ticker",
... | Concatenate data with ticker as sub column index
Args:
data_kw: key = ticker, value = pd.DataFrame
Returns:
pd.DataFrame
Examples:
>>> start = '2018-09-10T10:10:00'
>>> tz = 'Australia/Sydney'
>>> idx = pd.date_range(start=start, periods=6, freq='min').tz_localize(... | [
"Concatenate",
"data",
"with",
"ticker",
"as",
"sub",
"column",
"index"
] | 68534a30f7f1760b220ba58040be3927f7dfbcf4 | https://github.com/alpha-xone/xone/blob/68534a30f7f1760b220ba58040be3927f7dfbcf4/xone/utils.py#L170-L209 |
55,870 | alpha-xone/xone | xone/utils.py | to_frame | def to_frame(data_list, exc_cols=None, **kwargs):
"""
Dict in Python 3.6 keeps insertion order, but cannot be relied upon
This method is to keep column names in order
In Python 3.7 this method is redundant
Args:
data_list: list of dict
exc_cols: exclude columns
Returns:
... | python | def to_frame(data_list, exc_cols=None, **kwargs):
"""
Dict in Python 3.6 keeps insertion order, but cannot be relied upon
This method is to keep column names in order
In Python 3.7 this method is redundant
Args:
data_list: list of dict
exc_cols: exclude columns
Returns:
... | [
"def",
"to_frame",
"(",
"data_list",
",",
"exc_cols",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"collections",
"import",
"OrderedDict",
"return",
"pd",
".",
"DataFrame",
"(",
"pd",
".",
"Series",
"(",
"data_list",
")",
".",
"apply",
"(",
... | Dict in Python 3.6 keeps insertion order, but cannot be relied upon
This method is to keep column names in order
In Python 3.7 this method is redundant
Args:
data_list: list of dict
exc_cols: exclude columns
Returns:
pd.DataFrame
Example:
>>> d_list = [
...... | [
"Dict",
"in",
"Python",
"3",
".",
"6",
"keeps",
"insertion",
"order",
"but",
"cannot",
"be",
"relied",
"upon",
"This",
"method",
"is",
"to",
"keep",
"column",
"names",
"in",
"order",
"In",
"Python",
"3",
".",
"7",
"this",
"method",
"is",
"redundant"
] | 68534a30f7f1760b220ba58040be3927f7dfbcf4 | https://github.com/alpha-xone/xone/blob/68534a30f7f1760b220ba58040be3927f7dfbcf4/xone/utils.py#L262-L293 |
55,871 | alpha-xone/xone | xone/utils.py | spline_curve | def spline_curve(x, y, step, val_min=0, val_max=None, kind='quadratic', **kwargs):
"""
Fit spline curve for given x, y values
Args:
x: x-values
y: y-values
step: step size for interpolation
val_min: minimum value of result
val_max: maximum value of result
kin... | python | def spline_curve(x, y, step, val_min=0, val_max=None, kind='quadratic', **kwargs):
"""
Fit spline curve for given x, y values
Args:
x: x-values
y: y-values
step: step size for interpolation
val_min: minimum value of result
val_max: maximum value of result
kin... | [
"def",
"spline_curve",
"(",
"x",
",",
"y",
",",
"step",
",",
"val_min",
"=",
"0",
",",
"val_max",
"=",
"None",
",",
"kind",
"=",
"'quadratic'",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"scipy",
".",
"interpolate",
"import",
"interp1d",
"from",
"col... | Fit spline curve for given x, y values
Args:
x: x-values
y: y-values
step: step size for interpolation
val_min: minimum value of result
val_max: maximum value of result
kind: for scipy.interpolate.interp1d
Specifies the kind of interpolation as a string (‘lin... | [
"Fit",
"spline",
"curve",
"for",
"given",
"x",
"y",
"values"
] | 68534a30f7f1760b220ba58040be3927f7dfbcf4 | https://github.com/alpha-xone/xone/blob/68534a30f7f1760b220ba58040be3927f7dfbcf4/xone/utils.py#L296-L346 |
55,872 | alpha-xone/xone | xone/utils.py | format_float | def format_float(digit=0, is_pct=False):
"""
Number display format for pandas
Args:
digit: number of digits to keep
if negative, add one space in front of positive pct
is_pct: % display
Returns:
lambda function to format floats
Examples:
>>> format_f... | python | def format_float(digit=0, is_pct=False):
"""
Number display format for pandas
Args:
digit: number of digits to keep
if negative, add one space in front of positive pct
is_pct: % display
Returns:
lambda function to format floats
Examples:
>>> format_f... | [
"def",
"format_float",
"(",
"digit",
"=",
"0",
",",
"is_pct",
"=",
"False",
")",
":",
"if",
"is_pct",
":",
"space",
"=",
"' '",
"if",
"digit",
"<",
"0",
"else",
"''",
"fmt",
"=",
"f'{{:{space}.{abs(int(digit))}%}}'",
"return",
"lambda",
"vv",
":",
"'NaN'... | Number display format for pandas
Args:
digit: number of digits to keep
if negative, add one space in front of positive pct
is_pct: % display
Returns:
lambda function to format floats
Examples:
>>> format_float(0)(1e5)
'100,000'
>>> format_flo... | [
"Number",
"display",
"format",
"for",
"pandas"
] | 68534a30f7f1760b220ba58040be3927f7dfbcf4 | https://github.com/alpha-xone/xone/blob/68534a30f7f1760b220ba58040be3927f7dfbcf4/xone/utils.py#L369-L400 |
55,873 | tkf/rash | rash/utils/sqlconstructor.py | SQLConstructor.join | def join(self, source, op='LEFT JOIN', on=''):
"""
Join `source`.
>>> sc = SQLConstructor('main', ['c1', 'c2'])
>>> sc.join('sub', 'JOIN', 'main.id = sub.id')
>>> (sql, params, keys) = sc.compile()
>>> sql
'SELECT c1, c2 FROM main JOIN sub ON main.id = sub.id'
... | python | def join(self, source, op='LEFT JOIN', on=''):
"""
Join `source`.
>>> sc = SQLConstructor('main', ['c1', 'c2'])
>>> sc.join('sub', 'JOIN', 'main.id = sub.id')
>>> (sql, params, keys) = sc.compile()
>>> sql
'SELECT c1, c2 FROM main JOIN sub ON main.id = sub.id'
... | [
"def",
"join",
"(",
"self",
",",
"source",
",",
"op",
"=",
"'LEFT JOIN'",
",",
"on",
"=",
"''",
")",
":",
"if",
"isinstance",
"(",
"source",
",",
"SQLConstructor",
")",
":",
"(",
"sql",
",",
"params",
",",
"_",
")",
"=",
"source",
".",
"compile",
... | Join `source`.
>>> sc = SQLConstructor('main', ['c1', 'c2'])
>>> sc.join('sub', 'JOIN', 'main.id = sub.id')
>>> (sql, params, keys) = sc.compile()
>>> sql
'SELECT c1, c2 FROM main JOIN sub ON main.id = sub.id'
It is possible to pass another `SQLConstructor` as a source.... | [
"Join",
"source",
"."
] | 585da418ec37dd138f1a4277718b6f507e9536a2 | https://github.com/tkf/rash/blob/585da418ec37dd138f1a4277718b6f507e9536a2/rash/utils/sqlconstructor.py#L84-L139 |
55,874 | tkf/rash | rash/utils/sqlconstructor.py | SQLConstructor.add_and_matches | def add_and_matches(self, matcher, lhs, params, numq=1, flatten=None):
"""
Add AND conditions to match to `params`.
:type matcher: str or callable
:arg matcher: if `str`, `matcher.format` is used.
:type lhs: str
:arg lhs: the first argument to `matcher`.
... | python | def add_and_matches(self, matcher, lhs, params, numq=1, flatten=None):
"""
Add AND conditions to match to `params`.
:type matcher: str or callable
:arg matcher: if `str`, `matcher.format` is used.
:type lhs: str
:arg lhs: the first argument to `matcher`.
... | [
"def",
"add_and_matches",
"(",
"self",
",",
"matcher",
",",
"lhs",
",",
"params",
",",
"numq",
"=",
"1",
",",
"flatten",
"=",
"None",
")",
":",
"params",
"=",
"self",
".",
"_adapt_params",
"(",
"params",
")",
"qs",
"=",
"[",
"'?'",
"]",
"*",
"numq"... | Add AND conditions to match to `params`.
:type matcher: str or callable
:arg matcher: if `str`, `matcher.format` is used.
:type lhs: str
:arg lhs: the first argument to `matcher`.
:type params: list
:arg params: each element should be able to feed into sqlit... | [
"Add",
"AND",
"conditions",
"to",
"match",
"to",
"params",
"."
] | 585da418ec37dd138f1a4277718b6f507e9536a2 | https://github.com/tkf/rash/blob/585da418ec37dd138f1a4277718b6f507e9536a2/rash/utils/sqlconstructor.py#L208-L230 |
55,875 | tkf/rash | rash/utils/sqlconstructor.py | SQLConstructor.add_matches | def add_matches(self, matcher, lhs,
match_params=[], include_params=[], exclude_params=[],
numq=1, flatten=None):
"""
Quick way to call `add_or_matches` and `add_and_matches`.
"""
matcher = adapt_matcher(matcher)
notmatcher = negate(matcher... | python | def add_matches(self, matcher, lhs,
match_params=[], include_params=[], exclude_params=[],
numq=1, flatten=None):
"""
Quick way to call `add_or_matches` and `add_and_matches`.
"""
matcher = adapt_matcher(matcher)
notmatcher = negate(matcher... | [
"def",
"add_matches",
"(",
"self",
",",
"matcher",
",",
"lhs",
",",
"match_params",
"=",
"[",
"]",
",",
"include_params",
"=",
"[",
"]",
",",
"exclude_params",
"=",
"[",
"]",
",",
"numq",
"=",
"1",
",",
"flatten",
"=",
"None",
")",
":",
"matcher",
... | Quick way to call `add_or_matches` and `add_and_matches`. | [
"Quick",
"way",
"to",
"call",
"add_or_matches",
"and",
"add_and_matches",
"."
] | 585da418ec37dd138f1a4277718b6f507e9536a2 | https://github.com/tkf/rash/blob/585da418ec37dd138f1a4277718b6f507e9536a2/rash/utils/sqlconstructor.py#L243-L253 |
55,876 | tkf/rash | rash/utils/sqlconstructor.py | SQLConstructor.uniquify_by | def uniquify_by(self, column, chooser=None, aggregate='MAX'):
"""
Group by `column` and run `aggregate` function on `chooser` column.
"""
self.group_by.append(column)
if chooser:
i = self.columns.index(chooser)
self.columns[i] = '{0}({1})'.format(aggregate... | python | def uniquify_by(self, column, chooser=None, aggregate='MAX'):
"""
Group by `column` and run `aggregate` function on `chooser` column.
"""
self.group_by.append(column)
if chooser:
i = self.columns.index(chooser)
self.columns[i] = '{0}({1})'.format(aggregate... | [
"def",
"uniquify_by",
"(",
"self",
",",
"column",
",",
"chooser",
"=",
"None",
",",
"aggregate",
"=",
"'MAX'",
")",
":",
"self",
".",
"group_by",
".",
"append",
"(",
"column",
")",
"if",
"chooser",
":",
"i",
"=",
"self",
".",
"columns",
".",
"index",... | Group by `column` and run `aggregate` function on `chooser` column. | [
"Group",
"by",
"column",
"and",
"run",
"aggregate",
"function",
"on",
"chooser",
"column",
"."
] | 585da418ec37dd138f1a4277718b6f507e9536a2 | https://github.com/tkf/rash/blob/585da418ec37dd138f1a4277718b6f507e9536a2/rash/utils/sqlconstructor.py#L255-L262 |
55,877 | tkf/rash | rash/utils/sqlconstructor.py | SQLConstructor.move_where_clause_to_column | def move_where_clause_to_column(self, column='condition', key=None):
"""
Move whole WHERE clause to a column named `column`.
"""
if self.conditions:
expr = " AND ".join(self.conditions)
params = self.params
self.params = []
self.conditions ... | python | def move_where_clause_to_column(self, column='condition', key=None):
"""
Move whole WHERE clause to a column named `column`.
"""
if self.conditions:
expr = " AND ".join(self.conditions)
params = self.params
self.params = []
self.conditions ... | [
"def",
"move_where_clause_to_column",
"(",
"self",
",",
"column",
"=",
"'condition'",
",",
"key",
"=",
"None",
")",
":",
"if",
"self",
".",
"conditions",
":",
"expr",
"=",
"\" AND \"",
".",
"join",
"(",
"self",
".",
"conditions",
")",
"params",
"=",
"sel... | Move whole WHERE clause to a column named `column`. | [
"Move",
"whole",
"WHERE",
"clause",
"to",
"a",
"column",
"named",
"column",
"."
] | 585da418ec37dd138f1a4277718b6f507e9536a2 | https://github.com/tkf/rash/blob/585da418ec37dd138f1a4277718b6f507e9536a2/rash/utils/sqlconstructor.py#L275-L289 |
55,878 | INM-6/hybridLFPy | examples/example_plotting.py | remove_axis_junk | def remove_axis_junk(ax, which=['right', 'top']):
'''remove upper and right axis'''
for loc, spine in ax.spines.items():
if loc in which:
spine.set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left') | python | def remove_axis_junk(ax, which=['right', 'top']):
'''remove upper and right axis'''
for loc, spine in ax.spines.items():
if loc in which:
spine.set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left') | [
"def",
"remove_axis_junk",
"(",
"ax",
",",
"which",
"=",
"[",
"'right'",
",",
"'top'",
"]",
")",
":",
"for",
"loc",
",",
"spine",
"in",
"ax",
".",
"spines",
".",
"items",
"(",
")",
":",
"if",
"loc",
"in",
"which",
":",
"spine",
".",
"set_color",
... | remove upper and right axis | [
"remove",
"upper",
"and",
"right",
"axis"
] | c38bdf38982c4624c2f70caeb50c40f1d5980abd | https://github.com/INM-6/hybridLFPy/blob/c38bdf38982c4624c2f70caeb50c40f1d5980abd/examples/example_plotting.py#L13-L19 |
55,879 | INM-6/hybridLFPy | examples/example_plotting.py | normalize | def normalize(x):
'''normalize x to have mean 0 and unity standard deviation'''
x = x.astype(float)
x -= x.mean()
return x / float(x.std()) | python | def normalize(x):
'''normalize x to have mean 0 and unity standard deviation'''
x = x.astype(float)
x -= x.mean()
return x / float(x.std()) | [
"def",
"normalize",
"(",
"x",
")",
":",
"x",
"=",
"x",
".",
"astype",
"(",
"float",
")",
"x",
"-=",
"x",
".",
"mean",
"(",
")",
"return",
"x",
"/",
"float",
"(",
"x",
".",
"std",
"(",
")",
")"
] | normalize x to have mean 0 and unity standard deviation | [
"normalize",
"x",
"to",
"have",
"mean",
"0",
"and",
"unity",
"standard",
"deviation"
] | c38bdf38982c4624c2f70caeb50c40f1d5980abd | https://github.com/INM-6/hybridLFPy/blob/c38bdf38982c4624c2f70caeb50c40f1d5980abd/examples/example_plotting.py#L324-L328 |
55,880 | tkf/rash | rash/indexer.py | Indexer.find_record_files | def find_record_files(self):
"""
Yield paths to record files.
"""
for (root, _, files) in os.walk(self.record_path):
for f in (f for f in files if f.endswith('.json')):
yield os.path.join(root, f) | python | def find_record_files(self):
"""
Yield paths to record files.
"""
for (root, _, files) in os.walk(self.record_path):
for f in (f for f in files if f.endswith('.json')):
yield os.path.join(root, f) | [
"def",
"find_record_files",
"(",
"self",
")",
":",
"for",
"(",
"root",
",",
"_",
",",
"files",
")",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"record_path",
")",
":",
"for",
"f",
"in",
"(",
"f",
"for",
"f",
"in",
"files",
"if",
"f",
".",
"ends... | Yield paths to record files. | [
"Yield",
"paths",
"to",
"record",
"files",
"."
] | 585da418ec37dd138f1a4277718b6f507e9536a2 | https://github.com/tkf/rash/blob/585da418ec37dd138f1a4277718b6f507e9536a2/rash/indexer.py#L109-L115 |
55,881 | pebble/libpebble2 | libpebble2/protocol/base/types.py | Field.buffer_to_value | def buffer_to_value(self, obj, buffer, offset, default_endianness=DEFAULT_ENDIANNESS):
"""
Converts the bytes in ``buffer`` at ``offset`` to a native Python value. Returns that value and the number of
bytes consumed to create it.
:param obj: The parent :class:`.PebblePacket` of this fie... | python | def buffer_to_value(self, obj, buffer, offset, default_endianness=DEFAULT_ENDIANNESS):
"""
Converts the bytes in ``buffer`` at ``offset`` to a native Python value. Returns that value and the number of
bytes consumed to create it.
:param obj: The parent :class:`.PebblePacket` of this fie... | [
"def",
"buffer_to_value",
"(",
"self",
",",
"obj",
",",
"buffer",
",",
"offset",
",",
"default_endianness",
"=",
"DEFAULT_ENDIANNESS",
")",
":",
"try",
":",
"value",
",",
"length",
"=",
"struct",
".",
"unpack_from",
"(",
"str",
"(",
"self",
".",
"endiannes... | Converts the bytes in ``buffer`` at ``offset`` to a native Python value. Returns that value and the number of
bytes consumed to create it.
:param obj: The parent :class:`.PebblePacket` of this field
:type obj: .PebblePacket
:param buffer: The buffer from which to extract a value.
... | [
"Converts",
"the",
"bytes",
"in",
"buffer",
"at",
"offset",
"to",
"a",
"native",
"Python",
"value",
".",
"Returns",
"that",
"value",
"and",
"the",
"number",
"of",
"bytes",
"consumed",
"to",
"create",
"it",
"."
] | 23e2eb92cfc084e6f9e8c718711ac994ef606d18 | https://github.com/pebble/libpebble2/blob/23e2eb92cfc084e6f9e8c718711ac994ef606d18/libpebble2/protocol/base/types.py#L43-L71 |
55,882 | pebble/libpebble2 | libpebble2/protocol/base/types.py | Field.value_to_bytes | def value_to_bytes(self, obj, value, default_endianness=DEFAULT_ENDIANNESS):
"""
Converts the given value to an appropriately encoded string of bytes that represents it.
:param obj: The parent :class:`.PebblePacket` of this field
:type obj: .PebblePacket
:param value: The python... | python | def value_to_bytes(self, obj, value, default_endianness=DEFAULT_ENDIANNESS):
"""
Converts the given value to an appropriately encoded string of bytes that represents it.
:param obj: The parent :class:`.PebblePacket` of this field
:type obj: .PebblePacket
:param value: The python... | [
"def",
"value_to_bytes",
"(",
"self",
",",
"obj",
",",
"value",
",",
"default_endianness",
"=",
"DEFAULT_ENDIANNESS",
")",
":",
"return",
"struct",
".",
"pack",
"(",
"str",
"(",
"self",
".",
"endianness",
"or",
"default_endianness",
")",
"+",
"self",
".",
... | Converts the given value to an appropriately encoded string of bytes that represents it.
:param obj: The parent :class:`.PebblePacket` of this field
:type obj: .PebblePacket
:param value: The python value to serialise.
:param default_endianness: The default endianness of the value. Used... | [
"Converts",
"the",
"given",
"value",
"to",
"an",
"appropriately",
"encoded",
"string",
"of",
"bytes",
"that",
"represents",
"it",
"."
] | 23e2eb92cfc084e6f9e8c718711ac994ef606d18 | https://github.com/pebble/libpebble2/blob/23e2eb92cfc084e6f9e8c718711ac994ef606d18/libpebble2/protocol/base/types.py#L73-L86 |
55,883 | alpha-xone/xone | xone/profile.py | profile | def profile(func):
"""
Decorator to profile functions with cProfile
Args:
func: python function
Returns:
profile report
References:
https://osf.io/upav8/
"""
def inner(*args, **kwargs):
pr = cProfile.Profile()
pr.enable()
res = func(*args, ... | python | def profile(func):
"""
Decorator to profile functions with cProfile
Args:
func: python function
Returns:
profile report
References:
https://osf.io/upav8/
"""
def inner(*args, **kwargs):
pr = cProfile.Profile()
pr.enable()
res = func(*args, ... | [
"def",
"profile",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pr",
"=",
"cProfile",
".",
"Profile",
"(",
")",
"pr",
".",
"enable",
"(",
")",
"res",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",... | Decorator to profile functions with cProfile
Args:
func: python function
Returns:
profile report
References:
https://osf.io/upav8/ | [
"Decorator",
"to",
"profile",
"functions",
"with",
"cProfile"
] | 68534a30f7f1760b220ba58040be3927f7dfbcf4 | https://github.com/alpha-xone/xone/blob/68534a30f7f1760b220ba58040be3927f7dfbcf4/xone/profile.py#L6-L31 |
55,884 | mathiasertl/xmpp-backends | xmpp_backends/ejabberd_xmlrpc.py | EjabberdXMLRPCBackend.rpc | def rpc(self, cmd, **kwargs):
"""Generic helper function to call an RPC method."""
func = getattr(self.client, cmd)
try:
if self.credentials is None:
return func(kwargs)
else:
return func(self.credentials, kwargs)
except socket.err... | python | def rpc(self, cmd, **kwargs):
"""Generic helper function to call an RPC method."""
func = getattr(self.client, cmd)
try:
if self.credentials is None:
return func(kwargs)
else:
return func(self.credentials, kwargs)
except socket.err... | [
"def",
"rpc",
"(",
"self",
",",
"cmd",
",",
"*",
"*",
"kwargs",
")",
":",
"func",
"=",
"getattr",
"(",
"self",
".",
"client",
",",
"cmd",
")",
"try",
":",
"if",
"self",
".",
"credentials",
"is",
"None",
":",
"return",
"func",
"(",
"kwargs",
")",
... | Generic helper function to call an RPC method. | [
"Generic",
"helper",
"function",
"to",
"call",
"an",
"RPC",
"method",
"."
] | 214ef0664dbf90fa300c2483b9b3416559e5d171 | https://github.com/mathiasertl/xmpp-backends/blob/214ef0664dbf90fa300c2483b9b3416559e5d171/xmpp_backends/ejabberd_xmlrpc.py#L107-L120 |
55,885 | schneiderfelipe/pyrrole | pyrrole/core.py | _parse_chemical_equation | def _parse_chemical_equation(value):
"""
Parse the chemical equation mini-language.
See the docstring of `ChemicalEquation` for more.
Parameters
----------
value : `str`
A string in chemical equation mini-language.
Returns
-------
mapping
A mapping in the format sp... | python | def _parse_chemical_equation(value):
"""
Parse the chemical equation mini-language.
See the docstring of `ChemicalEquation` for more.
Parameters
----------
value : `str`
A string in chemical equation mini-language.
Returns
-------
mapping
A mapping in the format sp... | [
"def",
"_parse_chemical_equation",
"(",
"value",
")",
":",
"arrow",
"=",
"_pp",
".",
"oneOf",
"(",
"'-> <- <=>'",
")",
".",
"setResultsName",
"(",
"'arrow'",
")",
"species",
"=",
"_pp",
".",
"Word",
"(",
"_pp",
".",
"printables",
")",
".",
"setResultsName"... | Parse the chemical equation mini-language.
See the docstring of `ChemicalEquation` for more.
Parameters
----------
value : `str`
A string in chemical equation mini-language.
Returns
-------
mapping
A mapping in the format specified by the mini-language (see notes on
... | [
"Parse",
"the",
"chemical",
"equation",
"mini",
"-",
"language",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/core.py#L24-L72 |
55,886 | schneiderfelipe/pyrrole | pyrrole/core.py | _get_chemical_equation_piece | def _get_chemical_equation_piece(species_list, coefficients):
"""
Produce a string from chemical species and their coefficients.
Parameters
----------
species_list : iterable of `str`
Iterable of chemical species.
coefficients : iterable of `float`
Nonzero stoichiometric coeffic... | python | def _get_chemical_equation_piece(species_list, coefficients):
"""
Produce a string from chemical species and their coefficients.
Parameters
----------
species_list : iterable of `str`
Iterable of chemical species.
coefficients : iterable of `float`
Nonzero stoichiometric coeffic... | [
"def",
"_get_chemical_equation_piece",
"(",
"species_list",
",",
"coefficients",
")",
":",
"def",
"_get_token",
"(",
"species",
",",
"coefficient",
")",
":",
"if",
"coefficient",
"==",
"1",
":",
"return",
"'{}'",
".",
"format",
"(",
"species",
")",
"else",
"... | Produce a string from chemical species and their coefficients.
Parameters
----------
species_list : iterable of `str`
Iterable of chemical species.
coefficients : iterable of `float`
Nonzero stoichiometric coefficients. The length of `species_list` and
`coefficients` must be the... | [
"Produce",
"a",
"string",
"from",
"chemical",
"species",
"and",
"their",
"coefficients",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/core.py#L75-L111 |
55,887 | schneiderfelipe/pyrrole | pyrrole/core.py | _check_data | def _check_data(data):
"""
Check a data object for inconsistencies.
Parameters
----------
data : `pandas.DataFrame`
A `data` object, i.e., a table whose rows store information about
chemical species, indexed by chemical species.
Warns
-----
UserWarning
Warned if... | python | def _check_data(data):
"""
Check a data object for inconsistencies.
Parameters
----------
data : `pandas.DataFrame`
A `data` object, i.e., a table whose rows store information about
chemical species, indexed by chemical species.
Warns
-----
UserWarning
Warned if... | [
"def",
"_check_data",
"(",
"data",
")",
":",
"if",
"\"vibfreqs\"",
"in",
"data",
".",
"columns",
":",
"for",
"species",
"in",
"data",
".",
"index",
":",
"vibfreqs",
"=",
"data",
".",
"loc",
"[",
"species",
",",
"\"vibfreqs\"",
"]",
"nimagvibfreqs",
"=",
... | Check a data object for inconsistencies.
Parameters
----------
data : `pandas.DataFrame`
A `data` object, i.e., a table whose rows store information about
chemical species, indexed by chemical species.
Warns
-----
UserWarning
Warned if a ground state species has one or ... | [
"Check",
"a",
"data",
"object",
"for",
"inconsistencies",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/core.py#L114-L154 |
55,888 | schneiderfelipe/pyrrole | pyrrole/core.py | _split_chemical_equations | def _split_chemical_equations(value):
"""
Split a string with sequential chemical equations into separate strings.
Each string in the returned iterable represents a single chemical equation
of the input.
See the docstrings of `ChemicalEquation` and `ChemicalSystem` for more.
Parameters
---... | python | def _split_chemical_equations(value):
"""
Split a string with sequential chemical equations into separate strings.
Each string in the returned iterable represents a single chemical equation
of the input.
See the docstrings of `ChemicalEquation` and `ChemicalSystem` for more.
Parameters
---... | [
"def",
"_split_chemical_equations",
"(",
"value",
")",
":",
"pieces",
"=",
"_split_arrows",
"(",
"value",
")",
"return",
"[",
"(",
"pieces",
"[",
"i",
"]",
"+",
"pieces",
"[",
"i",
"+",
"1",
"]",
"+",
"pieces",
"[",
"i",
"+",
"2",
"]",
")",
".",
... | Split a string with sequential chemical equations into separate strings.
Each string in the returned iterable represents a single chemical equation
of the input.
See the docstrings of `ChemicalEquation` and `ChemicalSystem` for more.
Parameters
----------
value : `str`
A string with se... | [
"Split",
"a",
"string",
"with",
"sequential",
"chemical",
"equations",
"into",
"separate",
"strings",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/core.py#L584-L615 |
55,889 | schneiderfelipe/pyrrole | pyrrole/core.py | ChemicalEquation.to_series | def to_series(self, only=None,
intensive_columns=["temperature", "pressure"],
check_data=True):
"""
Produce a data record for `ChemicalEquation`.
All possible linear differences for all numeric attributes are computed
and stored in the returned `panda... | python | def to_series(self, only=None,
intensive_columns=["temperature", "pressure"],
check_data=True):
"""
Produce a data record for `ChemicalEquation`.
All possible linear differences for all numeric attributes are computed
and stored in the returned `panda... | [
"def",
"to_series",
"(",
"self",
",",
"only",
"=",
"None",
",",
"intensive_columns",
"=",
"[",
"\"temperature\"",
",",
"\"pressure\"",
"]",
",",
"check_data",
"=",
"True",
")",
":",
"if",
"self",
".",
"data",
"is",
"None",
":",
"# TODO: should an empty Serie... | Produce a data record for `ChemicalEquation`.
All possible linear differences for all numeric attributes are computed
and stored in the returned `pandas.Series` object (see examples below).
This allows for easy application and manipulation of
`Hess's law <https://en.wikipedia.org/wiki/H... | [
"Produce",
"a",
"data",
"record",
"for",
"ChemicalEquation",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/core.py#L416-L546 |
55,890 | schneiderfelipe/pyrrole | pyrrole/core.py | ChemicalSystem.to_dataframe | def to_dataframe(self, *args, **kwargs):
"""
Produce a data table with records for all chemical equations.
All possible differences for numeric attributes are computed and stored
as columns in the returned `pandas.DataFrame` object (see examples
below), whose rows represent chem... | python | def to_dataframe(self, *args, **kwargs):
"""
Produce a data table with records for all chemical equations.
All possible differences for numeric attributes are computed and stored
as columns in the returned `pandas.DataFrame` object (see examples
below), whose rows represent chem... | [
"def",
"to_dataframe",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dataframe",
"=",
"_pd",
".",
"DataFrame",
"(",
"[",
"equation",
".",
"to_series",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"equation",
"in",
"se... | Produce a data table with records for all chemical equations.
All possible differences for numeric attributes are computed and stored
as columns in the returned `pandas.DataFrame` object (see examples
below), whose rows represent chemical equations.
In terms of behavior, this method ca... | [
"Produce",
"a",
"data",
"table",
"with",
"records",
"for",
"all",
"chemical",
"equations",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/core.py#L694-L736 |
55,891 | schneiderfelipe/pyrrole | pyrrole/core.py | ChemicalSystem.to_digraph | def to_digraph(self, *args, **kwargs):
"""
Compute a directed graph for the chemical system.
Returns
-------
digraph : `networkx.DiGraph`
Graph nodes are reactants and/or products of chemical equations,
while edges represent the equations themselves. Doub... | python | def to_digraph(self, *args, **kwargs):
"""
Compute a directed graph for the chemical system.
Returns
-------
digraph : `networkx.DiGraph`
Graph nodes are reactants and/or products of chemical equations,
while edges represent the equations themselves. Doub... | [
"def",
"to_digraph",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: make test for this",
"digraph",
"=",
"_nx",
".",
"DiGraph",
"(",
")",
"for",
"equation",
"in",
"self",
".",
"equations",
":",
"reactants",
",",
"arrow",
",",
... | Compute a directed graph for the chemical system.
Returns
-------
digraph : `networkx.DiGraph`
Graph nodes are reactants and/or products of chemical equations,
while edges represent the equations themselves. Double ended edges
are used to represent equilibria... | [
"Compute",
"a",
"directed",
"graph",
"for",
"the",
"chemical",
"system",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/core.py#L738-L801 |
55,892 | schneiderfelipe/pyrrole | pyrrole/atoms.py | read_cclib | def read_cclib(value, name=None):
"""
Create an `Atoms` object from data attributes parsed by cclib.
`cclib <https://cclib.github.io/>`_ is an open source library, written in
Python, for parsing and interpreting the results (logfiles) of
computational chemistry packages.
Parameters
-------... | python | def read_cclib(value, name=None):
"""
Create an `Atoms` object from data attributes parsed by cclib.
`cclib <https://cclib.github.io/>`_ is an open source library, written in
Python, for parsing and interpreting the results (logfiles) of
computational chemistry packages.
Parameters
-------... | [
"def",
"read_cclib",
"(",
"value",
",",
"name",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"_logfileparser",
".",
"Logfile",
")",
":",
"# TODO: test this case.",
"jobfilename",
"=",
"value",
".",
"filename",
"ccdata",
"=",
"value",
".",
... | Create an `Atoms` object from data attributes parsed by cclib.
`cclib <https://cclib.github.io/>`_ is an open source library, written in
Python, for parsing and interpreting the results (logfiles) of
computational chemistry packages.
Parameters
----------
value : `str`, `cclib.parser.logfilepa... | [
"Create",
"an",
"Atoms",
"object",
"from",
"data",
"attributes",
"parsed",
"by",
"cclib",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/atoms.py#L491-L548 |
55,893 | schneiderfelipe/pyrrole | pyrrole/atoms.py | read_pybel | def read_pybel(value, name=None):
"""
Create an `Atoms` object from content parsed by Pybel.
`Pybel <https://openbabel.org/docs/dev/UseTheLibrary/Python_Pybel.html>`_
is a Python module that simplifies access to the OpenBabel API, a chemical
toolbox designed to speak the many languages of chemical ... | python | def read_pybel(value, name=None):
"""
Create an `Atoms` object from content parsed by Pybel.
`Pybel <https://openbabel.org/docs/dev/UseTheLibrary/Python_Pybel.html>`_
is a Python module that simplifies access to the OpenBabel API, a chemical
toolbox designed to speak the many languages of chemical ... | [
"def",
"read_pybel",
"(",
"value",
",",
"name",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"_pb",
".",
"Molecule",
")",
":",
"# TODO: test this case.",
"jobfilename",
"=",
"None",
"charge",
",",
"mult",
"=",
"value",
".",
"charge",
","... | Create an `Atoms` object from content parsed by Pybel.
`Pybel <https://openbabel.org/docs/dev/UseTheLibrary/Python_Pybel.html>`_
is a Python module that simplifies access to the OpenBabel API, a chemical
toolbox designed to speak the many languages of chemical data. It’s an
open, collaborative project ... | [
"Create",
"an",
"Atoms",
"object",
"from",
"content",
"parsed",
"by",
"Pybel",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/atoms.py#L551-L628 |
55,894 | schneiderfelipe/pyrrole | pyrrole/atoms.py | create_data | def create_data(*args):
"""
Produce a single data object from an arbitrary number of different objects.
This function returns a single `pandas.DataFrame` object from a collection
of `Atoms` and `pandas.DataFrame` objects. The returned object, already
indexed by `Atoms.name`, can be promptly used by... | python | def create_data(*args):
"""
Produce a single data object from an arbitrary number of different objects.
This function returns a single `pandas.DataFrame` object from a collection
of `Atoms` and `pandas.DataFrame` objects. The returned object, already
indexed by `Atoms.name`, can be promptly used by... | [
"def",
"create_data",
"(",
"*",
"args",
")",
":",
"def",
"_prepare_data",
"(",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"_pd",
".",
"DataFrame",
")",
":",
"try",
":",
"data",
"=",
"_pd",
".",
"DataFrame",
"(",
"[",
"data",
"."... | Produce a single data object from an arbitrary number of different objects.
This function returns a single `pandas.DataFrame` object from a collection
of `Atoms` and `pandas.DataFrame` objects. The returned object, already
indexed by `Atoms.name`, can be promptly used by e.g. `ChemicalSystem`.
Paramet... | [
"Produce",
"a",
"single",
"data",
"object",
"from",
"an",
"arbitrary",
"number",
"of",
"different",
"objects",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/atoms.py#L631-L690 |
55,895 | schneiderfelipe/pyrrole | pyrrole/atoms.py | Atoms.split | def split(self, pattern=None):
r"""
Break molecule up into constituent fragments.
By default (i.e., if `pattern` is `None`), each disconnected fragment
is returned as a separate new `Atoms` object. This uses OpenBabel
(through `OBMol.Separate`) and might not preserve atom order,... | python | def split(self, pattern=None):
r"""
Break molecule up into constituent fragments.
By default (i.e., if `pattern` is `None`), each disconnected fragment
is returned as a separate new `Atoms` object. This uses OpenBabel
(through `OBMol.Separate`) and might not preserve atom order,... | [
"def",
"split",
"(",
"self",
",",
"pattern",
"=",
"None",
")",
":",
"molecule_pybel",
"=",
"self",
".",
"to_pybel",
"(",
")",
"if",
"pattern",
"is",
"None",
":",
"fragments",
"=",
"[",
"read_pybel",
"(",
"frag",
")",
"for",
"frag",
"in",
"molecule_pybe... | r"""
Break molecule up into constituent fragments.
By default (i.e., if `pattern` is `None`), each disconnected fragment
is returned as a separate new `Atoms` object. This uses OpenBabel
(through `OBMol.Separate`) and might not preserve atom order, depending
on your version of t... | [
"r",
"Break",
"molecule",
"up",
"into",
"constituent",
"fragments",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/atoms.py#L140-L212 |
55,896 | schneiderfelipe/pyrrole | pyrrole/atoms.py | Atoms.to_pybel | def to_pybel(self):
"""
Produce a Pybel Molecule object.
It is based on the capabilities of OpenBabel through Pybel. The present
object must have at least `atomcoords`, `atomnos`, `charge` and `mult`
defined.
Returns
-------
`pybel.Molecule`
Exa... | python | def to_pybel(self):
"""
Produce a Pybel Molecule object.
It is based on the capabilities of OpenBabel through Pybel. The present
object must have at least `atomcoords`, `atomnos`, `charge` and `mult`
defined.
Returns
-------
`pybel.Molecule`
Exa... | [
"def",
"to_pybel",
"(",
"self",
")",
":",
"# TODO: This only exports last geometry by default.",
"obmol",
"=",
"_makeopenbabel",
"(",
"self",
".",
"atomcoords",
",",
"self",
".",
"atomnos",
",",
"self",
".",
"charge",
",",
"self",
".",
"mult",
")",
"title",
"=... | Produce a Pybel Molecule object.
It is based on the capabilities of OpenBabel through Pybel. The present
object must have at least `atomcoords`, `atomnos`, `charge` and `mult`
defined.
Returns
-------
`pybel.Molecule`
Examples
--------
>>> from ... | [
"Produce",
"a",
"Pybel",
"Molecule",
"object",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/atoms.py#L253-L289 |
55,897 | schneiderfelipe/pyrrole | pyrrole/atoms.py | Atoms.to_string | def to_string(self, format="smi", dialect=None, with_header=False,
fragment_id=None, constraints=None):
r"""
Produce a string representation of the molecule.
This function wraps and extends the functionality of OpenBabel (which
is accessible through `to_pybel`). Many c... | python | def to_string(self, format="smi", dialect=None, with_header=False,
fragment_id=None, constraints=None):
r"""
Produce a string representation of the molecule.
This function wraps and extends the functionality of OpenBabel (which
is accessible through `to_pybel`). Many c... | [
"def",
"to_string",
"(",
"self",
",",
"format",
"=",
"\"smi\"",
",",
"dialect",
"=",
"None",
",",
"with_header",
"=",
"False",
",",
"fragment_id",
"=",
"None",
",",
"constraints",
"=",
"None",
")",
":",
"s",
"=",
"self",
".",
"to_pybel",
"(",
")",
".... | r"""
Produce a string representation of the molecule.
This function wraps and extends the functionality of OpenBabel (which
is accessible through `to_pybel`). Many chemical formats can thus be
output (see the `pybel.outformats` variable for a list of available
output formats).
... | [
"r",
"Produce",
"a",
"string",
"representation",
"of",
"the",
"molecule",
"."
] | 13e26accc9a059f0ab69773648b24292fe1fbfd6 | https://github.com/schneiderfelipe/pyrrole/blob/13e26accc9a059f0ab69773648b24292fe1fbfd6/pyrrole/atoms.py#L291-L488 |
55,898 | arve0/fijibin | fijibin/macro.py | run | def run(macro, output_files=[], force_close=True):
"""
Runs Fiji with the suplied macro. Output of Fiji can be viewed by
setting environment variable `DEBUG=fijibin`.
Parameters
----------
macro : string or list of strings
IJM-macro(s) to run. If list of strings, it will be joined with
... | python | def run(macro, output_files=[], force_close=True):
"""
Runs Fiji with the suplied macro. Output of Fiji can be viewed by
setting environment variable `DEBUG=fijibin`.
Parameters
----------
macro : string or list of strings
IJM-macro(s) to run. If list of strings, it will be joined with
... | [
"def",
"run",
"(",
"macro",
",",
"output_files",
"=",
"[",
"]",
",",
"force_close",
"=",
"True",
")",
":",
"if",
"type",
"(",
"macro",
")",
"==",
"list",
":",
"macro",
"=",
"' '",
".",
"join",
"(",
"macro",
")",
"if",
"len",
"(",
"macro",
")",
... | Runs Fiji with the suplied macro. Output of Fiji can be viewed by
setting environment variable `DEBUG=fijibin`.
Parameters
----------
macro : string or list of strings
IJM-macro(s) to run. If list of strings, it will be joined with
a space, so all statements should end with ``;``.
o... | [
"Runs",
"Fiji",
"with",
"the",
"suplied",
"macro",
".",
"Output",
"of",
"Fiji",
"can",
"be",
"viewed",
"by",
"setting",
"environment",
"variable",
"DEBUG",
"=",
"fijibin",
"."
] | a3d2e983cb9ff2bcbb56a800084bc3b35cb9292f | https://github.com/arve0/fijibin/blob/a3d2e983cb9ff2bcbb56a800084bc3b35cb9292f/fijibin/macro.py#L16-L97 |
55,899 | arve0/fijibin | fijibin/macro.py | _exists | def _exists(filenames):
"""Check if every filename exists. If not, print an error
message and remove the item from the list.
Parameters
----------
filenames : list
List of filenames to check for existence.
Returns
-------
list
Filtered list of filenames that exists.
... | python | def _exists(filenames):
"""Check if every filename exists. If not, print an error
message and remove the item from the list.
Parameters
----------
filenames : list
List of filenames to check for existence.
Returns
-------
list
Filtered list of filenames that exists.
... | [
"def",
"_exists",
"(",
"filenames",
")",
":",
"exists",
"=",
"[",
"]",
"for",
"filename",
"in",
"filenames",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"exists",
".",
"append",
"(",
"filename",
")",
"else",
":",
"print",
... | Check if every filename exists. If not, print an error
message and remove the item from the list.
Parameters
----------
filenames : list
List of filenames to check for existence.
Returns
-------
list
Filtered list of filenames that exists. | [
"Check",
"if",
"every",
"filename",
"exists",
".",
"If",
"not",
"print",
"an",
"error",
"message",
"and",
"remove",
"the",
"item",
"from",
"the",
"list",
"."
] | a3d2e983cb9ff2bcbb56a800084bc3b35cb9292f | https://github.com/arve0/fijibin/blob/a3d2e983cb9ff2bcbb56a800084bc3b35cb9292f/fijibin/macro.py#L182-L203 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.