repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
steveYeah/PyBomb | pybomb/clients/base_client.py | BaseClient._validate_response | def _validate_response(self, response):
"""
:param response: requests.models.Response
:raises: pybomb.exceptions.InvalidResponseException
:raises: pybomb.exceptions.BadRequestException
"""
try:
response.raise_for_status()
except HTTPError as http_error... | python | def _validate_response(self, response):
"""
:param response: requests.models.Response
:raises: pybomb.exceptions.InvalidResponseException
:raises: pybomb.exceptions.BadRequestException
"""
try:
response.raise_for_status()
except HTTPError as http_error... | [
"def",
"_validate_response",
"(",
"self",
",",
"response",
")",
":",
"try",
":",
"response",
".",
"raise_for_status",
"(",
")",
"except",
"HTTPError",
"as",
"http_error",
":",
"raise",
"BadRequestException",
"(",
"str",
"(",
"http_error",
")",
")",
"response_d... | :param response: requests.models.Response
:raises: pybomb.exceptions.InvalidResponseException
:raises: pybomb.exceptions.BadRequestException | [
":",
"param",
"response",
":",
"requests",
".",
"models",
".",
"Response",
":",
"raises",
":",
"pybomb",
".",
"exceptions",
".",
"InvalidResponseException",
":",
"raises",
":",
"pybomb",
".",
"exceptions",
".",
"BadRequestException"
] | 54045d74e642f8a1c4366c24bd6a330ae3da6257 | https://github.com/steveYeah/PyBomb/blob/54045d74e642f8a1c4366c24bd6a330ae3da6257/pybomb/clients/base_client.py#L162-L179 | train | Validate the response from the server. |
glormph/msstitch | src/app/drivers/mzidtsv/prot2gene.py | TSVGeneFromProteinDriver.get_psms | def get_psms(self):
"""Creates iterator to write to new tsv. Contains input tsv
lines plus quant data for these."""
self.header = actions.create_header(self.oldheader)
self.psms = actions.add_genes_to_psm_table(self.fn, self.oldheader,
s... | python | def get_psms(self):
"""Creates iterator to write to new tsv. Contains input tsv
lines plus quant data for these."""
self.header = actions.create_header(self.oldheader)
self.psms = actions.add_genes_to_psm_table(self.fn, self.oldheader,
s... | [
"def",
"get_psms",
"(",
"self",
")",
":",
"self",
".",
"header",
"=",
"actions",
".",
"create_header",
"(",
"self",
".",
"oldheader",
")",
"self",
".",
"psms",
"=",
"actions",
".",
"add_genes_to_psm_table",
"(",
"self",
".",
"fn",
",",
"self",
".",
"ol... | Creates iterator to write to new tsv. Contains input tsv
lines plus quant data for these. | [
"Creates",
"iterator",
"to",
"write",
"to",
"new",
"tsv",
".",
"Contains",
"input",
"tsv",
"lines",
"plus",
"quant",
"data",
"for",
"these",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/mzidtsv/prot2gene.py#L17-L22 | train | Creates iterator to write to new tsv. Contains input tsv
lines plus quant data for these. |
chriso/gauged | gauged/writer.py | Writer.add | def add(self, data, value=None, timestamp=None, namespace=None,
debug=False):
"""Queue a gauge or gauges to be written"""
if value is not None:
return self.add(((data, value),), timestamp=timestamp,
namespace=namespace, debug=debug)
writer = se... | python | def add(self, data, value=None, timestamp=None, namespace=None,
debug=False):
"""Queue a gauge or gauges to be written"""
if value is not None:
return self.add(((data, value),), timestamp=timestamp,
namespace=namespace, debug=debug)
writer = se... | [
"def",
"add",
"(",
"self",
",",
"data",
",",
"value",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"self",
".",
"add",
"(",
"("... | Queue a gauge or gauges to be written | [
"Queue",
"a",
"gauge",
"or",
"gauges",
"to",
"be",
"written"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L47-L128 | train | Add a new entry to the queue. |
chriso/gauged | gauged/writer.py | Writer.flush | def flush(self):
"""Flush all pending gauges"""
writer = self.writer
if writer is None:
raise GaugedUseAfterFreeError
self.flush_writer_position()
keys = self.translate_keys()
blocks = []
current_block = self.current_block
statistics = self.sta... | python | def flush(self):
"""Flush all pending gauges"""
writer = self.writer
if writer is None:
raise GaugedUseAfterFreeError
self.flush_writer_position()
keys = self.translate_keys()
blocks = []
current_block = self.current_block
statistics = self.sta... | [
"def",
"flush",
"(",
"self",
")",
":",
"writer",
"=",
"self",
".",
"writer",
"if",
"writer",
"is",
"None",
":",
"raise",
"GaugedUseAfterFreeError",
"self",
".",
"flush_writer_position",
"(",
")",
"keys",
"=",
"self",
".",
"translate_keys",
"(",
")",
"block... | Flush all pending gauges | [
"Flush",
"all",
"pending",
"gauges"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L130-L162 | train | Flush all pending gauges and all associated gauges. |
chriso/gauged | gauged/writer.py | Writer.resume_from | def resume_from(self):
"""Get a timestamp representing the position just after the last
written gauge"""
position = self.driver.get_writer_position(self.config.writer_name)
return position + self.config.resolution if position else 0 | python | def resume_from(self):
"""Get a timestamp representing the position just after the last
written gauge"""
position = self.driver.get_writer_position(self.config.writer_name)
return position + self.config.resolution if position else 0 | [
"def",
"resume_from",
"(",
"self",
")",
":",
"position",
"=",
"self",
".",
"driver",
".",
"get_writer_position",
"(",
"self",
".",
"config",
".",
"writer_name",
")",
"return",
"position",
"+",
"self",
".",
"config",
".",
"resolution",
"if",
"position",
"el... | Get a timestamp representing the position just after the last
written gauge | [
"Get",
"a",
"timestamp",
"representing",
"the",
"position",
"just",
"after",
"the",
"last",
"written",
"gauge"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L164-L168 | train | Get a timestamp representing the position just after the last acquired timestamp |
chriso/gauged | gauged/writer.py | Writer.clear_from | def clear_from(self, timestamp):
"""Clear all data from `timestamp` onwards. Note that the timestamp
is rounded down to the nearest block boundary"""
block_size = self.config.block_size
offset, remainder = timestamp // block_size, timestamp % block_size
if remainder:
... | python | def clear_from(self, timestamp):
"""Clear all data from `timestamp` onwards. Note that the timestamp
is rounded down to the nearest block boundary"""
block_size = self.config.block_size
offset, remainder = timestamp // block_size, timestamp % block_size
if remainder:
... | [
"def",
"clear_from",
"(",
"self",
",",
"timestamp",
")",
":",
"block_size",
"=",
"self",
".",
"config",
".",
"block_size",
"offset",
",",
"remainder",
"=",
"timestamp",
"//",
"block_size",
",",
"timestamp",
"%",
"block_size",
"if",
"remainder",
":",
"raise",... | Clear all data from `timestamp` onwards. Note that the timestamp
is rounded down to the nearest block boundary | [
"Clear",
"all",
"data",
"from",
"timestamp",
"onwards",
".",
"Note",
"that",
"the",
"timestamp",
"is",
"rounded",
"down",
"to",
"the",
"nearest",
"block",
"boundary"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L170-L177 | train | Clear all data from timestamp onwards. |
chriso/gauged | gauged/writer.py | Writer.clear_key_before | def clear_key_before(self, key, namespace=None, timestamp=None):
"""Clear all data before `timestamp` for a given key. Note that the
timestamp is rounded down to the nearest block boundary"""
block_size = self.config.block_size
if namespace is None:
namespace = self.config.na... | python | def clear_key_before(self, key, namespace=None, timestamp=None):
"""Clear all data before `timestamp` for a given key. Note that the
timestamp is rounded down to the nearest block boundary"""
block_size = self.config.block_size
if namespace is None:
namespace = self.config.na... | [
"def",
"clear_key_before",
"(",
"self",
",",
"key",
",",
"namespace",
"=",
"None",
",",
"timestamp",
"=",
"None",
")",
":",
"block_size",
"=",
"self",
".",
"config",
".",
"block_size",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"self",
".",
... | Clear all data before `timestamp` for a given key. Note that the
timestamp is rounded down to the nearest block boundary | [
"Clear",
"all",
"data",
"before",
"timestamp",
"for",
"a",
"given",
"key",
".",
"Note",
"that",
"the",
"timestamp",
"is",
"rounded",
"down",
"to",
"the",
"nearest",
"block",
"boundary"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L179-L194 | train | Clear all data before a given timestamp for a given key. |
chriso/gauged | gauged/writer.py | Writer.parse_query | def parse_query(self, query):
"""Parse a query string and return an iterator which yields
(key, value)"""
writer = self.writer
if writer is None:
raise GaugedUseAfterFreeError
Gauged.writer_parse_query(writer, query)
position = 0
writer_contents = writ... | python | def parse_query(self, query):
"""Parse a query string and return an iterator which yields
(key, value)"""
writer = self.writer
if writer is None:
raise GaugedUseAfterFreeError
Gauged.writer_parse_query(writer, query)
position = 0
writer_contents = writ... | [
"def",
"parse_query",
"(",
"self",
",",
"query",
")",
":",
"writer",
"=",
"self",
".",
"writer",
"if",
"writer",
"is",
"None",
":",
"raise",
"GaugedUseAfterFreeError",
"Gauged",
".",
"writer_parse_query",
"(",
"writer",
",",
"query",
")",
"position",
"=",
... | Parse a query string and return an iterator which yields
(key, value) | [
"Parse",
"a",
"query",
"string",
"and",
"return",
"an",
"iterator",
"which",
"yields",
"(",
"key",
"value",
")"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/writer.py#L210-L223 | train | Parse a query string and return an iterator which yields
( key value |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | CTfile.loadstr | def loadstr(cls, string):
"""Load data into ``CTfile`` object from string.
:param str string: String containing data in ``CTfile`` format.
:return: Instance of ``CTfile``.
"""
try:
string = string.decode('utf-8')
except AttributeError:
pas... | python | def loadstr(cls, string):
"""Load data into ``CTfile`` object from string.
:param str string: String containing data in ``CTfile`` format.
:return: Instance of ``CTfile``.
"""
try:
string = string.decode('utf-8')
except AttributeError:
pas... | [
"def",
"loadstr",
"(",
"cls",
",",
"string",
")",
":",
"try",
":",
"string",
"=",
"string",
".",
"decode",
"(",
"'utf-8'",
")",
"except",
"AttributeError",
":",
"pass",
"lexer",
"=",
"tokenizer",
"(",
"string",
")",
"if",
"cls",
".",
"is_molfile",
"(",... | Load data into ``CTfile`` object from string.
:param str string: String containing data in ``CTfile`` format.
:return: Instance of ``CTfile``. | [
"Load",
"data",
"into",
"CTfile",
"object",
"from",
"string",
".",
":",
"param",
"str",
"string",
":",
"String",
"containing",
"data",
"in",
"CTfile",
"format",
".",
":",
"return",
":",
"Instance",
"of",
"CTfile",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L48-L80 | train | Load data into CTfile object from string. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | CTfile.write | def write(self, filehandle, file_format):
"""Write :class:`~ctfile.ctfile.CTfile` data into file.
:param filehandle: File-like object.
:param str file_format: Format to use to write data: ``ctfile`` or ``json``.
:return: None.
:rtype: :py:obj:`None`.
"""
try:
... | python | def write(self, filehandle, file_format):
"""Write :class:`~ctfile.ctfile.CTfile` data into file.
:param filehandle: File-like object.
:param str file_format: Format to use to write data: ``ctfile`` or ``json``.
:return: None.
:rtype: :py:obj:`None`.
"""
try:
... | [
"def",
"write",
"(",
"self",
",",
"filehandle",
",",
"file_format",
")",
":",
"try",
":",
"filehandle",
".",
"write",
"(",
"self",
".",
"writestr",
"(",
"file_format",
"=",
"file_format",
")",
")",
"except",
"IOError",
":",
"raise",
"IOError",
"(",
"'\"f... | Write :class:`~ctfile.ctfile.CTfile` data into file.
:param filehandle: File-like object.
:param str file_format: Format to use to write data: ``ctfile`` or ``json``.
:return: None.
:rtype: :py:obj:`None`. | [
"Write",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"CTfile",
"data",
"into",
"file",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L82-L93 | train | Writes the data into file. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | CTfile.print_file | def print_file(self, file_format='ctfile', f=sys.stdout):
"""Print representation of :class:`~ctfile.ctfile.CTfile`.
:param str file_format: Format to use: ``ctfile`` or ``json``.
:param f: Print to file or stdout.
:type f: File-like
:return: None.
:rtype: :py:obj:`None... | python | def print_file(self, file_format='ctfile', f=sys.stdout):
"""Print representation of :class:`~ctfile.ctfile.CTfile`.
:param str file_format: Format to use: ``ctfile`` or ``json``.
:param f: Print to file or stdout.
:type f: File-like
:return: None.
:rtype: :py:obj:`None... | [
"def",
"print_file",
"(",
"self",
",",
"file_format",
"=",
"'ctfile'",
",",
"f",
"=",
"sys",
".",
"stdout",
")",
":",
"print",
"(",
"self",
".",
"writestr",
"(",
"file_format",
"=",
"file_format",
")",
",",
"file",
"=",
"f",
")"
] | Print representation of :class:`~ctfile.ctfile.CTfile`.
:param str file_format: Format to use: ``ctfile`` or ``json``.
:param f: Print to file or stdout.
:type f: File-like
:return: None.
:rtype: :py:obj:`None`. | [
"Print",
"representation",
"of",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"CTfile",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L110-L119 | train | Print the contents of the object to a file or stdout. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | CTfile._to_json | def _to_json(self, sort_keys=False, indent=4):
"""Convert :class:`~ctfile.ctfile.CTfile` into JSON string.
:return: ``JSON`` formatted string.
:rtype: :py:class:`str`.
"""
return json.dumps(self, sort_keys=sort_keys, indent=indent, cls=CtabAtomBondEncoder) | python | def _to_json(self, sort_keys=False, indent=4):
"""Convert :class:`~ctfile.ctfile.CTfile` into JSON string.
:return: ``JSON`` formatted string.
:rtype: :py:class:`str`.
"""
return json.dumps(self, sort_keys=sort_keys, indent=indent, cls=CtabAtomBondEncoder) | [
"def",
"_to_json",
"(",
"self",
",",
"sort_keys",
"=",
"False",
",",
"indent",
"=",
"4",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
",",
"sort_keys",
"=",
"sort_keys",
",",
"indent",
"=",
"indent",
",",
"cls",
"=",
"CtabAtomBondEncoder",
")... | Convert :class:`~ctfile.ctfile.CTfile` into JSON string.
:return: ``JSON`` formatted string.
:rtype: :py:class:`str`. | [
"Convert",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"CTfile",
"into",
"JSON",
"string",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L129-L135 | train | Convert the CtabAtomBond object into a JSON string. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._build | def _build(self, lexer):
"""Build :class:`~ctfile.ctfile.Ctab` instance.
:return: :class:`~ctfile.ctfile.Ctab` instance.
:rtype: :class:`~ctfile.ctfile.Ctab`.
"""
atom_number = 1
while True:
token = next(lexer)
key = token.__class__.__name__
... | python | def _build(self, lexer):
"""Build :class:`~ctfile.ctfile.Ctab` instance.
:return: :class:`~ctfile.ctfile.Ctab` instance.
:rtype: :class:`~ctfile.ctfile.Ctab`.
"""
atom_number = 1
while True:
token = next(lexer)
key = token.__class__.__name__
... | [
"def",
"_build",
"(",
"self",
",",
"lexer",
")",
":",
"atom_number",
"=",
"1",
"while",
"True",
":",
"token",
"=",
"next",
"(",
"lexer",
")",
"key",
"=",
"token",
".",
"__class__",
".",
"__name__",
"if",
"key",
"==",
"'CtabCountsLine'",
":",
"self",
... | Build :class:`~ctfile.ctfile.Ctab` instance.
:return: :class:`~ctfile.ctfile.Ctab` instance.
:rtype: :class:`~ctfile.ctfile.Ctab`. | [
"Build",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"Ctab",
"instance",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L273-L318 | train | Build the list of Ctab objects. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile | def _to_ctfile(self):
"""Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: `CTfile` formatted string.
:rtype: :py:class:`str`.
"""
output = io.StringIO()
for key in self:
if key == 'CtabCountsLine':
output.write(s... | python | def _to_ctfile(self):
"""Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: `CTfile` formatted string.
:rtype: :py:class:`str`.
"""
output = io.StringIO()
for key in self:
if key == 'CtabCountsLine':
output.write(s... | [
"def",
"_to_ctfile",
"(",
"self",
")",
":",
"output",
"=",
"io",
".",
"StringIO",
"(",
")",
"for",
"key",
"in",
"self",
":",
"if",
"key",
"==",
"'CtabCountsLine'",
":",
"output",
".",
"write",
"(",
"self",
".",
"_to_ctfile_counts_line",
"(",
"key",
"="... | Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: `CTfile` formatted string.
:rtype: :py:class:`str`. | [
"Convert",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"CTfile",
"into",
"CTfile",
"formatted",
"string",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L320-L344 | train | Convert the list of all the elements of the current object into a CTfile formatted string. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile_counts_line | def _to_ctfile_counts_line(self, key):
"""Create counts line in ``CTfile`` format.
:param str key: Counts line key.
:return: Counts line string.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(self.counts_line_format)
self[key]['number_of_atoms'] = str(len(... | python | def _to_ctfile_counts_line(self, key):
"""Create counts line in ``CTfile`` format.
:param str key: Counts line key.
:return: Counts line string.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(self.counts_line_format)
self[key]['number_of_atoms'] = str(len(... | [
"def",
"_to_ctfile_counts_line",
"(",
"self",
",",
"key",
")",
":",
"counter",
"=",
"OrderedCounter",
"(",
"self",
".",
"counts_line_format",
")",
"self",
"[",
"key",
"]",
"[",
"'number_of_atoms'",
"]",
"=",
"str",
"(",
"len",
"(",
"self",
".",
"atoms",
... | Create counts line in ``CTfile`` format.
:param str key: Counts line key.
:return: Counts line string.
:rtype: :py:class:`str` | [
"Create",
"counts",
"line",
"in",
"CTfile",
"format",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L346-L358 | train | Create counts line in CTfile format. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile_atom_block | def _to_ctfile_atom_block(self, key):
"""Create atom block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab atom block.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(Atom.atom_block_format)
ctab_atom_block = '\n'.join([''.join([str(v... | python | def _to_ctfile_atom_block(self, key):
"""Create atom block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab atom block.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(Atom.atom_block_format)
ctab_atom_block = '\n'.join([''.join([str(v... | [
"def",
"_to_ctfile_atom_block",
"(",
"self",
",",
"key",
")",
":",
"counter",
"=",
"OrderedCounter",
"(",
"Atom",
".",
"atom_block_format",
")",
"ctab_atom_block",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"''",
".",
"join",
"(",
"[",
"str",
"(",
"value",
")"... | Create atom block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab atom block.
:rtype: :py:class:`str` | [
"Create",
"atom",
"block",
"in",
"CTfile",
"format",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L360-L371 | train | Create atom block in CTfile format. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile_bond_block | def _to_ctfile_bond_block(self, key):
"""Create bond block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab bond block.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(Bond.bond_block_format)
ctab_bond_block = '\n'.join([''.join([str(v... | python | def _to_ctfile_bond_block(self, key):
"""Create bond block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab bond block.
:rtype: :py:class:`str`
"""
counter = OrderedCounter(Bond.bond_block_format)
ctab_bond_block = '\n'.join([''.join([str(v... | [
"def",
"_to_ctfile_bond_block",
"(",
"self",
",",
"key",
")",
":",
"counter",
"=",
"OrderedCounter",
"(",
"Bond",
".",
"bond_block_format",
")",
"ctab_bond_block",
"=",
"'\\n'",
".",
"join",
"(",
"[",
"''",
".",
"join",
"(",
"[",
"str",
"(",
"value",
")"... | Create bond block in `CTfile` format.
:param str key: Ctab atom block key.
:return: Ctab bond block.
:rtype: :py:class:`str` | [
"Create",
"bond",
"block",
"in",
"CTfile",
"format",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L373-L384 | train | Create bond block in CTfile format. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab._to_ctfile_property_block | def _to_ctfile_property_block(self):
"""Create ctab properties block in `CTfile` format from atom-specific properties.
:return: Ctab property block.
:rtype: :py:class:`str`
"""
ctab_properties_data = defaultdict(list)
for atom in self.atoms:
for ctab_property... | python | def _to_ctfile_property_block(self):
"""Create ctab properties block in `CTfile` format from atom-specific properties.
:return: Ctab property block.
:rtype: :py:class:`str`
"""
ctab_properties_data = defaultdict(list)
for atom in self.atoms:
for ctab_property... | [
"def",
"_to_ctfile_property_block",
"(",
"self",
")",
":",
"ctab_properties_data",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"atom",
"in",
"self",
".",
"atoms",
":",
"for",
"ctab_property_key",
",",
"ctab_property_value",
"in",
"atom",
".",
"_ctab_property_data... | Create ctab properties block in `CTfile` format from atom-specific properties.
:return: Ctab property block.
:rtype: :py:class:`str` | [
"Create",
"ctab",
"properties",
"block",
"in",
"CTfile",
"format",
"from",
"atom",
"-",
"specific",
"properties",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L386-L408 | train | Create ctab properties block in CTfile format from atom - specific properties. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Ctab.delete_atom | def delete_atom(self, *atom_numbers):
"""Delete atoms by atom number.
:param str atom_numbers:
:return: None.
:rtype: :py:obj:`None`
"""
for atom_number in atom_numbers:
deletion_atom = self.atom_by_number(atom_number=atom_number)
# update atom ... | python | def delete_atom(self, *atom_numbers):
"""Delete atoms by atom number.
:param str atom_numbers:
:return: None.
:rtype: :py:obj:`None`
"""
for atom_number in atom_numbers:
deletion_atom = self.atom_by_number(atom_number=atom_number)
# update atom ... | [
"def",
"delete_atom",
"(",
"self",
",",
"*",
"atom_numbers",
")",
":",
"for",
"atom_number",
"in",
"atom_numbers",
":",
"deletion_atom",
"=",
"self",
".",
"atom_by_number",
"(",
"atom_number",
"=",
"atom_number",
")",
"# update atom numbers",
"for",
"atom",
"in"... | Delete atoms by atom number.
:param str atom_numbers:
:return: None.
:rtype: :py:obj:`None` | [
"Delete",
"atoms",
"by",
"atom",
"number",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L522-L548 | train | Delete atoms by atom number. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Molfile._build | def _build(self, lexer):
"""Build :class:`~ctfile.ctfile.Molfile` instance.
:return: :class:`~ctfile.ctfile.Molfile` instance.
:rtype: :class:`~ctfile.ctfile.Molfile`.
"""
key = ''
while key != 'EndOfFile':
token = next(lexer)
key = token.__class... | python | def _build(self, lexer):
"""Build :class:`~ctfile.ctfile.Molfile` instance.
:return: :class:`~ctfile.ctfile.Molfile` instance.
:rtype: :class:`~ctfile.ctfile.Molfile`.
"""
key = ''
while key != 'EndOfFile':
token = next(lexer)
key = token.__class... | [
"def",
"_build",
"(",
"self",
",",
"lexer",
")",
":",
"key",
"=",
"''",
"while",
"key",
"!=",
"'EndOfFile'",
":",
"token",
"=",
"next",
"(",
"lexer",
")",
"key",
"=",
"token",
".",
"__class__",
".",
"__name__",
"if",
"key",
"==",
"'HeaderBlock'",
":"... | Build :class:`~ctfile.ctfile.Molfile` instance.
:return: :class:`~ctfile.ctfile.Molfile` instance.
:rtype: :class:`~ctfile.ctfile.Molfile`. | [
"Build",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"Molfile",
"instance",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L573-L602 | train | Build the Molfile instance. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Molfile._to_ctfile | def _to_ctfile(self):
"""Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: ``CTfile`` formatted string.
:rtype: :py:class:`str`.
"""
output = io.StringIO()
for key in self:
if key == 'HeaderBlock':
for line in se... | python | def _to_ctfile(self):
"""Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: ``CTfile`` formatted string.
:rtype: :py:class:`str`.
"""
output = io.StringIO()
for key in self:
if key == 'HeaderBlock':
for line in se... | [
"def",
"_to_ctfile",
"(",
"self",
")",
":",
"output",
"=",
"io",
".",
"StringIO",
"(",
")",
"for",
"key",
"in",
"self",
":",
"if",
"key",
"==",
"'HeaderBlock'",
":",
"for",
"line",
"in",
"self",
"[",
"key",
"]",
".",
"values",
"(",
")",
":",
"out... | Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: ``CTfile`` formatted string.
:rtype: :py:class:`str`. | [
"Convert",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"CTfile",
"into",
"CTfile",
"formatted",
"string",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L604-L625 | train | Convert the Molfile object into a CTfile formatted string. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile.from_molfile | def from_molfile(cls, molfile, data=None):
"""Construct new ``SDfile`` object from ``Molfile`` object.
:param molfile: ``Molfile`` object.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:return: ``SDfile`` object.
:rtype: :class:`~ctfile.ctfile.SDfile`.
"""
if n... | python | def from_molfile(cls, molfile, data=None):
"""Construct new ``SDfile`` object from ``Molfile`` object.
:param molfile: ``Molfile`` object.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:return: ``SDfile`` object.
:rtype: :class:`~ctfile.ctfile.SDfile`.
"""
if n... | [
"def",
"from_molfile",
"(",
"cls",
",",
"molfile",
",",
"data",
"=",
"None",
")",
":",
"if",
"not",
"data",
":",
"data",
"=",
"OrderedDict",
"(",
")",
"if",
"not",
"isinstance",
"(",
"molfile",
",",
"Molfile",
")",
":",
"raise",
"ValueError",
"(",
"'... | Construct new ``SDfile`` object from ``Molfile`` object.
:param molfile: ``Molfile`` object.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:return: ``SDfile`` object.
:rtype: :class:`~ctfile.ctfile.SDfile`. | [
"Construct",
"new",
"SDfile",
"object",
"from",
"Molfile",
"object",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L768-L789 | train | Construct a new SDfile object from a Molfile object. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile.add_data | def add_data(self, id, key, value):
"""Add new data item.
:param str id: Entry id within ``SDfile``.
:param str key: Data item key.
:param str value: Data item value.
:return: None.
:rtype: :py:obj:`None`.
"""
self[str(id)]['data'].setdefault(key, [])
... | python | def add_data(self, id, key, value):
"""Add new data item.
:param str id: Entry id within ``SDfile``.
:param str key: Data item key.
:param str value: Data item value.
:return: None.
:rtype: :py:obj:`None`.
"""
self[str(id)]['data'].setdefault(key, [])
... | [
"def",
"add_data",
"(",
"self",
",",
"id",
",",
"key",
",",
"value",
")",
":",
"self",
"[",
"str",
"(",
"id",
")",
"]",
"[",
"'data'",
"]",
".",
"setdefault",
"(",
"key",
",",
"[",
"]",
")",
"self",
"[",
"str",
"(",
"id",
")",
"]",
"[",
"'d... | Add new data item.
:param str id: Entry id within ``SDfile``.
:param str key: Data item key.
:param str value: Data item value.
:return: None.
:rtype: :py:obj:`None`. | [
"Add",
"new",
"data",
"item",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L791-L801 | train | Add new data item. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile.add_molfile | def add_molfile(self, molfile, data):
"""Add ``Molfile`` and data to ``SDfile`` object.
:param molfile: ``Molfile`` instance.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:param dict data: Data associated with ``Molfile`` instance.
:return: None.
:rtype: :py:obj:`Non... | python | def add_molfile(self, molfile, data):
"""Add ``Molfile`` and data to ``SDfile`` object.
:param molfile: ``Molfile`` instance.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:param dict data: Data associated with ``Molfile`` instance.
:return: None.
:rtype: :py:obj:`Non... | [
"def",
"add_molfile",
"(",
"self",
",",
"molfile",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"molfile",
",",
"Molfile",
")",
":",
"raise",
"ValueError",
"(",
"'Not a Molfile type: \"{}\"'",
".",
"format",
"(",
"type",
"(",
"molfile",
")",
")",... | Add ``Molfile`` and data to ``SDfile`` object.
:param molfile: ``Molfile`` instance.
:type molfile: :class:`~ctfile.ctfile.Molfile`.
:param dict data: Data associated with ``Molfile`` instance.
:return: None.
:rtype: :py:obj:`None`. | [
"Add",
"Molfile",
"and",
"data",
"to",
"SDfile",
"object",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L803-L827 | train | Add a Molfile and data to the SDfile object. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile.add_sdfile | def add_sdfile(self, sdfile):
"""Add new ``SDfile`` to current ``SDfile``.
:param sdfile: ``SDfile`` instance.
:return: None.
:rtype: :py:obj:`None`.
"""
if not isinstance(sdfile, SDfile):
raise ValueError('Not a SDfile type: "{}"'.format(type(sdfile)))
... | python | def add_sdfile(self, sdfile):
"""Add new ``SDfile`` to current ``SDfile``.
:param sdfile: ``SDfile`` instance.
:return: None.
:rtype: :py:obj:`None`.
"""
if not isinstance(sdfile, SDfile):
raise ValueError('Not a SDfile type: "{}"'.format(type(sdfile)))
... | [
"def",
"add_sdfile",
"(",
"self",
",",
"sdfile",
")",
":",
"if",
"not",
"isinstance",
"(",
"sdfile",
",",
"SDfile",
")",
":",
"raise",
"ValueError",
"(",
"'Not a SDfile type: \"{}\"'",
".",
"format",
"(",
"type",
"(",
"sdfile",
")",
")",
")",
"for",
"ent... | Add new ``SDfile`` to current ``SDfile``.
:param sdfile: ``SDfile`` instance.
:return: None.
:rtype: :py:obj:`None`. | [
"Add",
"new",
"SDfile",
"to",
"current",
"SDfile",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L829-L841 | train | Adds new SDfile to current SDfile instance. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile._build | def _build(self, lexer):
"""Build :class:`~ctfile.ctfile.SDfile` instance.
:return: :class:`~ctfile.ctfile.SDfile` instance.
:rtype: :class:`~ctfile.ctfile.SDfile`.
"""
current_entry_id = 0
while True:
token = next(lexer)
key = token.__class__.__... | python | def _build(self, lexer):
"""Build :class:`~ctfile.ctfile.SDfile` instance.
:return: :class:`~ctfile.ctfile.SDfile` instance.
:rtype: :class:`~ctfile.ctfile.SDfile`.
"""
current_entry_id = 0
while True:
token = next(lexer)
key = token.__class__.__... | [
"def",
"_build",
"(",
"self",
",",
"lexer",
")",
":",
"current_entry_id",
"=",
"0",
"while",
"True",
":",
"token",
"=",
"next",
"(",
"lexer",
")",
"key",
"=",
"token",
".",
"__class__",
".",
"__name__",
"if",
"key",
"==",
"'MolfileStart'",
":",
"curren... | Build :class:`~ctfile.ctfile.SDfile` instance.
:return: :class:`~ctfile.ctfile.SDfile` instance.
:rtype: :class:`~ctfile.ctfile.SDfile`. | [
"Build",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"SDfile",
"instance",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L843-L871 | train | Build the object. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile._build_data_block | def _build_data_block(self, lexer):
"""Build the data block of :class:`~ctfile.ctfile.SDfile` instance.
:return: Data block.
:rtype: :py:class:`collections.OrderedDict`.
"""
data_block = OrderedDict()
header = ''
while True:
token = next(lexer)
... | python | def _build_data_block(self, lexer):
"""Build the data block of :class:`~ctfile.ctfile.SDfile` instance.
:return: Data block.
:rtype: :py:class:`collections.OrderedDict`.
"""
data_block = OrderedDict()
header = ''
while True:
token = next(lexer)
... | [
"def",
"_build_data_block",
"(",
"self",
",",
"lexer",
")",
":",
"data_block",
"=",
"OrderedDict",
"(",
")",
"header",
"=",
"''",
"while",
"True",
":",
"token",
"=",
"next",
"(",
"lexer",
")",
"key",
"=",
"token",
".",
"__class__",
".",
"__name__",
"if... | Build the data block of :class:`~ctfile.ctfile.SDfile` instance.
:return: Data block.
:rtype: :py:class:`collections.OrderedDict`. | [
"Build",
"the",
"data",
"block",
"of",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"SDfile",
"instance",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L873-L899 | train | Build the data block of the SDfile instance. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | SDfile._to_ctfile | def _to_ctfile(self):
"""Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: ``CTfile`` formatted string.
:rtype: :py:class:`str`.
"""
output = io.StringIO()
for entry in self.values():
output.write(entry['molfile']._to_ctfile())
... | python | def _to_ctfile(self):
"""Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: ``CTfile`` formatted string.
:rtype: :py:class:`str`.
"""
output = io.StringIO()
for entry in self.values():
output.write(entry['molfile']._to_ctfile())
... | [
"def",
"_to_ctfile",
"(",
"self",
")",
":",
"output",
"=",
"io",
".",
"StringIO",
"(",
")",
"for",
"entry",
"in",
"self",
".",
"values",
"(",
")",
":",
"output",
".",
"write",
"(",
"entry",
"[",
"'molfile'",
"]",
".",
"_to_ctfile",
"(",
")",
")",
... | Convert :class:`~ctfile.ctfile.CTfile` into `CTfile` formatted string.
:return: ``CTfile`` formatted string.
:rtype: :py:class:`str`. | [
"Convert",
":",
"class",
":",
"~ctfile",
".",
"ctfile",
".",
"CTfile",
"into",
"CTfile",
"formatted",
"string",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L901-L918 | train | Convert the MoleculeFile into CTfile formatted string. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Atom.neighbor_atoms | def neighbor_atoms(self, atom_symbol=None):
"""Access neighbor atoms.
:param str atom_symbol: Atom symbol.
:return: List of neighbor atoms.
:rtype: :py:class:`list`.
"""
if not atom_symbol:
return self.neighbors
else:
return [atom for atom... | python | def neighbor_atoms(self, atom_symbol=None):
"""Access neighbor atoms.
:param str atom_symbol: Atom symbol.
:return: List of neighbor atoms.
:rtype: :py:class:`list`.
"""
if not atom_symbol:
return self.neighbors
else:
return [atom for atom... | [
"def",
"neighbor_atoms",
"(",
"self",
",",
"atom_symbol",
"=",
"None",
")",
":",
"if",
"not",
"atom_symbol",
":",
"return",
"self",
".",
"neighbors",
"else",
":",
"return",
"[",
"atom",
"for",
"atom",
"in",
"self",
".",
"neighbors",
"if",
"atom",
"[",
... | Access neighbor atoms.
:param str atom_symbol: Atom symbol.
:return: List of neighbor atoms.
:rtype: :py:class:`list`. | [
"Access",
"neighbor",
"atoms",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L983-L993 | train | Access neighbor atoms. |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | Bond.update_atom_numbers | def update_atom_numbers(self):
"""Update links "first_atom_number" -> "second_atom_number"
:return: None.
:rtype: :py:obj:`None`.
"""
self._ctab_data['first_atom_number'] = self.first_atom.atom_number
self._ctab_data['second_atom_number'] = self.second_atom.atom_number | python | def update_atom_numbers(self):
"""Update links "first_atom_number" -> "second_atom_number"
:return: None.
:rtype: :py:obj:`None`.
"""
self._ctab_data['first_atom_number'] = self.first_atom.atom_number
self._ctab_data['second_atom_number'] = self.second_atom.atom_number | [
"def",
"update_atom_numbers",
"(",
"self",
")",
":",
"self",
".",
"_ctab_data",
"[",
"'first_atom_number'",
"]",
"=",
"self",
".",
"first_atom",
".",
"atom_number",
"self",
".",
"_ctab_data",
"[",
"'second_atom_number'",
"]",
"=",
"self",
".",
"second_atom",
"... | Update links "first_atom_number" -> "second_atom_number"
:return: None.
:rtype: :py:obj:`None`. | [
"Update",
"links",
"first_atom_number",
"-",
">",
"second_atom_number"
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L1111-L1118 | train | Update links first_atom_number -> second_atom_number |
MoseleyBioinformaticsLab/ctfile | ctfile/ctfile.py | CtabAtomBondEncoder.default | def default(self, o):
"""Default encoder.
:param o: Atom or Bond instance.
:type o: :class:`~ctfile.ctfile.Atom` or :class:`~ctfile.ctfile.Bond`.
:return: Dictionary that contains information required for atom and bond block of ``Ctab``.
:rtype: :py:class:`collections.OrderedDic... | python | def default(self, o):
"""Default encoder.
:param o: Atom or Bond instance.
:type o: :class:`~ctfile.ctfile.Atom` or :class:`~ctfile.ctfile.Bond`.
:return: Dictionary that contains information required for atom and bond block of ``Ctab``.
:rtype: :py:class:`collections.OrderedDic... | [
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"Atom",
")",
"or",
"isinstance",
"(",
"o",
",",
"Bond",
")",
":",
"return",
"o",
".",
"_ctab_data",
"else",
":",
"return",
"o",
".",
"__dict__"
] | Default encoder.
:param o: Atom or Bond instance.
:type o: :class:`~ctfile.ctfile.Atom` or :class:`~ctfile.ctfile.Bond`.
:return: Dictionary that contains information required for atom and bond block of ``Ctab``.
:rtype: :py:class:`collections.OrderedDict` | [
"Default",
"encoder",
"."
] | eae864126cd9102207df5d363a3222256a0f1396 | https://github.com/MoseleyBioinformaticsLab/ctfile/blob/eae864126cd9102207df5d363a3222256a0f1396/ctfile/ctfile.py#L1144-L1155 | train | Default encoder. |
product-definition-center/pdc-client | pdc_client/config.py | ServerConfigManager.get | def get(self, server):
"""
Returns ServerConfig instance with configuration given server.
:raises ServerConfigConflictError:
if configuration directory contains configuration for same server
multiple times
:raises ServerConfigMissingUrlError: if URL is not speci... | python | def get(self, server):
"""
Returns ServerConfig instance with configuration given server.
:raises ServerConfigConflictError:
if configuration directory contains configuration for same server
multiple times
:raises ServerConfigMissingUrlError: if URL is not speci... | [
"def",
"get",
"(",
"self",
",",
"server",
")",
":",
"server_config",
"=",
"self",
".",
"config",
".",
"get",
"(",
"server",
")",
"try",
":",
"while",
"server_config",
"is",
"None",
":",
"new_config",
"=",
"self",
".",
"_read_next_config",
"(",
")",
"se... | Returns ServerConfig instance with configuration given server.
:raises ServerConfigConflictError:
if configuration directory contains configuration for same server
multiple times
:raises ServerConfigMissingUrlError: if URL is not specified in the configuration
:raises ... | [
"Returns",
"ServerConfig",
"instance",
"with",
"configuration",
"given",
"server",
"."
] | 7236fd8b72e675ebb321bbe337289d9fbeb6119f | https://github.com/product-definition-center/pdc-client/blob/7236fd8b72e675ebb321bbe337289d9fbeb6119f/pdc_client/config.py#L94-L121 | train | Returns a ServerConfig instance with configuration given server. |
chriso/gauged | gauged/structures/float_array.py | FloatArray.free | def free(self):
"""Free the underlying C array"""
if self._ptr is None:
return
Gauged.array_free(self.ptr)
FloatArray.ALLOCATIONS -= 1
self._ptr = None | python | def free(self):
"""Free the underlying C array"""
if self._ptr is None:
return
Gauged.array_free(self.ptr)
FloatArray.ALLOCATIONS -= 1
self._ptr = None | [
"def",
"free",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ptr",
"is",
"None",
":",
"return",
"Gauged",
".",
"array_free",
"(",
"self",
".",
"ptr",
")",
"FloatArray",
".",
"ALLOCATIONS",
"-=",
"1",
"self",
".",
"_ptr",
"=",
"None"
] | Free the underlying C array | [
"Free",
"the",
"underlying",
"C",
"array"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/structures/float_array.py#L59-L65 | train | Free the underlying C array. |
rhazdon/django-sonic-screwdriver | django_sonic_screwdriver/management/commands/patch.py | Command.handle | def handle(self, *args, **options):
"""
Check, how much options are true.
If option '--force', '-f' is set this part will be skipped.
"""
if not options['force']:
counter = 0
for key in options:
if options[key]:
counter... | python | def handle(self, *args, **options):
"""
Check, how much options are true.
If option '--force', '-f' is set this part will be skipped.
"""
if not options['force']:
counter = 0
for key in options:
if options[key]:
counter... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"if",
"not",
"options",
"[",
"'force'",
"]",
":",
"counter",
"=",
"0",
"for",
"key",
"in",
"options",
":",
"if",
"options",
"[",
"key",
"]",
":",
"counter",
"+=",... | Check, how much options are true.
If option '--force', '-f' is set this part will be skipped. | [
"Check",
"how",
"much",
"options",
"are",
"true",
".",
"If",
"option",
"--",
"force",
"-",
"f",
"is",
"set",
"this",
"part",
"will",
"be",
"skipped",
"."
] | 89e885e8c1322fc5c3e0f79b03a55acdc6e63972 | https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/management/commands/patch.py#L32-L86 | train | Handles the command line. |
glormph/msstitch | src/app/actions/mzidtsv/quant.py | generate_psms_quanted | def generate_psms_quanted(quantdb, tsvfn, isob_header, oldheader,
isobaric=False, precursor=False):
"""Takes dbfn and connects, gets quants for each line in tsvfn, sorts
them in line by using keys in quantheader list."""
allquants, sqlfields = quantdb.select_all_psm_quants(isobaric... | python | def generate_psms_quanted(quantdb, tsvfn, isob_header, oldheader,
isobaric=False, precursor=False):
"""Takes dbfn and connects, gets quants for each line in tsvfn, sorts
them in line by using keys in quantheader list."""
allquants, sqlfields = quantdb.select_all_psm_quants(isobaric... | [
"def",
"generate_psms_quanted",
"(",
"quantdb",
",",
"tsvfn",
",",
"isob_header",
",",
"oldheader",
",",
"isobaric",
"=",
"False",
",",
"precursor",
"=",
"False",
")",
":",
"allquants",
",",
"sqlfields",
"=",
"quantdb",
".",
"select_all_psm_quants",
"(",
"isob... | Takes dbfn and connects, gets quants for each line in tsvfn, sorts
them in line by using keys in quantheader list. | [
"Takes",
"dbfn",
"and",
"connects",
"gets",
"quants",
"for",
"each",
"line",
"in",
"tsvfn",
"sorts",
"them",
"in",
"line",
"by",
"using",
"keys",
"in",
"quantheader",
"list",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/quant.py#L5-L36 | train | Takes tsvfn and connects gets quants for each line in tsvfn sorts them by using keys in isobaric and precursor are used to get the next PSM in the list of all possible PSMs in line by using keys in oldheader. |
glormph/msstitch | src/app/actions/mzidtsv/quant.py | get_quant_NAs | def get_quant_NAs(quantdata, quantheader):
"""Takes quantdata in a dict and header with quantkeys
(eg iTRAQ isotopes). Returns dict of quant intensities
with missing keys set to NA."""
out = {}
for qkey in quantheader:
out[qkey] = quantdata.get(qkey, 'NA')
return out | python | def get_quant_NAs(quantdata, quantheader):
"""Takes quantdata in a dict and header with quantkeys
(eg iTRAQ isotopes). Returns dict of quant intensities
with missing keys set to NA."""
out = {}
for qkey in quantheader:
out[qkey] = quantdata.get(qkey, 'NA')
return out | [
"def",
"get_quant_NAs",
"(",
"quantdata",
",",
"quantheader",
")",
":",
"out",
"=",
"{",
"}",
"for",
"qkey",
"in",
"quantheader",
":",
"out",
"[",
"qkey",
"]",
"=",
"quantdata",
".",
"get",
"(",
"qkey",
",",
"'NA'",
")",
"return",
"out"
] | Takes quantdata in a dict and header with quantkeys
(eg iTRAQ isotopes). Returns dict of quant intensities
with missing keys set to NA. | [
"Takes",
"quantdata",
"in",
"a",
"dict",
"and",
"header",
"with",
"quantkeys",
"(",
"eg",
"iTRAQ",
"isotopes",
")",
".",
"Returns",
"dict",
"of",
"quant",
"intensities",
"with",
"missing",
"keys",
"set",
"to",
"NA",
"."
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/quant.py#L63-L70 | train | Takes quantdata in a dict and header with quantkeys
. Returns dict of quant intensities
with missing keys set to NA. |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_string_UNESCAPED | def t_string_UNESCAPED(self, t):
r'[\x20-\x21,\x23-\x5B,\x5D-\xFF]+'
t.value = t.value if isinstance(t.value, unicode) else unicode(t.value, encoding='utf8')
return t | python | def t_string_UNESCAPED(self, t):
r'[\x20-\x21,\x23-\x5B,\x5D-\xFF]+'
t.value = t.value if isinstance(t.value, unicode) else unicode(t.value, encoding='utf8')
return t | [
"def",
"t_string_UNESCAPED",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"value",
"=",
"t",
".",
"value",
"if",
"isinstance",
"(",
"t",
".",
"value",
",",
"unicode",
")",
"else",
"unicode",
"(",
"t",
".",
"value",
",",
"encoding",
"=",
"'utf8'",
")"... | r'[\x20-\x21,\x23-\x5B,\x5D-\xFF]+ | [
"r",
"[",
"\\",
"x20",
"-",
"\\",
"x21",
"\\",
"x23",
"-",
"\\",
"x5B",
"\\",
"x5D",
"-",
"\\",
"xFF",
"]",
"+"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L138-L141 | train | A string is a unicode string. |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_BACKSPACE_CHAR | def t_escaped_BACKSPACE_CHAR(self, t):
r'\x62' # 'b'
t.lexer.pop_state()
t.value = unichr(0x0008)
return t | python | def t_escaped_BACKSPACE_CHAR(self, t):
r'\x62' # 'b'
t.lexer.pop_state()
t.value = unichr(0x0008)
return t | [
"def",
"t_escaped_BACKSPACE_CHAR",
"(",
"self",
",",
"t",
")",
":",
"# 'b'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x0008",
")",
"return",
"t"
] | r'\x62 | [
"r",
"\\",
"x62"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L173-L177 | train | t_escaped_BACKSPACE_CHAR - Handles backspace characters. |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_FORM_FEED_CHAR | def t_escaped_FORM_FEED_CHAR(self, t):
r'\x66' # 'f'
t.lexer.pop_state()
t.value = unichr(0x000c)
return t | python | def t_escaped_FORM_FEED_CHAR(self, t):
r'\x66' # 'f'
t.lexer.pop_state()
t.value = unichr(0x000c)
return t | [
"def",
"t_escaped_FORM_FEED_CHAR",
"(",
"self",
",",
"t",
")",
":",
"# 'f'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x000c",
")",
"return",
"t"
] | r'\x66 | [
"r",
"\\",
"x66"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L179-L183 | train | Tokenize an escaped FORMFEED character. |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_CARRIAGE_RETURN_CHAR | def t_escaped_CARRIAGE_RETURN_CHAR(self, t):
r'\x72' # 'r'
t.lexer.pop_state()
t.value = unichr(0x000d)
return t | python | def t_escaped_CARRIAGE_RETURN_CHAR(self, t):
r'\x72' # 'r'
t.lexer.pop_state()
t.value = unichr(0x000d)
return t | [
"def",
"t_escaped_CARRIAGE_RETURN_CHAR",
"(",
"self",
",",
"t",
")",
":",
"# 'r'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x000d",
")",
"return",
"t"
] | r'\x72 | [
"r",
"\\",
"x72"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L185-L189 | train | r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x72 r \ x000d |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_LINE_FEED_CHAR | def t_escaped_LINE_FEED_CHAR(self, t):
r'\x6E' # 'n'
t.lexer.pop_state()
t.value = unichr(0x000a)
return t | python | def t_escaped_LINE_FEED_CHAR(self, t):
r'\x6E' # 'n'
t.lexer.pop_state()
t.value = unichr(0x000a)
return t | [
"def",
"t_escaped_LINE_FEED_CHAR",
"(",
"self",
",",
"t",
")",
":",
"# 'n'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x000a",
")",
"return",
"t"
] | r'\x6E | [
"r",
"\\",
"x6E"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L191-L195 | train | t_escaped_LINE_FEED_CHAR - Handles escaped line feed characters. |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.t_escaped_TAB_CHAR | def t_escaped_TAB_CHAR(self, t):
r'\x74' # 't'
t.lexer.pop_state()
t.value = unichr(0x0009)
return t | python | def t_escaped_TAB_CHAR(self, t):
r'\x74' # 't'
t.lexer.pop_state()
t.value = unichr(0x0009)
return t | [
"def",
"t_escaped_TAB_CHAR",
"(",
"self",
",",
"t",
")",
":",
"# 't'",
"t",
".",
"lexer",
".",
"pop_state",
"(",
")",
"t",
".",
"value",
"=",
"unichr",
"(",
"0x0009",
")",
"return",
"t"
] | r'\x74 | [
"r",
"\\",
"x74"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L197-L201 | train | t_escaped_TAB_CHAR - Handle tab characters. |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossLexer.tokenize | def tokenize(self, data, *args, **kwargs):
"""Invoke the lexer on an input string an return the list of tokens.
This is relatively inefficient and should only be used for
testing/debugging as it slurps up all tokens into one list.
Args:
data: The input to be tokenized.
... | python | def tokenize(self, data, *args, **kwargs):
"""Invoke the lexer on an input string an return the list of tokens.
This is relatively inefficient and should only be used for
testing/debugging as it slurps up all tokens into one list.
Args:
data: The input to be tokenized.
... | [
"def",
"tokenize",
"(",
"self",
",",
"data",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"lexer",
".",
"input",
"(",
"data",
")",
"tokens",
"=",
"list",
"(",
")",
"while",
"True",
":",
"token",
"=",
"self",
".",
"lexer",
"... | Invoke the lexer on an input string an return the list of tokens.
This is relatively inefficient and should only be used for
testing/debugging as it slurps up all tokens into one list.
Args:
data: The input to be tokenized.
Returns:
A list of LexTokens | [
"Invoke",
"the",
"lexer",
"on",
"an",
"input",
"string",
"an",
"return",
"the",
"list",
"of",
"tokens",
".",
"This",
"is",
"relatively",
"inefficient",
"and",
"should",
"only",
"be",
"used",
"for",
"testing",
"/",
"debugging",
"as",
"it",
"slurps",
"up",
... | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L208-L224 | train | Invoke the lexer on an input string and return the list of tokens. |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossParser.p_values | def p_values(self, p):
"""values :
| values value VALUE_SEPARATOR
| values value"""
if len(p) == 1:
p[0] = list()
else:
p[1].append(p[2])
p[0] = p[1] | python | def p_values(self, p):
"""values :
| values value VALUE_SEPARATOR
| values value"""
if len(p) == 1:
p[0] = list()
else:
p[1].append(p[2])
p[0] = p[1] | [
"def",
"p_values",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"1",
":",
"p",
"[",
"0",
"]",
"=",
"list",
"(",
")",
"else",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]... | values :
| values value VALUE_SEPARATOR
| values value | [
"values",
":",
"|",
"values",
"value",
"VALUE_SEPARATOR",
"|",
"values",
"value"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L305-L313 | train | values | values value VALUE_SEPARATOR
| values value VALUE_SEPARATOR
| values value |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossParser.p_chars | def p_chars(self, p):
"""chars :
| chars char"""
if len(p) == 1:
p[0] = unicode()
else:
p[0] = p[1] + p[2] | python | def p_chars(self, p):
"""chars :
| chars char"""
if len(p) == 1:
p[0] = unicode()
else:
p[0] = p[1] + p[2] | [
"def",
"p_chars",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"1",
":",
"p",
"[",
"0",
"]",
"=",
"unicode",
"(",
")",
"else",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"+",
"p",
"[",
"2",
"]"
] | chars :
| chars char | [
"chars",
":",
"|",
"chars",
"char"
] | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L375-L381 | train | chars | chars char |
EnigmaBridge/jbossply | jbossply/jbossparser.py | JbossParser.parse | def parse(self, data, lexer=None, *args, **kwargs):
"""Parse the input JSON data string into a python data structure.
Args:
data: An input data string
lexer: An optional ply.lex instance that overrides the default lexer.
Returns:
A python dict or list representing ... | python | def parse(self, data, lexer=None, *args, **kwargs):
"""Parse the input JSON data string into a python data structure.
Args:
data: An input data string
lexer: An optional ply.lex instance that overrides the default lexer.
Returns:
A python dict or list representing ... | [
"def",
"parse",
"(",
"self",
",",
"data",
",",
"lexer",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"lexer",
"is",
"None",
":",
"lexer",
"=",
"self",
".",
"lexer",
"return",
"self",
".",
"parser",
".",
"parse",
"(",
... | Parse the input JSON data string into a python data structure.
Args:
data: An input data string
lexer: An optional ply.lex instance that overrides the default lexer.
Returns:
A python dict or list representing the input JSON data. | [
"Parse",
"the",
"input",
"JSON",
"data",
"string",
"into",
"a",
"python",
"data",
"structure",
".",
"Args",
":",
"data",
":",
"An",
"input",
"data",
"string",
"lexer",
":",
"An",
"optional",
"ply",
".",
"lex",
"instance",
"that",
"overrides",
"the",
"def... | 44b30b15982cae781f0c356fab7263751b20b4d0 | https://github.com/EnigmaBridge/jbossply/blob/44b30b15982cae781f0c356fab7263751b20b4d0/jbossply/jbossparser.py#L409-L419 | train | Parse the input JSON data string into a python dict or list of python dicts. |
glormph/msstitch | src/app/readers/mzidplus.py | get_mzid_specfile_ids | def get_mzid_specfile_ids(mzidfn, namespace):
"""Returns mzid spectra data filenames and their IDs used in the
mzIdentML file as a dict. Keys == IDs, values == fns"""
sid_fn = {}
for specdata in mzid_specdata_generator(mzidfn, namespace):
sid_fn[specdata.attrib['id']] = specdata.attrib['name']
... | python | def get_mzid_specfile_ids(mzidfn, namespace):
"""Returns mzid spectra data filenames and their IDs used in the
mzIdentML file as a dict. Keys == IDs, values == fns"""
sid_fn = {}
for specdata in mzid_specdata_generator(mzidfn, namespace):
sid_fn[specdata.attrib['id']] = specdata.attrib['name']
... | [
"def",
"get_mzid_specfile_ids",
"(",
"mzidfn",
",",
"namespace",
")",
":",
"sid_fn",
"=",
"{",
"}",
"for",
"specdata",
"in",
"mzid_specdata_generator",
"(",
"mzidfn",
",",
"namespace",
")",
":",
"sid_fn",
"[",
"specdata",
".",
"attrib",
"[",
"'id'",
"]",
"... | Returns mzid spectra data filenames and their IDs used in the
mzIdentML file as a dict. Keys == IDs, values == fns | [
"Returns",
"mzid",
"spectra",
"data",
"filenames",
"and",
"their",
"IDs",
"used",
"in",
"the",
"mzIdentML",
"file",
"as",
"a",
"dict",
".",
"Keys",
"==",
"IDs",
"values",
"==",
"fns"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/mzidplus.py#L96-L102 | train | Returns mzid spectra data filenames and their IDs used in the
mzIdentML file as a dict. Keys == IDs values == fns |
glormph/msstitch | src/app/readers/mzidplus.py | get_specidentitem_percolator_data | def get_specidentitem_percolator_data(item, xmlns):
"""Loop through SpecIdentificationItem children. Find
percolator data by matching to a dict lookup. Return a
dict containing percolator data"""
percomap = {'{0}userParam'.format(xmlns): PERCO_HEADERMAP, }
percodata = {}
for child in item:
... | python | def get_specidentitem_percolator_data(item, xmlns):
"""Loop through SpecIdentificationItem children. Find
percolator data by matching to a dict lookup. Return a
dict containing percolator data"""
percomap = {'{0}userParam'.format(xmlns): PERCO_HEADERMAP, }
percodata = {}
for child in item:
... | [
"def",
"get_specidentitem_percolator_data",
"(",
"item",
",",
"xmlns",
")",
":",
"percomap",
"=",
"{",
"'{0}userParam'",
".",
"format",
"(",
"xmlns",
")",
":",
"PERCO_HEADERMAP",
",",
"}",
"percodata",
"=",
"{",
"}",
"for",
"child",
"in",
"item",
":",
"try... | Loop through SpecIdentificationItem children. Find
percolator data by matching to a dict lookup. Return a
dict containing percolator data | [
"Loop",
"through",
"SpecIdentificationItem",
"children",
".",
"Find",
"percolator",
"data",
"by",
"matching",
"to",
"a",
"dict",
"lookup",
".",
"Return",
"a",
"dict",
"containing",
"percolator",
"data"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/mzidplus.py#L115-L134 | train | Loop through SpecIdentificationItem children and find the percolator data by matching to a dict lookup. Return a
dict containing percolator data |
Erotemic/utool | utool/oldalg.py | bayesnet | def bayesnet():
"""
References:
https://class.coursera.org/pgm-003/lecture/17
http://www.cs.ubc.ca/~murphyk/Bayes/bnintro.html
http://www3.cs.stonybrook.edu/~sael/teaching/cse537/Slides/chapter14d_BP.pdf
http://www.cse.unsw.edu.au/~cs9417ml/Bayes/Pages/PearlPropagation.html
... | python | def bayesnet():
"""
References:
https://class.coursera.org/pgm-003/lecture/17
http://www.cs.ubc.ca/~murphyk/Bayes/bnintro.html
http://www3.cs.stonybrook.edu/~sael/teaching/cse537/Slides/chapter14d_BP.pdf
http://www.cse.unsw.edu.au/~cs9417ml/Bayes/Pages/PearlPropagation.html
... | [
"def",
"bayesnet",
"(",
")",
":",
"# import operator as op",
"# # Enumerate all possible events",
"# varcard_list = list(map(op.attrgetter('variable_card'), cpd_list))",
"# _esdat = list(ut.iprod(*map(range, varcard_list)))",
"# _escol = list(map(op.attrgetter('variable'), cpd_list))",
"# event_... | References:
https://class.coursera.org/pgm-003/lecture/17
http://www.cs.ubc.ca/~murphyk/Bayes/bnintro.html
http://www3.cs.stonybrook.edu/~sael/teaching/cse537/Slides/chapter14d_BP.pdf
http://www.cse.unsw.edu.au/~cs9417ml/Bayes/Pages/PearlPropagation.html
https://github.com/pgmpy/... | [
"References",
":",
"https",
":",
"//",
"class",
".",
"coursera",
".",
"org",
"/",
"pgm",
"-",
"003",
"/",
"lecture",
"/",
"17",
"http",
":",
"//",
"www",
".",
"cs",
".",
"ubc",
".",
"ca",
"/",
"~murphyk",
"/",
"Bayes",
"/",
"bnintro",
".",
"html"... | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/oldalg.py#L32-L384 | train | A Bayes network implementation of the Bayes algorithm. |
Erotemic/utool | utool/util_sysreq.py | in_virtual_env | def in_virtual_env():
"""
returns True if you are running inside a python virtual environment.
(DOES NOT WORK IF IN IPYTHON AND USING A VIRTUALENV)
sys.prefix gives the location of the virtualenv
Notes:
It seems IPython does not respect virtual environments properly.
TODO: find a s... | python | def in_virtual_env():
"""
returns True if you are running inside a python virtual environment.
(DOES NOT WORK IF IN IPYTHON AND USING A VIRTUALENV)
sys.prefix gives the location of the virtualenv
Notes:
It seems IPython does not respect virtual environments properly.
TODO: find a s... | [
"def",
"in_virtual_env",
"(",
")",
":",
"import",
"sys",
"has_venv",
"=",
"False",
"if",
"hasattr",
"(",
"sys",
",",
"'real_prefix'",
")",
":",
"# For virtualenv module",
"has_venv",
"=",
"True",
"elif",
"hasattr",
"(",
"sys",
",",
"'base_prefix'",
")",
":",... | returns True if you are running inside a python virtual environment.
(DOES NOT WORK IF IN IPYTHON AND USING A VIRTUALENV)
sys.prefix gives the location of the virtualenv
Notes:
It seems IPython does not respect virtual environments properly.
TODO: find a solution
http://stackoverfl... | [
"returns",
"True",
"if",
"you",
"are",
"running",
"inside",
"a",
"python",
"virtual",
"environment",
".",
"(",
"DOES",
"NOT",
"WORK",
"IF",
"IN",
"IPYTHON",
"AND",
"USING",
"A",
"VIRTUALENV",
")"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sysreq.py#L11-L44 | train | Returns True if you are running inside a python virtual environment. |
Erotemic/utool | utool/util_sysreq.py | get_global_dist_packages_dir | def get_global_dist_packages_dir():
"""
Attempts to work around virtualenvs and find the system dist_pacakges.
Essentially this is implmenented as a lookuptable
"""
import utool as ut
if not ut.in_virtual_env():
# Non venv case
return get_site_packages_dir()
else:
can... | python | def get_global_dist_packages_dir():
"""
Attempts to work around virtualenvs and find the system dist_pacakges.
Essentially this is implmenented as a lookuptable
"""
import utool as ut
if not ut.in_virtual_env():
# Non venv case
return get_site_packages_dir()
else:
can... | [
"def",
"get_global_dist_packages_dir",
"(",
")",
":",
"import",
"utool",
"as",
"ut",
"if",
"not",
"ut",
".",
"in_virtual_env",
"(",
")",
":",
"# Non venv case",
"return",
"get_site_packages_dir",
"(",
")",
"else",
":",
"candidates",
"=",
"[",
"]",
"if",
"ut"... | Attempts to work around virtualenvs and find the system dist_pacakges.
Essentially this is implmenented as a lookuptable | [
"Attempts",
"to",
"work",
"around",
"virtualenvs",
"and",
"find",
"the",
"system",
"dist_pacakges",
".",
"Essentially",
"this",
"is",
"implmenented",
"as",
"a",
"lookuptable"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sysreq.py#L61-L82 | train | Returns the path to the dist - packages directory for the current environment |
Erotemic/utool | utool/util_sysreq.py | get_local_dist_packages_dir | def get_local_dist_packages_dir():
"""
Attempts to work around virtualenvs and find the system dist_pacakges.
Essentially this is implmenented as a lookuptable
"""
import utool as ut
if not ut.in_virtual_env():
# Non venv case
return get_site_packages_dir()
else:
cand... | python | def get_local_dist_packages_dir():
"""
Attempts to work around virtualenvs and find the system dist_pacakges.
Essentially this is implmenented as a lookuptable
"""
import utool as ut
if not ut.in_virtual_env():
# Non venv case
return get_site_packages_dir()
else:
cand... | [
"def",
"get_local_dist_packages_dir",
"(",
")",
":",
"import",
"utool",
"as",
"ut",
"if",
"not",
"ut",
".",
"in_virtual_env",
"(",
")",
":",
"# Non venv case",
"return",
"get_site_packages_dir",
"(",
")",
"else",
":",
"candidates",
"=",
"[",
"]",
"if",
"ut",... | Attempts to work around virtualenvs and find the system dist_pacakges.
Essentially this is implmenented as a lookuptable | [
"Attempts",
"to",
"work",
"around",
"virtualenvs",
"and",
"find",
"the",
"system",
"dist_pacakges",
".",
"Essentially",
"this",
"is",
"implmenented",
"as",
"a",
"lookuptable"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sysreq.py#L85-L104 | train | Returns the path to the dist - packages directory for the current site |
Erotemic/utool | utool/util_sysreq.py | locate_path | def locate_path(dname, recurse_down=True):
""" Search for a path """
tried_fpaths = []
root_dir = os.getcwd()
while root_dir is not None:
dpath = join(root_dir, dname)
if exists(dpath):
return dpath
else:
tried_fpaths.append(dpath)
_new_root = dirn... | python | def locate_path(dname, recurse_down=True):
""" Search for a path """
tried_fpaths = []
root_dir = os.getcwd()
while root_dir is not None:
dpath = join(root_dir, dname)
if exists(dpath):
return dpath
else:
tried_fpaths.append(dpath)
_new_root = dirn... | [
"def",
"locate_path",
"(",
"dname",
",",
"recurse_down",
"=",
"True",
")",
":",
"tried_fpaths",
"=",
"[",
"]",
"root_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"while",
"root_dir",
"is",
"not",
"None",
":",
"dpath",
"=",
"join",
"(",
"root_dir",
",",
... | Search for a path | [
"Search",
"for",
"a",
"path"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sysreq.py#L116-L137 | train | Find the path to a resource in the current directory. |
Erotemic/utool | utool/util_sysreq.py | total_purge_developed_repo | def total_purge_developed_repo(repodir):
r"""
Outputs commands to help purge a repo
Args:
repodir (str): path to developed repository
CommandLine:
python -m utool.util_sysreq total_purge_installed_repo --show
Ignore:
repodir = ut.truepath('~/code/Lasagne')
Example:
... | python | def total_purge_developed_repo(repodir):
r"""
Outputs commands to help purge a repo
Args:
repodir (str): path to developed repository
CommandLine:
python -m utool.util_sysreq total_purge_installed_repo --show
Ignore:
repodir = ut.truepath('~/code/Lasagne')
Example:
... | [
"def",
"total_purge_developed_repo",
"(",
"repodir",
")",
":",
"assert",
"repodir",
"is",
"not",
"None",
"import",
"utool",
"as",
"ut",
"import",
"os",
"repo",
"=",
"ut",
".",
"util_git",
".",
"Repo",
"(",
"dpath",
"=",
"repodir",
")",
"user",
"=",
"os",... | r"""
Outputs commands to help purge a repo
Args:
repodir (str): path to developed repository
CommandLine:
python -m utool.util_sysreq total_purge_installed_repo --show
Ignore:
repodir = ut.truepath('~/code/Lasagne')
Example:
>>> # DISABLE_DOCTEST
>>> from ... | [
"r",
"Outputs",
"commands",
"to",
"help",
"purge",
"a",
"repo"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_sysreq.py#L151-L244 | train | r Purges all developed packages in a repository |
Erotemic/utool | utool/DynamicStruct.py | DynStruct.add_dict | def add_dict(self, dyn_dict):
'Adds a dictionary to the prefs'
if not isinstance(dyn_dict, dict):
raise Exception('DynStruct.add_dict expects a dictionary.' +
'Recieved: ' + six.text_type(type(dyn_dict)))
for (key, val) in six.iteritems(dyn_dict):
... | python | def add_dict(self, dyn_dict):
'Adds a dictionary to the prefs'
if not isinstance(dyn_dict, dict):
raise Exception('DynStruct.add_dict expects a dictionary.' +
'Recieved: ' + six.text_type(type(dyn_dict)))
for (key, val) in six.iteritems(dyn_dict):
... | [
"def",
"add_dict",
"(",
"self",
",",
"dyn_dict",
")",
":",
"if",
"not",
"isinstance",
"(",
"dyn_dict",
",",
"dict",
")",
":",
"raise",
"Exception",
"(",
"'DynStruct.add_dict expects a dictionary.'",
"+",
"'Recieved: '",
"+",
"six",
".",
"text_type",
"(",
"type... | Adds a dictionary to the prefs | [
"Adds",
"a",
"dictionary",
"to",
"the",
"prefs"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/DynamicStruct.py#L52-L58 | train | Adds a dictionary to the prefs |
Erotemic/utool | utool/DynamicStruct.py | DynStruct.to_dict | def to_dict(self):
"""Converts dynstruct to a dictionary. """
dyn_dict = {}
for (key, val) in six.iteritems(self.__dict__):
if key not in self._printable_exclude:
dyn_dict[key] = val
return dyn_dict | python | def to_dict(self):
"""Converts dynstruct to a dictionary. """
dyn_dict = {}
for (key, val) in six.iteritems(self.__dict__):
if key not in self._printable_exclude:
dyn_dict[key] = val
return dyn_dict | [
"def",
"to_dict",
"(",
"self",
")",
":",
"dyn_dict",
"=",
"{",
"}",
"for",
"(",
"key",
",",
"val",
")",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"__dict__",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_printable_exclude",
":",
"dyn_di... | Converts dynstruct to a dictionary. | [
"Converts",
"dynstruct",
"to",
"a",
"dictionary",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/DynamicStruct.py#L60-L66 | train | Converts the object to a dictionary. |
Erotemic/utool | utool/DynamicStruct.py | DynStruct.execstr | def execstr(self, local_name):
"""returns a string which when evaluated will
add the stored variables to the current namespace
localname is the name of the variable in the current scope
* use locals().update(dyn.to_dict()) instead
"""
execstr = ''
for (k... | python | def execstr(self, local_name):
"""returns a string which when evaluated will
add the stored variables to the current namespace
localname is the name of the variable in the current scope
* use locals().update(dyn.to_dict()) instead
"""
execstr = ''
for (k... | [
"def",
"execstr",
"(",
"self",
",",
"local_name",
")",
":",
"execstr",
"=",
"''",
"for",
"(",
"key",
",",
"val",
")",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"__dict__",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_printable_exclude",
... | returns a string which when evaluated will
add the stored variables to the current namespace
localname is the name of the variable in the current scope
* use locals().update(dyn.to_dict()) instead | [
"returns",
"a",
"string",
"which",
"when",
"evaluated",
"will",
"add",
"the",
"stored",
"variables",
"to",
"the",
"current",
"namespace"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/DynamicStruct.py#L88-L99 | train | returns a string which when evaluated will
add the stored variables to the current namespace
localname is the name of the variable in the current scope
|
glormph/msstitch | src/app/lookups/sqlite/proteingroups.py | ProteinGroupDB.get_proteins_for_peptide | def get_proteins_for_peptide(self, psm_id):
"""Returns list of proteins for a passed psm_id"""
protsql = self.get_sql_select(['protein_acc'], 'protein_psm')
protsql = '{0} WHERE psm_id=?'.format(protsql)
cursor = self.get_cursor()
proteins = cursor.execute(protsql, psm_id).fetcha... | python | def get_proteins_for_peptide(self, psm_id):
"""Returns list of proteins for a passed psm_id"""
protsql = self.get_sql_select(['protein_acc'], 'protein_psm')
protsql = '{0} WHERE psm_id=?'.format(protsql)
cursor = self.get_cursor()
proteins = cursor.execute(protsql, psm_id).fetcha... | [
"def",
"get_proteins_for_peptide",
"(",
"self",
",",
"psm_id",
")",
":",
"protsql",
"=",
"self",
".",
"get_sql_select",
"(",
"[",
"'protein_acc'",
"]",
",",
"'protein_psm'",
")",
"protsql",
"=",
"'{0} WHERE psm_id=?'",
".",
"format",
"(",
"protsql",
")",
"curs... | Returns list of proteins for a passed psm_id | [
"Returns",
"list",
"of",
"proteins",
"for",
"a",
"passed",
"psm_id"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/proteingroups.py#L79-L85 | train | Returns a list of proteins for a passed psm_id |
rhazdon/django-sonic-screwdriver | django_sonic_screwdriver/management/commands/git:tag.py | Command.handle | def handle(self, *args, **options):
"""
:param args:
:param options:
:return:
"""
counter = 0
for key in options:
if options[key]:
counter += 1
# If no options are set, do a normal patch
if counter == 1:
opt... | python | def handle(self, *args, **options):
"""
:param args:
:param options:
:return:
"""
counter = 0
for key in options:
if options[key]:
counter += 1
# If no options are set, do a normal patch
if counter == 1:
opt... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"counter",
"=",
"0",
"for",
"key",
"in",
"options",
":",
"if",
"options",
"[",
"key",
"]",
":",
"counter",
"+=",
"1",
"# If no options are set, do a normal patch",
"if",
... | :param args:
:param options:
:return: | [
":",
"param",
"args",
":",
":",
"param",
"options",
":",
":",
"return",
":"
] | 89e885e8c1322fc5c3e0f79b03a55acdc6e63972 | https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/management/commands/git:tag.py#L22-L55 | train | Handles the command line arguments and options. |
flyte/xbee-helper | xbee_helper/device.py | raise_if_error | def raise_if_error(frame):
"""
Checks a frame and raises the relevant exception if required.
"""
if "status" not in frame or frame["status"] == b"\x00":
return
codes_and_exceptions = {
b"\x01": exceptions.ZigBeeUnknownError,
b"\x02": exceptions.ZigBeeInvalidCommand,
b... | python | def raise_if_error(frame):
"""
Checks a frame and raises the relevant exception if required.
"""
if "status" not in frame or frame["status"] == b"\x00":
return
codes_and_exceptions = {
b"\x01": exceptions.ZigBeeUnknownError,
b"\x02": exceptions.ZigBeeInvalidCommand,
b... | [
"def",
"raise_if_error",
"(",
"frame",
")",
":",
"if",
"\"status\"",
"not",
"in",
"frame",
"or",
"frame",
"[",
"\"status\"",
"]",
"==",
"b\"\\x00\"",
":",
"return",
"codes_and_exceptions",
"=",
"{",
"b\"\\x01\"",
":",
"exceptions",
".",
"ZigBeeUnknownError",
"... | Checks a frame and raises the relevant exception if required. | [
"Checks",
"a",
"frame",
"and",
"raises",
"the",
"relevant",
"exception",
"if",
"required",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L25-L39 | train | Checks a frame and raises the relevant exception if required. |
flyte/xbee-helper | xbee_helper/device.py | hex_to_int | def hex_to_int(value):
"""
Convert hex string like "\x0A\xE3" to 2787.
"""
if version_info.major >= 3:
return int.from_bytes(value, "big")
return int(value.encode("hex"), 16) | python | def hex_to_int(value):
"""
Convert hex string like "\x0A\xE3" to 2787.
"""
if version_info.major >= 3:
return int.from_bytes(value, "big")
return int(value.encode("hex"), 16) | [
"def",
"hex_to_int",
"(",
"value",
")",
":",
"if",
"version_info",
".",
"major",
">=",
"3",
":",
"return",
"int",
".",
"from_bytes",
"(",
"value",
",",
"\"big\"",
")",
"return",
"int",
"(",
"value",
".",
"encode",
"(",
"\"hex\"",
")",
",",
"16",
")"
... | Convert hex string like "\x0A\xE3" to 2787. | [
"Convert",
"hex",
"string",
"like",
"\\",
"x0A",
"\\",
"xE3",
"to",
"2787",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L42-L48 | train | Convert hex string like \ x0A \ xxE3 to 2787. |
flyte/xbee-helper | xbee_helper/device.py | adc_to_percentage | def adc_to_percentage(value, max_volts, clamp=True):
"""
Convert the ADC raw value to a percentage.
"""
percentage = (100.0 / const.ADC_MAX_VAL) * value
return max(min(100, percentage), 0) if clamp else percentage | python | def adc_to_percentage(value, max_volts, clamp=True):
"""
Convert the ADC raw value to a percentage.
"""
percentage = (100.0 / const.ADC_MAX_VAL) * value
return max(min(100, percentage), 0) if clamp else percentage | [
"def",
"adc_to_percentage",
"(",
"value",
",",
"max_volts",
",",
"clamp",
"=",
"True",
")",
":",
"percentage",
"=",
"(",
"100.0",
"/",
"const",
".",
"ADC_MAX_VAL",
")",
"*",
"value",
"return",
"max",
"(",
"min",
"(",
"100",
",",
"percentage",
")",
",",... | Convert the ADC raw value to a percentage. | [
"Convert",
"the",
"ADC",
"raw",
"value",
"to",
"a",
"percentage",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L51-L56 | train | Convert the ADC raw value to a percentage. |
flyte/xbee-helper | xbee_helper/device.py | convert_adc | def convert_adc(value, output_type, max_volts):
"""
Converts the output from the ADC into the desired type.
"""
return {
const.ADC_RAW: lambda x: x,
const.ADC_PERCENTAGE: adc_to_percentage,
const.ADC_VOLTS: adc_to_volts,
const.ADC_MILLIVOLTS: adc_to_millivolts
}[outpu... | python | def convert_adc(value, output_type, max_volts):
"""
Converts the output from the ADC into the desired type.
"""
return {
const.ADC_RAW: lambda x: x,
const.ADC_PERCENTAGE: adc_to_percentage,
const.ADC_VOLTS: adc_to_volts,
const.ADC_MILLIVOLTS: adc_to_millivolts
}[outpu... | [
"def",
"convert_adc",
"(",
"value",
",",
"output_type",
",",
"max_volts",
")",
":",
"return",
"{",
"const",
".",
"ADC_RAW",
":",
"lambda",
"x",
":",
"x",
",",
"const",
".",
"ADC_PERCENTAGE",
":",
"adc_to_percentage",
",",
"const",
".",
"ADC_VOLTS",
":",
... | Converts the output from the ADC into the desired type. | [
"Converts",
"the",
"output",
"from",
"the",
"ADC",
"into",
"the",
"desired",
"type",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L73-L82 | train | Converts the output from the ADC into the desired type. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.next_frame_id | def next_frame_id(self):
"""
Gets a byte of the next valid frame ID (1 - 255), increments the
internal _frame_id counter and wraps it back to 1 if necessary.
"""
# Python 2/3 compatible way of converting 1 to "\x01" in py2 or b"\x01"
# in py3.
fid = bytes(bytearra... | python | def next_frame_id(self):
"""
Gets a byte of the next valid frame ID (1 - 255), increments the
internal _frame_id counter and wraps it back to 1 if necessary.
"""
# Python 2/3 compatible way of converting 1 to "\x01" in py2 or b"\x01"
# in py3.
fid = bytes(bytearra... | [
"def",
"next_frame_id",
"(",
"self",
")",
":",
"# Python 2/3 compatible way of converting 1 to \"\\x01\" in py2 or b\"\\x01\"",
"# in py3.",
"fid",
"=",
"bytes",
"(",
"bytearray",
"(",
"(",
"self",
".",
"_frame_id",
",",
")",
")",
")",
"self",
".",
"_frame_id",
"+="... | Gets a byte of the next valid frame ID (1 - 255), increments the
internal _frame_id counter and wraps it back to 1 if necessary. | [
"Gets",
"a",
"byte",
"of",
"the",
"next",
"valid",
"frame",
"ID",
"(",
"1",
"-",
"255",
")",
"increments",
"the",
"internal",
"_frame_id",
"counter",
"and",
"wraps",
"it",
"back",
"to",
"1",
"if",
"necessary",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L105-L120 | train | Gets a byte of the next valid frame ID. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee._frame_received | def _frame_received(self, frame):
"""
Put the frame into the _rx_frames dict with a key of the frame_id.
"""
try:
self._rx_frames[frame["frame_id"]] = frame
except KeyError:
# Has no frame_id, ignore?
pass
_LOGGER.debug("Frame received:... | python | def _frame_received(self, frame):
"""
Put the frame into the _rx_frames dict with a key of the frame_id.
"""
try:
self._rx_frames[frame["frame_id"]] = frame
except KeyError:
# Has no frame_id, ignore?
pass
_LOGGER.debug("Frame received:... | [
"def",
"_frame_received",
"(",
"self",
",",
"frame",
")",
":",
"try",
":",
"self",
".",
"_rx_frames",
"[",
"frame",
"[",
"\"frame_id\"",
"]",
"]",
"=",
"frame",
"except",
"KeyError",
":",
"# Has no frame_id, ignore?",
"pass",
"_LOGGER",
".",
"debug",
"(",
... | Put the frame into the _rx_frames dict with a key of the frame_id. | [
"Put",
"the",
"frame",
"into",
"the",
"_rx_frames",
"dict",
"with",
"a",
"key",
"of",
"the",
"frame_id",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L122-L134 | train | Handle a received frame. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee._send | def _send(self, **kwargs):
"""
Send a frame to either the local ZigBee or a remote device.
"""
if kwargs.get("dest_addr_long") is not None:
self.zb.remote_at(**kwargs)
else:
self.zb.at(**kwargs) | python | def _send(self, **kwargs):
"""
Send a frame to either the local ZigBee or a remote device.
"""
if kwargs.get("dest_addr_long") is not None:
self.zb.remote_at(**kwargs)
else:
self.zb.at(**kwargs) | [
"def",
"_send",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"\"dest_addr_long\"",
")",
"is",
"not",
"None",
":",
"self",
".",
"zb",
".",
"remote_at",
"(",
"*",
"*",
"kwargs",
")",
"else",
":",
"self",
".",
"zb... | Send a frame to either the local ZigBee or a remote device. | [
"Send",
"a",
"frame",
"to",
"either",
"the",
"local",
"ZigBee",
"or",
"a",
"remote",
"device",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L136-L143 | train | Send a frame to either the local ZigBee or a remote device. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee._send_and_wait | def _send_and_wait(self, **kwargs):
"""
Send a frame to either the local ZigBee or a remote device and wait
for a pre-defined amount of time for its response.
"""
frame_id = self.next_frame_id
kwargs.update(dict(frame_id=frame_id))
self._send(**kwargs)
tim... | python | def _send_and_wait(self, **kwargs):
"""
Send a frame to either the local ZigBee or a remote device and wait
for a pre-defined amount of time for its response.
"""
frame_id = self.next_frame_id
kwargs.update(dict(frame_id=frame_id))
self._send(**kwargs)
tim... | [
"def",
"_send_and_wait",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"frame_id",
"=",
"self",
".",
"next_frame_id",
"kwargs",
".",
"update",
"(",
"dict",
"(",
"frame_id",
"=",
"frame_id",
")",
")",
"self",
".",
"_send",
"(",
"*",
"*",
"kwargs",
"... | Send a frame to either the local ZigBee or a remote device and wait
for a pre-defined amount of time for its response. | [
"Send",
"a",
"frame",
"to",
"either",
"the",
"local",
"ZigBee",
"or",
"a",
"remote",
"device",
"and",
"wait",
"for",
"a",
"pre",
"-",
"defined",
"amount",
"of",
"time",
"for",
"its",
"response",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L145-L164 | train | Send a frame to either the local ZigBee or a remote device and wait for its response. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee._get_parameter | def _get_parameter(self, parameter, dest_addr_long=None):
"""
Fetches and returns the value of the specified parameter.
"""
frame = self._send_and_wait(
command=parameter, dest_addr_long=dest_addr_long)
return frame["parameter"] | python | def _get_parameter(self, parameter, dest_addr_long=None):
"""
Fetches and returns the value of the specified parameter.
"""
frame = self._send_and_wait(
command=parameter, dest_addr_long=dest_addr_long)
return frame["parameter"] | [
"def",
"_get_parameter",
"(",
"self",
",",
"parameter",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"frame",
"=",
"self",
".",
"_send_and_wait",
"(",
"command",
"=",
"parameter",
",",
"dest_addr_long",
"=",
"dest_addr_long",
")",
"return",
"frame",
"[",
"\... | Fetches and returns the value of the specified parameter. | [
"Fetches",
"and",
"returns",
"the",
"value",
"of",
"the",
"specified",
"parameter",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L166-L172 | train | Fetches and returns the value of the specified parameter. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.get_sample | def get_sample(self, dest_addr_long=None):
"""
Initiate a sample and return its data.
"""
frame = self._send_and_wait(
command=b"IS", dest_addr_long=dest_addr_long)
if "parameter" in frame:
# @TODO: Is there always one value? Is it always a list?
... | python | def get_sample(self, dest_addr_long=None):
"""
Initiate a sample and return its data.
"""
frame = self._send_and_wait(
command=b"IS", dest_addr_long=dest_addr_long)
if "parameter" in frame:
# @TODO: Is there always one value? Is it always a list?
... | [
"def",
"get_sample",
"(",
"self",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"frame",
"=",
"self",
".",
"_send_and_wait",
"(",
"command",
"=",
"b\"IS\"",
",",
"dest_addr_long",
"=",
"dest_addr_long",
")",
"if",
"\"parameter\"",
"in",
"frame",
":",
"# @TOD... | Initiate a sample and return its data. | [
"Initiate",
"a",
"sample",
"and",
"return",
"its",
"data",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L188-L197 | train | Initiate a sample and return its data. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.read_digital_pin | def read_digital_pin(self, pin_number, dest_addr_long=None):
"""
Fetches a sample and returns the boolean value of the requested digital
pin.
"""
sample = self.get_sample(dest_addr_long=dest_addr_long)
try:
return sample[const.DIGITAL_PINS[pin_number]]
... | python | def read_digital_pin(self, pin_number, dest_addr_long=None):
"""
Fetches a sample and returns the boolean value of the requested digital
pin.
"""
sample = self.get_sample(dest_addr_long=dest_addr_long)
try:
return sample[const.DIGITAL_PINS[pin_number]]
... | [
"def",
"read_digital_pin",
"(",
"self",
",",
"pin_number",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"sample",
"=",
"self",
".",
"get_sample",
"(",
"dest_addr_long",
"=",
"dest_addr_long",
")",
"try",
":",
"return",
"sample",
"[",
"const",
".",
"DIGITAL_... | Fetches a sample and returns the boolean value of the requested digital
pin. | [
"Fetches",
"a",
"sample",
"and",
"returns",
"the",
"boolean",
"value",
"of",
"the",
"requested",
"digital",
"pin",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L199-L210 | train | Reads a digital pin from the ZigBee and returns the boolean value of the requested digital facility. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.read_analog_pin | def read_analog_pin(
self, pin_number, adc_max_volts,
dest_addr_long=None, output_type=const.ADC_RAW):
"""
Fetches a sample and returns the integer value of the requested analog
pin. output_type should be one of the following constants from
xbee_helper.const:
... | python | def read_analog_pin(
self, pin_number, adc_max_volts,
dest_addr_long=None, output_type=const.ADC_RAW):
"""
Fetches a sample and returns the integer value of the requested analog
pin. output_type should be one of the following constants from
xbee_helper.const:
... | [
"def",
"read_analog_pin",
"(",
"self",
",",
"pin_number",
",",
"adc_max_volts",
",",
"dest_addr_long",
"=",
"None",
",",
"output_type",
"=",
"const",
".",
"ADC_RAW",
")",
":",
"sample",
"=",
"self",
".",
"get_sample",
"(",
"dest_addr_long",
"=",
"dest_addr_lon... | Fetches a sample and returns the integer value of the requested analog
pin. output_type should be one of the following constants from
xbee_helper.const:
- ADC_RAW
- ADC_PERCENTAGE
- ADC_VOLTS
- ADC_MILLIVOLTS | [
"Fetches",
"a",
"sample",
"and",
"returns",
"the",
"integer",
"value",
"of",
"the",
"requested",
"analog",
"pin",
".",
"output_type",
"should",
"be",
"one",
"of",
"the",
"following",
"constants",
"from",
"xbee_helper",
".",
"const",
":"
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L212-L235 | train | Reads an analog entry from the ZigBee and returns the value of the requested analog entry. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.set_gpio_pin | def set_gpio_pin(self, pin_number, setting, dest_addr_long=None):
"""
Set a gpio pin setting.
"""
assert setting in const.GPIO_SETTINGS.values()
self._send_and_wait(
command=const.IO_PIN_COMMANDS[pin_number],
parameter=setting.value,
dest_addr_... | python | def set_gpio_pin(self, pin_number, setting, dest_addr_long=None):
"""
Set a gpio pin setting.
"""
assert setting in const.GPIO_SETTINGS.values()
self._send_and_wait(
command=const.IO_PIN_COMMANDS[pin_number],
parameter=setting.value,
dest_addr_... | [
"def",
"set_gpio_pin",
"(",
"self",
",",
"pin_number",
",",
"setting",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"assert",
"setting",
"in",
"const",
".",
"GPIO_SETTINGS",
".",
"values",
"(",
")",
"self",
".",
"_send_and_wait",
"(",
"command",
"=",
"con... | Set a gpio pin setting. | [
"Set",
"a",
"gpio",
"pin",
"setting",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L237-L245 | train | Set a gpio pin setting. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.get_gpio_pin | def get_gpio_pin(self, pin_number, dest_addr_long=None):
"""
Get a gpio pin setting.
"""
frame = self._send_and_wait(
command=const.IO_PIN_COMMANDS[pin_number],
dest_addr_long=dest_addr_long
)
value = frame["parameter"]
return const.GPIO_SE... | python | def get_gpio_pin(self, pin_number, dest_addr_long=None):
"""
Get a gpio pin setting.
"""
frame = self._send_and_wait(
command=const.IO_PIN_COMMANDS[pin_number],
dest_addr_long=dest_addr_long
)
value = frame["parameter"]
return const.GPIO_SE... | [
"def",
"get_gpio_pin",
"(",
"self",
",",
"pin_number",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"frame",
"=",
"self",
".",
"_send_and_wait",
"(",
"command",
"=",
"const",
".",
"IO_PIN_COMMANDS",
"[",
"pin_number",
"]",
",",
"dest_addr_long",
"=",
"dest_... | Get a gpio pin setting. | [
"Get",
"a",
"gpio",
"pin",
"setting",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L247-L256 | train | Get a gpio pin setting. |
flyte/xbee-helper | xbee_helper/device.py | ZigBee.get_supply_voltage | def get_supply_voltage(self, dest_addr_long=None):
"""
Fetches the value of %V and returns it as volts.
"""
value = self._get_parameter(b"%V", dest_addr_long=dest_addr_long)
return (hex_to_int(value) * (1200/1024.0)) / 1000 | python | def get_supply_voltage(self, dest_addr_long=None):
"""
Fetches the value of %V and returns it as volts.
"""
value = self._get_parameter(b"%V", dest_addr_long=dest_addr_long)
return (hex_to_int(value) * (1200/1024.0)) / 1000 | [
"def",
"get_supply_voltage",
"(",
"self",
",",
"dest_addr_long",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"_get_parameter",
"(",
"b\"%V\"",
",",
"dest_addr_long",
"=",
"dest_addr_long",
")",
"return",
"(",
"hex_to_int",
"(",
"value",
")",
"*",
"(",
... | Fetches the value of %V and returns it as volts. | [
"Fetches",
"the",
"value",
"of",
"%V",
"and",
"returns",
"it",
"as",
"volts",
"."
] | 8b47675ad44d8a57defea459682d129379af348d | https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L258-L263 | train | Retrieves the supply voltage from the resource. |
Erotemic/utool | utool/util_set.py | OrderedSet.add | def add(self, key):
""" Store new key in a new link at the end of the linked list """
if key not in self._map:
self._map[key] = link = _Link()
root = self._root
last = root.prev
link.prev, link.next, link.key = last, root, key
last.next = root.... | python | def add(self, key):
""" Store new key in a new link at the end of the linked list """
if key not in self._map:
self._map[key] = link = _Link()
root = self._root
last = root.prev
link.prev, link.next, link.key = last, root, key
last.next = root.... | [
"def",
"add",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_map",
":",
"self",
".",
"_map",
"[",
"key",
"]",
"=",
"link",
"=",
"_Link",
"(",
")",
"root",
"=",
"self",
".",
"_root",
"last",
"=",
"root",
".",
"prev... | Store new key in a new link at the end of the linked list | [
"Store",
"new",
"key",
"in",
"a",
"new",
"link",
"at",
"the",
"end",
"of",
"the",
"linked",
"list"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_set.py#L43-L50 | train | Store new key in a new link at the end of the linked list. |
Erotemic/utool | utool/util_set.py | OrderedSet.union | def union(cls, *sets):
"""
>>> from utool.util_set import * # NOQA
"""
import utool as ut
lists_ = ut.flatten([list(s) for s in sets])
return cls(lists_) | python | def union(cls, *sets):
"""
>>> from utool.util_set import * # NOQA
"""
import utool as ut
lists_ = ut.flatten([list(s) for s in sets])
return cls(lists_) | [
"def",
"union",
"(",
"cls",
",",
"*",
"sets",
")",
":",
"import",
"utool",
"as",
"ut",
"lists_",
"=",
"ut",
".",
"flatten",
"(",
"[",
"list",
"(",
"s",
")",
"for",
"s",
"in",
"sets",
"]",
")",
"return",
"cls",
"(",
"lists_",
")"
] | >>> from utool.util_set import * # NOQA | [
">>>",
"from",
"utool",
".",
"util_set",
"import",
"*",
"#",
"NOQA"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_set.py#L98-L104 | train | Return a new set with the union of sets. |
Erotemic/utool | utool/util_set.py | OrderedSet.index | def index(self, item):
"""
Find the index of `item` in the OrderedSet
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
>>> self = ut.oset([1, 2, 3])
>>> assert self.index(1) == 0
>>> assert self.index(2) == 1
>>> assert... | python | def index(self, item):
"""
Find the index of `item` in the OrderedSet
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
>>> self = ut.oset([1, 2, 3])
>>> assert self.index(1) == 0
>>> assert self.index(2) == 1
>>> assert... | [
"def",
"index",
"(",
"self",
",",
"item",
")",
":",
"for",
"count",
",",
"other",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"item",
"==",
"other",
":",
"return",
"count",
"raise",
"ValueError",
"(",
"'%r is not in OrderedSet'",
"%",
"(",
"item",
... | Find the index of `item` in the OrderedSet
Example:
>>> # ENABLE_DOCTEST
>>> import utool as ut
>>> self = ut.oset([1, 2, 3])
>>> assert self.index(1) == 0
>>> assert self.index(2) == 1
>>> assert self.index(3) == 2
>>> ut.asse... | [
"Find",
"the",
"index",
"of",
"item",
"in",
"the",
"OrderedSet"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_set.py#L138-L154 | train | Find the index of item in the OrderedSet |
chriso/gauged | gauged/gauged.py | Gauged.value | def value(self, key, timestamp=None, namespace=None):
"""Get the value of a gauge at the specified time"""
return self.make_context(key=key, end=timestamp,
namespace=namespace).value() | python | def value(self, key, timestamp=None, namespace=None):
"""Get the value of a gauge at the specified time"""
return self.make_context(key=key, end=timestamp,
namespace=namespace).value() | [
"def",
"value",
"(",
"self",
",",
"key",
",",
"timestamp",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"key",
"=",
"key",
",",
"end",
"=",
"timestamp",
",",
"namespace",
"=",
"namespace",
")",
"."... | Get the value of a gauge at the specified time | [
"Get",
"the",
"value",
"of",
"a",
"gauge",
"at",
"the",
"specified",
"time"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L68-L71 | train | Get the value of a gauge at the specified time |
chriso/gauged | gauged/gauged.py | Gauged.aggregate | def aggregate(self, key, aggregate, start=None, end=None,
namespace=None, percentile=None):
"""Get an aggregate of all gauge data stored in the specified date
range"""
return self.make_context(key=key, aggregate=aggregate, start=start,
end=end, ... | python | def aggregate(self, key, aggregate, start=None, end=None,
namespace=None, percentile=None):
"""Get an aggregate of all gauge data stored in the specified date
range"""
return self.make_context(key=key, aggregate=aggregate, start=start,
end=end, ... | [
"def",
"aggregate",
"(",
"self",
",",
"key",
",",
"aggregate",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"percentile",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"key",
"=",
"key",... | Get an aggregate of all gauge data stored in the specified date
range | [
"Get",
"an",
"aggregate",
"of",
"all",
"gauge",
"data",
"stored",
"in",
"the",
"specified",
"date",
"range"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L73-L79 | train | Get an aggregate of all gauge data stored in the specified date
range |
chriso/gauged | gauged/gauged.py | Gauged.value_series | def value_series(self, key, start=None, end=None, interval=None,
namespace=None, cache=None):
"""Get a time series of gauge values"""
return self.make_context(key=key, start=start, end=end,
interval=interval, namespace=namespace,
... | python | def value_series(self, key, start=None, end=None, interval=None,
namespace=None, cache=None):
"""Get a time series of gauge values"""
return self.make_context(key=key, start=start, end=end,
interval=interval, namespace=namespace,
... | [
"def",
"value_series",
"(",
"self",
",",
"key",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"interval",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"cache",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"key",
... | Get a time series of gauge values | [
"Get",
"a",
"time",
"series",
"of",
"gauge",
"values"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L81-L86 | train | Get a time series of gauge values |
chriso/gauged | gauged/gauged.py | Gauged.aggregate_series | def aggregate_series(self, key, aggregate, start=None, end=None,
interval=None, namespace=None, cache=None,
percentile=None):
"""Get a time series of gauge aggregates"""
return self.make_context(key=key, aggregate=aggregate, start=start,
... | python | def aggregate_series(self, key, aggregate, start=None, end=None,
interval=None, namespace=None, cache=None,
percentile=None):
"""Get a time series of gauge aggregates"""
return self.make_context(key=key, aggregate=aggregate, start=start,
... | [
"def",
"aggregate_series",
"(",
"self",
",",
"key",
",",
"aggregate",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"interval",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"cache",
"=",
"None",
",",
"percentile",
"=",
"None",
")",
":"... | Get a time series of gauge aggregates | [
"Get",
"a",
"time",
"series",
"of",
"gauge",
"aggregates"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L88-L95 | train | Get a time series of gauge aggregates |
chriso/gauged | gauged/gauged.py | Gauged.keys | def keys(self, prefix=None, limit=None, offset=None, namespace=None):
"""Get gauge keys"""
return self.make_context(prefix=prefix, limit=limit, offset=offset,
namespace=namespace).keys() | python | def keys(self, prefix=None, limit=None, offset=None, namespace=None):
"""Get gauge keys"""
return self.make_context(prefix=prefix, limit=limit, offset=offset,
namespace=namespace).keys() | [
"def",
"keys",
"(",
"self",
",",
"prefix",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"prefix",
"=",
"prefix",
",",
"limit",
"=",
"limit",
... | Get gauge keys | [
"Get",
"gauge",
"keys"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L97-L100 | train | Get gauge keys |
chriso/gauged | gauged/gauged.py | Gauged.statistics | def statistics(self, start=None, end=None, namespace=None):
"""Get write statistics for the specified namespace and date range"""
return self.make_context(start=start, end=end,
namespace=namespace).statistics() | python | def statistics(self, start=None, end=None, namespace=None):
"""Get write statistics for the specified namespace and date range"""
return self.make_context(start=start, end=end,
namespace=namespace).statistics() | [
"def",
"statistics",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"return",
"self",
".",
"make_context",
"(",
"start",
"=",
"start",
",",
"end",
"=",
"end",
",",
"namespace",
"=",
"namespac... | Get write statistics for the specified namespace and date range | [
"Get",
"write",
"statistics",
"for",
"the",
"specified",
"namespace",
"and",
"date",
"range"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L106-L109 | train | Get write statistics for the specified namespace and date range |
chriso/gauged | gauged/gauged.py | Gauged.sync | def sync(self):
"""Create the necessary schema"""
self.driver.create_schema()
self.driver.set_metadata({
'current_version': Gauged.VERSION,
'initial_version': Gauged.VERSION,
'block_size': self.config.block_size,
'resolution': self.config.resolutio... | python | def sync(self):
"""Create the necessary schema"""
self.driver.create_schema()
self.driver.set_metadata({
'current_version': Gauged.VERSION,
'initial_version': Gauged.VERSION,
'block_size': self.config.block_size,
'resolution': self.config.resolutio... | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
".",
"driver",
".",
"create_schema",
"(",
")",
"self",
".",
"driver",
".",
"set_metadata",
"(",
"{",
"'current_version'",
":",
"Gauged",
".",
"VERSION",
",",
"'initial_version'",
":",
"Gauged",
".",
"VERSION",
... | Create the necessary schema | [
"Create",
"the",
"necessary",
"schema"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L111-L120 | train | Sync the schema of the current version of the gauged instance. |
chriso/gauged | gauged/gauged.py | Gauged.make_context | def make_context(self, **kwargs):
"""Create a new context for reading data"""
self.check_schema()
return Context(self.driver, self.config, **kwargs) | python | def make_context(self, **kwargs):
"""Create a new context for reading data"""
self.check_schema()
return Context(self.driver, self.config, **kwargs) | [
"def",
"make_context",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"check_schema",
"(",
")",
"return",
"Context",
"(",
"self",
".",
"driver",
",",
"self",
".",
"config",
",",
"*",
"*",
"kwargs",
")"
] | Create a new context for reading data | [
"Create",
"a",
"new",
"context",
"for",
"reading",
"data"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L130-L133 | train | Create a new context for reading data |
chriso/gauged | gauged/gauged.py | Gauged.check_schema | def check_schema(self):
"""Check the schema exists and matches configuration"""
if self.valid_schema:
return
config = self.config
metadata = self.metadata()
if 'current_version' not in metadata:
raise GaugedSchemaError('Gauged schema not found, '
... | python | def check_schema(self):
"""Check the schema exists and matches configuration"""
if self.valid_schema:
return
config = self.config
metadata = self.metadata()
if 'current_version' not in metadata:
raise GaugedSchemaError('Gauged schema not found, '
... | [
"def",
"check_schema",
"(",
"self",
")",
":",
"if",
"self",
".",
"valid_schema",
":",
"return",
"config",
"=",
"self",
".",
"config",
"metadata",
"=",
"self",
".",
"metadata",
"(",
")",
"if",
"'current_version'",
"not",
"in",
"metadata",
":",
"raise",
"G... | Check the schema exists and matches configuration | [
"Check",
"the",
"schema",
"exists",
"and",
"matches",
"configuration"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/gauged.py#L135-L154 | train | Check the schema exists and matches the configuration |
Erotemic/utool | utool/util_graph.py | nx_topsort_rank | def nx_topsort_rank(graph, nodes=None):
"""
graph = inputs.exi_graph.reverse()
nodes = flat_node_order_
"""
import utool as ut
if False:
# Determenistic version
# Ok, this doesn't work.
dag_ranks = nx_dag_node_rank(graph, nodes)
toprank = ut.argsort(dag_ranks, lis... | python | def nx_topsort_rank(graph, nodes=None):
"""
graph = inputs.exi_graph.reverse()
nodes = flat_node_order_
"""
import utool as ut
if False:
# Determenistic version
# Ok, this doesn't work.
dag_ranks = nx_dag_node_rank(graph, nodes)
toprank = ut.argsort(dag_ranks, lis... | [
"def",
"nx_topsort_rank",
"(",
"graph",
",",
"nodes",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"if",
"False",
":",
"# Determenistic version",
"# Ok, this doesn't work.",
"dag_ranks",
"=",
"nx_dag_node_rank",
"(",
"graph",
",",
"nodes",
")",
"toprank... | graph = inputs.exi_graph.reverse()
nodes = flat_node_order_ | [
"graph",
"=",
"inputs",
".",
"exi_graph",
".",
"reverse",
"()",
"nodes",
"=",
"flat_node_order_"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L28-L46 | train | Topological sort of a node - ranked list of nodes |
Erotemic/utool | utool/util_graph.py | nx_transitive_reduction | def nx_transitive_reduction(G, mode=1):
"""
References:
https://en.wikipedia.org/wiki/Transitive_reduction#Computing_the_reduction_using_the_closure
http://dept-info.labri.fr/~thibault/tmp/0201008.pdf
http://stackoverflow.com/questions/17078696/transitive-reduction-of-directed-graph-in-p... | python | def nx_transitive_reduction(G, mode=1):
"""
References:
https://en.wikipedia.org/wiki/Transitive_reduction#Computing_the_reduction_using_the_closure
http://dept-info.labri.fr/~thibault/tmp/0201008.pdf
http://stackoverflow.com/questions/17078696/transitive-reduction-of-directed-graph-in-p... | [
"def",
"nx_transitive_reduction",
"(",
"G",
",",
"mode",
"=",
"1",
")",
":",
"import",
"utool",
"as",
"ut",
"has_cycles",
"=",
"not",
"nx",
".",
"is_directed_acyclic_graph",
"(",
"G",
")",
"if",
"has_cycles",
":",
"# FIXME: this does not work for cycle graphs.",
... | References:
https://en.wikipedia.org/wiki/Transitive_reduction#Computing_the_reduction_using_the_closure
http://dept-info.labri.fr/~thibault/tmp/0201008.pdf
http://stackoverflow.com/questions/17078696/transitive-reduction-of-directed-graph-in-python
CommandLine:
python -m utool.util... | [
"References",
":",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Transitive_reduction#Computing_the_reduction_using_the_closure",
"http",
":",
"//",
"dept",
"-",
"info",
".",
"labri",
".",
"fr",
"/",
"~thibault",
"/",
"tmp",
"/",
... | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L75-L199 | train | This function is a simple test graph that uses the transitive closure of the graph G and returns a list of the unique identifiers for the current node. |
Erotemic/utool | utool/util_graph.py | nx_dag_node_rank | def nx_dag_node_rank(graph, nodes=None):
"""
Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plot... | python | def nx_dag_node_rank(graph, nodes=None):
"""
Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plot... | [
"def",
"nx_dag_node_rank",
"(",
"graph",
",",
"nodes",
"=",
"None",
")",
":",
"import",
"utool",
"as",
"ut",
"source",
"=",
"list",
"(",
"ut",
".",
"nx_source_nodes",
"(",
"graph",
")",
")",
"[",
"0",
"]",
"longest_paths",
"=",
"dict",
"(",
"[",
"(",... | Returns rank of nodes that define the "level" each node is on in a
topological sort. This is the same as the Graphviz dot rank.
Ignore:
simple_graph = ut.simplify_graph(exi_graph)
adj_dict = ut.nx_to_adj_dict(simple_graph)
import plottool as pt
pt.qt4ensure()
pt.show_nx(... | [
"Returns",
"rank",
"of",
"nodes",
"that",
"define",
"the",
"level",
"each",
"node",
"is",
"on",
"in",
"a",
"topological",
"sort",
".",
"This",
"is",
"the",
"same",
"as",
"the",
"Graphviz",
"dot",
"rank",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L243-L278 | train | Returns rank of nodes that define the level each node is on in a
|
Erotemic/utool | utool/util_graph.py | nx_all_nodes_between | def nx_all_nodes_between(graph, source, target, data=False):
"""
Find all nodes with on paths between source and target.
"""
import utool as ut
if source is None:
# assume there is a single source
sources = list(ut.nx_source_nodes(graph))
assert len(sources) == 1, (
... | python | def nx_all_nodes_between(graph, source, target, data=False):
"""
Find all nodes with on paths between source and target.
"""
import utool as ut
if source is None:
# assume there is a single source
sources = list(ut.nx_source_nodes(graph))
assert len(sources) == 1, (
... | [
"def",
"nx_all_nodes_between",
"(",
"graph",
",",
"source",
",",
"target",
",",
"data",
"=",
"False",
")",
":",
"import",
"utool",
"as",
"ut",
"if",
"source",
"is",
"None",
":",
"# assume there is a single source",
"sources",
"=",
"list",
"(",
"ut",
".",
"... | Find all nodes with on paths between source and target. | [
"Find",
"all",
"nodes",
"with",
"on",
"paths",
"between",
"source",
"and",
"target",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L281-L300 | train | Find all nodes with on paths between source and target. |
Erotemic/utool | utool/util_graph.py | nx_all_simple_edge_paths | def nx_all_simple_edge_paths(G, source, target, cutoff=None, keys=False,
data=False):
"""
Returns each path from source to target as a list of edges.
This function is meant to be used with MultiGraphs or MultiDiGraphs.
When ``keys`` is True each edge in the path is returned... | python | def nx_all_simple_edge_paths(G, source, target, cutoff=None, keys=False,
data=False):
"""
Returns each path from source to target as a list of edges.
This function is meant to be used with MultiGraphs or MultiDiGraphs.
When ``keys`` is True each edge in the path is returned... | [
"def",
"nx_all_simple_edge_paths",
"(",
"G",
",",
"source",
",",
"target",
",",
"cutoff",
"=",
"None",
",",
"keys",
"=",
"False",
",",
"data",
"=",
"False",
")",
":",
"if",
"cutoff",
"is",
"None",
":",
"cutoff",
"=",
"len",
"(",
"G",
")",
"-",
"1",... | Returns each path from source to target as a list of edges.
This function is meant to be used with MultiGraphs or MultiDiGraphs.
When ``keys`` is True each edge in the path is returned with its unique key
identifier. In this case it is possible to distinguish between different
paths along different edg... | [
"Returns",
"each",
"path",
"from",
"source",
"to",
"target",
"as",
"a",
"list",
"of",
"edges",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L303-L351 | train | Returns a list of all simple edge paths from source to target. |
Erotemic/utool | utool/util_graph.py | nx_edges_between | def nx_edges_between(graph, nodes1, nodes2=None, assume_disjoint=False,
assume_sparse=True):
r"""
Get edges between two components or within a single component
Args:
graph (nx.Graph): the graph
nodes1 (set): list of nodes
nodes2 (set): (default=None) if None it ... | python | def nx_edges_between(graph, nodes1, nodes2=None, assume_disjoint=False,
assume_sparse=True):
r"""
Get edges between two components or within a single component
Args:
graph (nx.Graph): the graph
nodes1 (set): list of nodes
nodes2 (set): (default=None) if None it ... | [
"def",
"nx_edges_between",
"(",
"graph",
",",
"nodes1",
",",
"nodes2",
"=",
"None",
",",
"assume_disjoint",
"=",
"False",
",",
"assume_sparse",
"=",
"True",
")",
":",
"if",
"assume_sparse",
":",
"# Method 1 is where we check the intersection of existing edges",
"# and... | r"""
Get edges between two components or within a single component
Args:
graph (nx.Graph): the graph
nodes1 (set): list of nodes
nodes2 (set): (default=None) if None it is equivlanet to nodes2=nodes1
assume_disjoint (bool): skips expensive check to ensure edges arnt
... | [
"r",
"Get",
"edges",
"between",
"two",
"components",
"or",
"within",
"a",
"single",
"component"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L354-L558 | train | r Returns the edges between two nodes or within a single component |
Erotemic/utool | utool/util_graph.py | nx_delete_node_attr | def nx_delete_node_attr(graph, name, nodes=None):
"""
Removes node attributes
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_node_attributes(G, name='foo', values='bar')
>>> datas = nx.get_node_att... | python | def nx_delete_node_attr(graph, name, nodes=None):
"""
Removes node attributes
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_node_attributes(G, name='foo', values='bar')
>>> datas = nx.get_node_att... | [
"def",
"nx_delete_node_attr",
"(",
"graph",
",",
"name",
",",
"nodes",
"=",
"None",
")",
":",
"if",
"nodes",
"is",
"None",
":",
"nodes",
"=",
"list",
"(",
"graph",
".",
"nodes",
"(",
")",
")",
"removed",
"=",
"0",
"# names = [name] if not isinstance(name, ... | Removes node attributes
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_node_attributes(G, name='foo', values='bar')
>>> datas = nx.get_node_attributes(G, 'club')
>>> assert len(nx.get_node_attribut... | [
"Removes",
"node",
"attributes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L561-L601 | train | Removes node attributes from the given node graph |
Erotemic/utool | utool/util_graph.py | nx_delete_edge_attr | def nx_delete_edge_attr(graph, name, edges=None):
"""
Removes an attributes from specific edges in the graph
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_edge_attributes(G, name='spam', values='eggs')
... | python | def nx_delete_edge_attr(graph, name, edges=None):
"""
Removes an attributes from specific edges in the graph
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_edge_attributes(G, name='spam', values='eggs')
... | [
"def",
"nx_delete_edge_attr",
"(",
"graph",
",",
"name",
",",
"edges",
"=",
"None",
")",
":",
"removed",
"=",
"0",
"keys",
"=",
"[",
"name",
"]",
"if",
"not",
"isinstance",
"(",
"name",
",",
"(",
"list",
",",
"tuple",
")",
")",
"else",
"name",
"if"... | Removes an attributes from specific edges in the graph
Doctest:
>>> from utool.util_graph import * # NOQA
>>> import utool as ut
>>> G = nx.karate_club_graph()
>>> nx.set_edge_attributes(G, name='spam', values='eggs')
>>> nx.set_edge_attributes(G, name='foo', values='bar')
... | [
"Removes",
"an",
"attributes",
"from",
"specific",
"edges",
"in",
"the",
"graph"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L605-L663 | train | Removes an attribute from specific edges in a graph |
Erotemic/utool | utool/util_graph.py | nx_gen_node_values | def nx_gen_node_values(G, key, nodes, default=util_const.NoParam):
"""
Generates attributes values of specific nodes
"""
node_dict = nx_node_dict(G)
if default is util_const.NoParam:
return (node_dict[n][key] for n in nodes)
else:
return (node_dict[n].get(key, default) for n in n... | python | def nx_gen_node_values(G, key, nodes, default=util_const.NoParam):
"""
Generates attributes values of specific nodes
"""
node_dict = nx_node_dict(G)
if default is util_const.NoParam:
return (node_dict[n][key] for n in nodes)
else:
return (node_dict[n].get(key, default) for n in n... | [
"def",
"nx_gen_node_values",
"(",
"G",
",",
"key",
",",
"nodes",
",",
"default",
"=",
"util_const",
".",
"NoParam",
")",
":",
"node_dict",
"=",
"nx_node_dict",
"(",
"G",
")",
"if",
"default",
"is",
"util_const",
".",
"NoParam",
":",
"return",
"(",
"node_... | Generates attributes values of specific nodes | [
"Generates",
"attributes",
"values",
"of",
"specific",
"nodes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L748-L756 | train | Generates attributes values of specific nodes |
Erotemic/utool | utool/util_graph.py | nx_gen_node_attrs | def nx_gen_node_attrs(G, key, nodes=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Improved generator version of nx.get_node_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', ... | python | def nx_gen_node_attrs(G, key, nodes=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Improved generator version of nx.get_node_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', ... | [
"def",
"nx_gen_node_attrs",
"(",
"G",
",",
"key",
",",
"nodes",
"=",
"None",
",",
"default",
"=",
"util_const",
".",
"NoParam",
",",
"on_missing",
"=",
"'error'",
",",
"on_keyerr",
"=",
"'default'",
")",
":",
"if",
"on_missing",
"is",
"None",
":",
"on_mi... | Improved generator version of nx.get_node_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', 'filter'}. defaults to 'error'.
on_keyerr (str): Strategy for handling keys missing from node dicts.
Can be {'error', 'defaul... | [
"Improved",
"generator",
"version",
"of",
"nx",
".",
"get_node_attributes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L759-L877 | train | This function generates node attributes from a networkx graph. |
Erotemic/utool | utool/util_graph.py | nx_gen_edge_values | def nx_gen_edge_values(G, key, edges=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Generates attributes values of specific edges
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default'}. def... | python | def nx_gen_edge_values(G, key, edges=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Generates attributes values of specific edges
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default'}. def... | [
"def",
"nx_gen_edge_values",
"(",
"G",
",",
"key",
",",
"edges",
"=",
"None",
",",
"default",
"=",
"util_const",
".",
"NoParam",
",",
"on_missing",
"=",
"'error'",
",",
"on_keyerr",
"=",
"'default'",
")",
":",
"if",
"edges",
"is",
"None",
":",
"edges",
... | Generates attributes values of specific edges
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default'}. defaults to 'error'.
on_keyerr (str): Strategy for handling keys missing from node dicts.
Can be {'error', 'default'}. defaults to... | [
"Generates",
"attributes",
"values",
"of",
"specific",
"edges"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L880-L916 | train | Generate edge values of specific nodes and attributes of specific nodes. |
Erotemic/utool | utool/util_graph.py | nx_gen_edge_attrs | def nx_gen_edge_attrs(G, key, edges=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Improved generator version of nx.get_edge_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', ... | python | def nx_gen_edge_attrs(G, key, edges=None, default=util_const.NoParam,
on_missing='error', on_keyerr='default'):
"""
Improved generator version of nx.get_edge_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', ... | [
"def",
"nx_gen_edge_attrs",
"(",
"G",
",",
"key",
",",
"edges",
"=",
"None",
",",
"default",
"=",
"util_const",
".",
"NoParam",
",",
"on_missing",
"=",
"'error'",
",",
"on_keyerr",
"=",
"'default'",
")",
":",
"if",
"on_missing",
"is",
"None",
":",
"on_mi... | Improved generator version of nx.get_edge_attributes
Args:
on_missing (str): Strategy for handling nodes missing from G.
Can be {'error', 'default', 'filter'}. defaults to 'error'.
is on_missing is not error, then we allow any edge even if the
endpoints are not in the g... | [
"Improved",
"generator",
"version",
"of",
"nx",
".",
"get_edge_attributes"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L923-L989 | train | This function generates edge attributes for a node in a network. |
Erotemic/utool | utool/util_graph.py | nx_minimum_weight_component | def nx_minimum_weight_component(graph, weight='weight'):
""" A minimum weight component is an MST + all negative edges """
mwc = nx.minimum_spanning_tree(graph, weight=weight)
# negative edges only reduce the total weight
neg_edges = (e for e, w in nx_gen_edge_attrs(graph, weight) if w < 0)
mwc.add_... | python | def nx_minimum_weight_component(graph, weight='weight'):
""" A minimum weight component is an MST + all negative edges """
mwc = nx.minimum_spanning_tree(graph, weight=weight)
# negative edges only reduce the total weight
neg_edges = (e for e, w in nx_gen_edge_attrs(graph, weight) if w < 0)
mwc.add_... | [
"def",
"nx_minimum_weight_component",
"(",
"graph",
",",
"weight",
"=",
"'weight'",
")",
":",
"mwc",
"=",
"nx",
".",
"minimum_spanning_tree",
"(",
"graph",
",",
"weight",
"=",
"weight",
")",
"# negative edges only reduce the total weight",
"neg_edges",
"=",
"(",
"... | A minimum weight component is an MST + all negative edges | [
"A",
"minimum",
"weight",
"component",
"is",
"an",
"MST",
"+",
"all",
"negative",
"edges"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1037-L1043 | train | A minimum weight component is an MST + all negative edges |
Erotemic/utool | utool/util_graph.py | nx_ensure_agraph_color | def nx_ensure_agraph_color(graph):
""" changes colors to hex strings on graph attrs """
from plottool import color_funcs
import plottool as pt
#import six
def _fix_agraph_color(data):
try:
orig_color = data.get('color', None)
alpha = data.get('alpha', None)
... | python | def nx_ensure_agraph_color(graph):
""" changes colors to hex strings on graph attrs """
from plottool import color_funcs
import plottool as pt
#import six
def _fix_agraph_color(data):
try:
orig_color = data.get('color', None)
alpha = data.get('alpha', None)
... | [
"def",
"nx_ensure_agraph_color",
"(",
"graph",
")",
":",
"from",
"plottool",
"import",
"color_funcs",
"import",
"plottool",
"as",
"pt",
"#import six",
"def",
"_fix_agraph_color",
"(",
"data",
")",
":",
"try",
":",
"orig_color",
"=",
"data",
".",
"get",
"(",
... | changes colors to hex strings on graph attrs | [
"changes",
"colors",
"to",
"hex",
"strings",
"on",
"graph",
"attrs"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_graph.py#L1075-L1113 | train | ensure colors to hex strings on graph attrs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.