repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
zhanglab/psamm | psamm/datasource/native.py | ModelReader.reader_from_path | def reader_from_path(cls, path):
"""Create a model from specified path.
Path can be a directory containing a ``model.yaml`` or ``model.yml``
file or it can be a path naming the central model file directly.
"""
context = FilePathContext(path)
try:
with open(co... | python | def reader_from_path(cls, path):
"""Create a model from specified path.
Path can be a directory containing a ``model.yaml`` or ``model.yml``
file or it can be a path naming the central model file directly.
"""
context = FilePathContext(path)
try:
with open(co... | [
"def",
"reader_from_path",
"(",
"cls",
",",
"path",
")",
":",
"context",
"=",
"FilePathContext",
"(",
"path",
")",
"try",
":",
"with",
"open",
"(",
"context",
".",
"filepath",
",",
"'r'",
")",
"as",
"f",
":",
"return",
"ModelReader",
"(",
"f",
",",
"... | Create a model from specified path.
Path can be a directory containing a ``model.yaml`` or ``model.yml``
file or it can be a path naming the central model file directly. | [
"Create",
"a",
"model",
"from",
"specified",
"path",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L180-L204 | train | 65,200 |
zhanglab/psamm | psamm/datasource/native.py | ModelReader.parse_compartments | def parse_compartments(self):
"""Parse compartment information from model.
Return tuple of: 1) iterator of
:class:`psamm.datasource.entry.CompartmentEntry`; 2) Set of pairs
defining the compartment boundaries of the model.
"""
compartments = OrderedDict()
bounda... | python | def parse_compartments(self):
"""Parse compartment information from model.
Return tuple of: 1) iterator of
:class:`psamm.datasource.entry.CompartmentEntry`; 2) Set of pairs
defining the compartment boundaries of the model.
"""
compartments = OrderedDict()
bounda... | [
"def",
"parse_compartments",
"(",
"self",
")",
":",
"compartments",
"=",
"OrderedDict",
"(",
")",
"boundaries",
"=",
"set",
"(",
")",
"if",
"'compartments'",
"in",
"self",
".",
"_model",
":",
"boundary_map",
"=",
"{",
"}",
"for",
"compartment_def",
"in",
"... | Parse compartment information from model.
Return tuple of: 1) iterator of
:class:`psamm.datasource.entry.CompartmentEntry`; 2) Set of pairs
defining the compartment boundaries of the model. | [
"Parse",
"compartment",
"information",
"from",
"model",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L244-L287 | train | 65,201 |
zhanglab/psamm | psamm/datasource/native.py | ModelReader.parse_reactions | def parse_reactions(self):
"""Yield tuples of reaction ID and reactions defined in the model"""
# Parse reactions defined in the main model file
if 'reactions' in self._model:
for reaction in parse_reaction_list(
self._context, self._model['reactions'],
... | python | def parse_reactions(self):
"""Yield tuples of reaction ID and reactions defined in the model"""
# Parse reactions defined in the main model file
if 'reactions' in self._model:
for reaction in parse_reaction_list(
self._context, self._model['reactions'],
... | [
"def",
"parse_reactions",
"(",
"self",
")",
":",
"# Parse reactions defined in the main model file",
"if",
"'reactions'",
"in",
"self",
".",
"_model",
":",
"for",
"reaction",
"in",
"parse_reaction_list",
"(",
"self",
".",
"_context",
",",
"self",
".",
"_model",
"[... | Yield tuples of reaction ID and reactions defined in the model | [
"Yield",
"tuples",
"of",
"reaction",
"ID",
"and",
"reactions",
"defined",
"in",
"the",
"model"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L289-L297 | train | 65,202 |
zhanglab/psamm | psamm/datasource/native.py | ModelReader.parse_model | def parse_model(self):
"""Yield reaction IDs of model reactions"""
if self.has_model_definition():
for reaction_id in parse_model_group_list(
self._context, self._model['model']):
yield reaction_id | python | def parse_model(self):
"""Yield reaction IDs of model reactions"""
if self.has_model_definition():
for reaction_id in parse_model_group_list(
self._context, self._model['model']):
yield reaction_id | [
"def",
"parse_model",
"(",
"self",
")",
":",
"if",
"self",
".",
"has_model_definition",
"(",
")",
":",
"for",
"reaction_id",
"in",
"parse_model_group_list",
"(",
"self",
".",
"_context",
",",
"self",
".",
"_model",
"[",
"'model'",
"]",
")",
":",
"yield",
... | Yield reaction IDs of model reactions | [
"Yield",
"reaction",
"IDs",
"of",
"model",
"reactions"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L303-L309 | train | 65,203 |
zhanglab/psamm | psamm/datasource/native.py | ModelReader.parse_limits | def parse_limits(self):
"""Yield tuples of reaction ID, lower, and upper bound flux limits"""
if 'limits' in self._model:
if not isinstance(self._model['limits'], list):
raise ParseError('Expected limits to be a list')
for limit in parse_limits_list(
... | python | def parse_limits(self):
"""Yield tuples of reaction ID, lower, and upper bound flux limits"""
if 'limits' in self._model:
if not isinstance(self._model['limits'], list):
raise ParseError('Expected limits to be a list')
for limit in parse_limits_list(
... | [
"def",
"parse_limits",
"(",
"self",
")",
":",
"if",
"'limits'",
"in",
"self",
".",
"_model",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"_model",
"[",
"'limits'",
"]",
",",
"list",
")",
":",
"raise",
"ParseError",
"(",
"'Expected limits to be a list... | Yield tuples of reaction ID, lower, and upper bound flux limits | [
"Yield",
"tuples",
"of",
"reaction",
"ID",
"lower",
"and",
"upper",
"bound",
"flux",
"limits"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L311-L320 | train | 65,204 |
zhanglab/psamm | psamm/datasource/native.py | ModelReader.parse_exchange | def parse_exchange(self):
"""Yield tuples of exchange compounds.
Each exchange compound is a tuple of compound, reaction ID, lower and
upper flux limits.
"""
if 'media' in self._model:
if 'exchange' in self._model:
raise ParseError('Both "media" and ... | python | def parse_exchange(self):
"""Yield tuples of exchange compounds.
Each exchange compound is a tuple of compound, reaction ID, lower and
upper flux limits.
"""
if 'media' in self._model:
if 'exchange' in self._model:
raise ParseError('Both "media" and ... | [
"def",
"parse_exchange",
"(",
"self",
")",
":",
"if",
"'media'",
"in",
"self",
".",
"_model",
":",
"if",
"'exchange'",
"in",
"self",
".",
"_model",
":",
"raise",
"ParseError",
"(",
"'Both \"media\" and \"exchange\" are specified'",
")",
"logger",
".",
"warning",... | Yield tuples of exchange compounds.
Each exchange compound is a tuple of compound, reaction ID, lower and
upper flux limits. | [
"Yield",
"tuples",
"of",
"exchange",
"compounds",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L322-L349 | train | 65,205 |
zhanglab/psamm | psamm/datasource/native.py | ModelReader.parse_compounds | def parse_compounds(self):
"""Yield CompoundEntries for defined compounds"""
if 'compounds' in self._model:
for compound in parse_compound_list(
self._context, self._model['compounds']):
yield compound | python | def parse_compounds(self):
"""Yield CompoundEntries for defined compounds"""
if 'compounds' in self._model:
for compound in parse_compound_list(
self._context, self._model['compounds']):
yield compound | [
"def",
"parse_compounds",
"(",
"self",
")",
":",
"if",
"'compounds'",
"in",
"self",
".",
"_model",
":",
"for",
"compound",
"in",
"parse_compound_list",
"(",
"self",
".",
"_context",
",",
"self",
".",
"_model",
"[",
"'compounds'",
"]",
")",
":",
"yield",
... | Yield CompoundEntries for defined compounds | [
"Yield",
"CompoundEntries",
"for",
"defined",
"compounds"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L358-L364 | train | 65,206 |
zhanglab/psamm | psamm/datasource/native.py | ModelWriter.convert_compartment_entry | def convert_compartment_entry(self, compartment, adjacencies):
"""Convert compartment entry to YAML dict.
Args:
compartment: :class:`psamm.datasource.entry.CompartmentEntry`.
adjacencies: Sequence of IDs or a single ID of adjacent
compartments (or None).
... | python | def convert_compartment_entry(self, compartment, adjacencies):
"""Convert compartment entry to YAML dict.
Args:
compartment: :class:`psamm.datasource.entry.CompartmentEntry`.
adjacencies: Sequence of IDs or a single ID of adjacent
compartments (or None).
... | [
"def",
"convert_compartment_entry",
"(",
"self",
",",
"compartment",
",",
"adjacencies",
")",
":",
"d",
"=",
"OrderedDict",
"(",
")",
"d",
"[",
"'id'",
"]",
"=",
"compartment",
".",
"id",
"if",
"adjacencies",
"is",
"not",
"None",
":",
"d",
"[",
"'adjacen... | Convert compartment entry to YAML dict.
Args:
compartment: :class:`psamm.datasource.entry.CompartmentEntry`.
adjacencies: Sequence of IDs or a single ID of adjacent
compartments (or None). | [
"Convert",
"compartment",
"entry",
"to",
"YAML",
"dict",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1369-L1389 | train | 65,207 |
zhanglab/psamm | psamm/datasource/native.py | ModelWriter.convert_compound_entry | def convert_compound_entry(self, compound):
"""Convert compound entry to YAML dict."""
d = OrderedDict()
d['id'] = compound.id
order = {
key: i for i, key in enumerate(
['name', 'formula', 'formula_neutral', 'charge', 'kegg',
'cas'])}
... | python | def convert_compound_entry(self, compound):
"""Convert compound entry to YAML dict."""
d = OrderedDict()
d['id'] = compound.id
order = {
key: i for i, key in enumerate(
['name', 'formula', 'formula_neutral', 'charge', 'kegg',
'cas'])}
... | [
"def",
"convert_compound_entry",
"(",
"self",
",",
"compound",
")",
":",
"d",
"=",
"OrderedDict",
"(",
")",
"d",
"[",
"'id'",
"]",
"=",
"compound",
".",
"id",
"order",
"=",
"{",
"key",
":",
"i",
"for",
"i",
",",
"key",
"in",
"enumerate",
"(",
"[",
... | Convert compound entry to YAML dict. | [
"Convert",
"compound",
"entry",
"to",
"YAML",
"dict",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1391-L1407 | train | 65,208 |
zhanglab/psamm | psamm/datasource/native.py | ModelWriter.convert_reaction_entry | def convert_reaction_entry(self, reaction):
"""Convert reaction entry to YAML dict."""
d = OrderedDict()
d['id'] = reaction.id
def is_equation_valid(equation):
# If the equation is a Reaction object, it must have non-zero
# number of compounds.
return... | python | def convert_reaction_entry(self, reaction):
"""Convert reaction entry to YAML dict."""
d = OrderedDict()
d['id'] = reaction.id
def is_equation_valid(equation):
# If the equation is a Reaction object, it must have non-zero
# number of compounds.
return... | [
"def",
"convert_reaction_entry",
"(",
"self",
",",
"reaction",
")",
":",
"d",
"=",
"OrderedDict",
"(",
")",
"d",
"[",
"'id'",
"]",
"=",
"reaction",
".",
"id",
"def",
"is_equation_valid",
"(",
"equation",
")",
":",
"# If the equation is a Reaction object, it must... | Convert reaction entry to YAML dict. | [
"Convert",
"reaction",
"entry",
"to",
"YAML",
"dict",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1409-L1433 | train | 65,209 |
zhanglab/psamm | psamm/datasource/native.py | ModelWriter._write_entries | def _write_entries(self, stream, entries, converter, properties=None):
"""Write iterable of entries as YAML object to stream.
Args:
stream: File-like object.
entries: Iterable of entries.
converter: Conversion function from entry to YAML object.
propertie... | python | def _write_entries(self, stream, entries, converter, properties=None):
"""Write iterable of entries as YAML object to stream.
Args:
stream: File-like object.
entries: Iterable of entries.
converter: Conversion function from entry to YAML object.
propertie... | [
"def",
"_write_entries",
"(",
"self",
",",
"stream",
",",
"entries",
",",
"converter",
",",
"properties",
"=",
"None",
")",
":",
"def",
"iter_entries",
"(",
")",
":",
"for",
"c",
"in",
"entries",
":",
"entry",
"=",
"converter",
"(",
"c",
")",
"if",
"... | Write iterable of entries as YAML object to stream.
Args:
stream: File-like object.
entries: Iterable of entries.
converter: Conversion function from entry to YAML object.
properties: Set of compartment properties to output (or None to
output all)... | [
"Write",
"iterable",
"of",
"entries",
"as",
"YAML",
"object",
"to",
"stream",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1435-L1456 | train | 65,210 |
zhanglab/psamm | psamm/datasource/native.py | ModelWriter.write_compartments | def write_compartments(self, stream, compartments, adjacencies,
properties=None):
"""Write iterable of compartments as YAML object to stream.
Args:
stream: File-like object.
compartments: Iterable of compartment entries.
adjacencies: Dictio... | python | def write_compartments(self, stream, compartments, adjacencies,
properties=None):
"""Write iterable of compartments as YAML object to stream.
Args:
stream: File-like object.
compartments: Iterable of compartment entries.
adjacencies: Dictio... | [
"def",
"write_compartments",
"(",
"self",
",",
"stream",
",",
"compartments",
",",
"adjacencies",
",",
"properties",
"=",
"None",
")",
":",
"def",
"convert",
"(",
"entry",
")",
":",
"return",
"self",
".",
"convert_compartment_entry",
"(",
"entry",
",",
"adja... | Write iterable of compartments as YAML object to stream.
Args:
stream: File-like object.
compartments: Iterable of compartment entries.
adjacencies: Dictionary mapping IDs to adjacent compartment IDs.
properties: Set of compartment properties to output (or None t... | [
"Write",
"iterable",
"of",
"compartments",
"as",
"YAML",
"object",
"to",
"stream",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1458-L1473 | train | 65,211 |
zhanglab/psamm | psamm/datasource/native.py | ModelWriter.write_compounds | def write_compounds(self, stream, compounds, properties=None):
"""Write iterable of compounds as YAML object to stream.
Args:
stream: File-like object.
compounds: Iterable of compound entries.
properties: Set of compound properties to output (or None to output
... | python | def write_compounds(self, stream, compounds, properties=None):
"""Write iterable of compounds as YAML object to stream.
Args:
stream: File-like object.
compounds: Iterable of compound entries.
properties: Set of compound properties to output (or None to output
... | [
"def",
"write_compounds",
"(",
"self",
",",
"stream",
",",
"compounds",
",",
"properties",
"=",
"None",
")",
":",
"self",
".",
"_write_entries",
"(",
"stream",
",",
"compounds",
",",
"self",
".",
"convert_compound_entry",
",",
"properties",
")"
] | Write iterable of compounds as YAML object to stream.
Args:
stream: File-like object.
compounds: Iterable of compound entries.
properties: Set of compound properties to output (or None to output
all). | [
"Write",
"iterable",
"of",
"compounds",
"as",
"YAML",
"object",
"to",
"stream",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1475-L1485 | train | 65,212 |
zhanglab/psamm | psamm/datasource/native.py | ModelWriter.write_reactions | def write_reactions(self, stream, reactions, properties=None):
"""Write iterable of reactions as YAML object to stream.
Args:
stream: File-like object.
compounds: Iterable of reaction entries.
properties: Set of reaction properties to output (or None to output
... | python | def write_reactions(self, stream, reactions, properties=None):
"""Write iterable of reactions as YAML object to stream.
Args:
stream: File-like object.
compounds: Iterable of reaction entries.
properties: Set of reaction properties to output (or None to output
... | [
"def",
"write_reactions",
"(",
"self",
",",
"stream",
",",
"reactions",
",",
"properties",
"=",
"None",
")",
":",
"self",
".",
"_write_entries",
"(",
"stream",
",",
"reactions",
",",
"self",
".",
"convert_reaction_entry",
",",
"properties",
")"
] | Write iterable of reactions as YAML object to stream.
Args:
stream: File-like object.
compounds: Iterable of reaction entries.
properties: Set of reaction properties to output (or None to output
all). | [
"Write",
"iterable",
"of",
"reactions",
"as",
"YAML",
"object",
"to",
"stream",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/native.py#L1487-L1497 | train | 65,213 |
inveniosoftware/invenio-rest | invenio_rest/views.py | create_api_errorhandler | def create_api_errorhandler(**kwargs):
r"""Create an API error handler.
E.g. register a 404 error:
.. code-block:: python
app.errorhandler(404)(create_api_errorhandler(
status=404, message='Not Found'))
:param \*\*kwargs: It contains the ``'status'`` and the ``'message'``
... | python | def create_api_errorhandler(**kwargs):
r"""Create an API error handler.
E.g. register a 404 error:
.. code-block:: python
app.errorhandler(404)(create_api_errorhandler(
status=404, message='Not Found'))
:param \*\*kwargs: It contains the ``'status'`` and the ``'message'``
... | [
"def",
"create_api_errorhandler",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"api_errorhandler",
"(",
"e",
")",
":",
"if",
"isinstance",
"(",
"e",
",",
"RESTException",
")",
":",
"return",
"e",
".",
"get_response",
"(",
")",
"elif",
"isinstance",
"(",
"e"... | r"""Create an API error handler.
E.g. register a 404 error:
.. code-block:: python
app.errorhandler(404)(create_api_errorhandler(
status=404, message='Not Found'))
:param \*\*kwargs: It contains the ``'status'`` and the ``'message'``
to describe the error. | [
"r",
"Create",
"an",
"API",
"error",
"handler",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L21-L42 | train | 65,214 |
inveniosoftware/invenio-rest | invenio_rest/views.py | ContentNegotiatedMethodView.get_method_serializers | def get_method_serializers(self, http_method):
"""Get request method serializers + default media type.
Grab serializers from ``method_serializers`` if defined, otherwise
returns the default serializers. Uses GET serializers for HEAD requests
if no HEAD serializers were specified.
... | python | def get_method_serializers(self, http_method):
"""Get request method serializers + default media type.
Grab serializers from ``method_serializers`` if defined, otherwise
returns the default serializers. Uses GET serializers for HEAD requests
if no HEAD serializers were specified.
... | [
"def",
"get_method_serializers",
"(",
"self",
",",
"http_method",
")",
":",
"if",
"http_method",
"==",
"'HEAD'",
"and",
"'HEAD'",
"not",
"in",
"self",
".",
"method_serializers",
":",
"http_method",
"=",
"'GET'",
"return",
"(",
"self",
".",
"method_serializers",
... | Get request method serializers + default media type.
Grab serializers from ``method_serializers`` if defined, otherwise
returns the default serializers. Uses GET serializers for HEAD requests
if no HEAD serializers were specified.
The method also determines the default media type.
... | [
"Get",
"request",
"method",
"serializers",
"+",
"default",
"media",
"type",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L119-L138 | train | 65,215 |
inveniosoftware/invenio-rest | invenio_rest/views.py | ContentNegotiatedMethodView._match_serializers_by_query_arg | def _match_serializers_by_query_arg(self, serializers):
"""Match serializer by query arg."""
# if the format query argument is present, match the serializer
arg_name = current_app.config.get('REST_MIMETYPE_QUERY_ARG_NAME')
if arg_name:
arg_value = request.args.get(arg_name, N... | python | def _match_serializers_by_query_arg(self, serializers):
"""Match serializer by query arg."""
# if the format query argument is present, match the serializer
arg_name = current_app.config.get('REST_MIMETYPE_QUERY_ARG_NAME')
if arg_name:
arg_value = request.args.get(arg_name, N... | [
"def",
"_match_serializers_by_query_arg",
"(",
"self",
",",
"serializers",
")",
":",
"# if the format query argument is present, match the serializer",
"arg_name",
"=",
"current_app",
".",
"config",
".",
"get",
"(",
"'REST_MIMETYPE_QUERY_ARG_NAME'",
")",
"if",
"arg_name",
"... | Match serializer by query arg. | [
"Match",
"serializer",
"by",
"query",
"arg",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L140-L156 | train | 65,216 |
inveniosoftware/invenio-rest | invenio_rest/views.py | ContentNegotiatedMethodView._match_serializers_by_accept_headers | def _match_serializers_by_accept_headers(self, serializers,
default_media_type):
"""Match serializer by `Accept` headers."""
# Bail out fast if no accept headers were given.
if len(request.accept_mimetypes) == 0:
return serializers[default... | python | def _match_serializers_by_accept_headers(self, serializers,
default_media_type):
"""Match serializer by `Accept` headers."""
# Bail out fast if no accept headers were given.
if len(request.accept_mimetypes) == 0:
return serializers[default... | [
"def",
"_match_serializers_by_accept_headers",
"(",
"self",
",",
"serializers",
",",
"default_media_type",
")",
":",
"# Bail out fast if no accept headers were given.",
"if",
"len",
"(",
"request",
".",
"accept_mimetypes",
")",
"==",
"0",
":",
"return",
"serializers",
"... | Match serializer by `Accept` headers. | [
"Match",
"serializer",
"by",
"Accept",
"headers",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L158-L186 | train | 65,217 |
inveniosoftware/invenio-rest | invenio_rest/views.py | ContentNegotiatedMethodView.match_serializers | def match_serializers(self, serializers, default_media_type):
"""Choose serializer for a given request based on query arg or headers.
Checks if query arg `format` (by default) is present and tries to match
the serializer based on the arg value, by resolving the mimetype mapped
to the ar... | python | def match_serializers(self, serializers, default_media_type):
"""Choose serializer for a given request based on query arg or headers.
Checks if query arg `format` (by default) is present and tries to match
the serializer based on the arg value, by resolving the mimetype mapped
to the ar... | [
"def",
"match_serializers",
"(",
"self",
",",
"serializers",
",",
"default_media_type",
")",
":",
"return",
"self",
".",
"_match_serializers_by_query_arg",
"(",
"serializers",
")",
"or",
"self",
".",
"_match_serializers_by_accept_headers",
"(",
"serializers",
",",
"de... | Choose serializer for a given request based on query arg or headers.
Checks if query arg `format` (by default) is present and tries to match
the serializer based on the arg value, by resolving the mimetype mapped
to the arg value.
Otherwise, chooses the serializer by retrieving the best... | [
"Choose",
"serializer",
"for",
"a",
"given",
"request",
"based",
"on",
"query",
"arg",
"or",
"headers",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L188-L204 | train | 65,218 |
inveniosoftware/invenio-rest | invenio_rest/views.py | ContentNegotiatedMethodView.make_response | def make_response(self, *args, **kwargs):
"""Create a Flask Response.
Dispatch the given arguments to the serializer best matching the
current request's Accept header.
:return: The response created by the serializing function.
:rtype: :class:`flask.Response`
:raises wer... | python | def make_response(self, *args, **kwargs):
"""Create a Flask Response.
Dispatch the given arguments to the serializer best matching the
current request's Accept header.
:return: The response created by the serializing function.
:rtype: :class:`flask.Response`
:raises wer... | [
"def",
"make_response",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"serializer",
"=",
"self",
".",
"match_serializers",
"(",
"*",
"self",
".",
"get_method_serializers",
"(",
"request",
".",
"method",
")",
")",
"if",
"serializer",
"... | Create a Flask Response.
Dispatch the given arguments to the serializer best matching the
current request's Accept header.
:return: The response created by the serializing function.
:rtype: :class:`flask.Response`
:raises werkzeug.exceptions.NotAcceptable: If no media type
... | [
"Create",
"a",
"Flask",
"Response",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L206-L222 | train | 65,219 |
inveniosoftware/invenio-rest | invenio_rest/views.py | ContentNegotiatedMethodView.dispatch_request | def dispatch_request(self, *args, **kwargs):
"""Dispatch current request.
Dispatch the current request using
:class:`flask.views.MethodView` `dispatch_request()` then, if the
result is not already a :py:class:`flask.Response`, search for the
serializing function which matches th... | python | def dispatch_request(self, *args, **kwargs):
"""Dispatch current request.
Dispatch the current request using
:class:`flask.views.MethodView` `dispatch_request()` then, if the
result is not already a :py:class:`flask.Response`, search for the
serializing function which matches th... | [
"def",
"dispatch_request",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"super",
"(",
"ContentNegotiatedMethodView",
",",
"self",
")",
".",
"dispatch_request",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"i... | Dispatch current request.
Dispatch the current request using
:class:`flask.views.MethodView` `dispatch_request()` then, if the
result is not already a :py:class:`flask.Response`, search for the
serializing function which matches the best the current request's
Accept header and u... | [
"Dispatch",
"current",
"request",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L224-L248 | train | 65,220 |
inveniosoftware/invenio-rest | invenio_rest/views.py | ContentNegotiatedMethodView.check_etag | def check_etag(self, etag, weak=False):
"""Validate the given ETag with current request conditions.
Compare the given ETag to the ones in the request header If-Match
and If-None-Match conditions.
The result is unspecified for requests having If-Match and
If-None-Match being bot... | python | def check_etag(self, etag, weak=False):
"""Validate the given ETag with current request conditions.
Compare the given ETag to the ones in the request header If-Match
and If-None-Match conditions.
The result is unspecified for requests having If-Match and
If-None-Match being bot... | [
"def",
"check_etag",
"(",
"self",
",",
"etag",
",",
"weak",
"=",
"False",
")",
":",
"# bool(:py:class:`werkzeug.datastructures.ETags`) is not consistent",
"# in Python 3. bool(Etags()) == True even though it is empty.",
"if",
"len",
"(",
"request",
".",
"if_match",
".",
"as... | Validate the given ETag with current request conditions.
Compare the given ETag to the ones in the request header If-Match
and If-None-Match conditions.
The result is unspecified for requests having If-Match and
If-None-Match being both set.
:param str etag: The ETag of the cu... | [
"Validate",
"the",
"given",
"ETag",
"with",
"current",
"request",
"conditions",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L250-L285 | train | 65,221 |
inveniosoftware/invenio-rest | invenio_rest/views.py | ContentNegotiatedMethodView.check_if_modified_since | def check_if_modified_since(self, dt, etag=None):
"""Validate If-Modified-Since with current request conditions."""
dt = dt.replace(microsecond=0)
if request.if_modified_since and dt <= request.if_modified_since:
raise SameContentException(etag, last_modified=dt) | python | def check_if_modified_since(self, dt, etag=None):
"""Validate If-Modified-Since with current request conditions."""
dt = dt.replace(microsecond=0)
if request.if_modified_since and dt <= request.if_modified_since:
raise SameContentException(etag, last_modified=dt) | [
"def",
"check_if_modified_since",
"(",
"self",
",",
"dt",
",",
"etag",
"=",
"None",
")",
":",
"dt",
"=",
"dt",
".",
"replace",
"(",
"microsecond",
"=",
"0",
")",
"if",
"request",
".",
"if_modified_since",
"and",
"dt",
"<=",
"request",
".",
"if_modified_s... | Validate If-Modified-Since with current request conditions. | [
"Validate",
"If",
"-",
"Modified",
"-",
"Since",
"with",
"current",
"request",
"conditions",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/views.py#L287-L291 | train | 65,222 |
zhanglab/psamm | psamm/importer.py | get_default_compartment | def get_default_compartment(model):
"""Return what the default compartment should be set to.
If some compounds have no compartment, unique compartment
name is returned to avoid collisions.
"""
default_compartment = 'c'
default_key = set()
for reaction in model.reactions:
equation = ... | python | def get_default_compartment(model):
"""Return what the default compartment should be set to.
If some compounds have no compartment, unique compartment
name is returned to avoid collisions.
"""
default_compartment = 'c'
default_key = set()
for reaction in model.reactions:
equation = ... | [
"def",
"get_default_compartment",
"(",
"model",
")",
":",
"default_compartment",
"=",
"'c'",
"default_key",
"=",
"set",
"(",
")",
"for",
"reaction",
"in",
"model",
".",
"reactions",
":",
"equation",
"=",
"reaction",
".",
"equation",
"if",
"equation",
"is",
"... | Return what the default compartment should be set to.
If some compounds have no compartment, unique compartment
name is returned to avoid collisions. | [
"Return",
"what",
"the",
"default",
"compartment",
"should",
"be",
"set",
"to",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L172-L201 | train | 65,223 |
zhanglab/psamm | psamm/importer.py | detect_best_flux_limit | def detect_best_flux_limit(model):
"""Detect the best default flux limit to use for model output.
The default flux limit does not change the model but selecting a good
value reduced the amount of output produced and reduces clutter in the
output files.
"""
flux_limit_count = Counter()
for ... | python | def detect_best_flux_limit(model):
"""Detect the best default flux limit to use for model output.
The default flux limit does not change the model but selecting a good
value reduced the amount of output produced and reduces clutter in the
output files.
"""
flux_limit_count = Counter()
for ... | [
"def",
"detect_best_flux_limit",
"(",
"model",
")",
":",
"flux_limit_count",
"=",
"Counter",
"(",
")",
"for",
"reaction",
"in",
"model",
".",
"reactions",
":",
"if",
"reaction",
".",
"id",
"not",
"in",
"model",
".",
"limits",
":",
"continue",
"equation",
"... | Detect the best default flux limit to use for model output.
The default flux limit does not change the model but selecting a good
value reduced the amount of output produced and reduces clutter in the
output files. | [
"Detect",
"the",
"best",
"default",
"flux",
"limit",
"to",
"use",
"for",
"model",
"output",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L204-L231 | train | 65,224 |
zhanglab/psamm | psamm/importer.py | reactions_to_files | def reactions_to_files(model, dest, writer, split_subsystem):
"""Turn the reaction subsystems into their own files.
If a subsystem has a number of reactions over the threshold, it gets its
own YAML file. All other reactions, those that don't have a subsystem or
are in a subsystem that falls below the t... | python | def reactions_to_files(model, dest, writer, split_subsystem):
"""Turn the reaction subsystems into their own files.
If a subsystem has a number of reactions over the threshold, it gets its
own YAML file. All other reactions, those that don't have a subsystem or
are in a subsystem that falls below the t... | [
"def",
"reactions_to_files",
"(",
"model",
",",
"dest",
",",
"writer",
",",
"split_subsystem",
")",
":",
"def",
"safe_file_name",
"(",
"origin_name",
")",
":",
"safe_name",
"=",
"re",
".",
"sub",
"(",
"r'\\W+'",
",",
"'_'",
",",
"origin_name",
",",
"flags"... | Turn the reaction subsystems into their own files.
If a subsystem has a number of reactions over the threshold, it gets its
own YAML file. All other reactions, those that don't have a subsystem or
are in a subsystem that falls below the threshold, get added to a common
reaction file.
Args:
... | [
"Turn",
"the",
"reaction",
"subsystems",
"into",
"their",
"own",
"files",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L234-L303 | train | 65,225 |
zhanglab/psamm | psamm/importer.py | _generate_limit_items | def _generate_limit_items(lower, upper):
"""Yield key, value pairs for limits dictionary.
Yield pairs of key, value where key is ``lower``, ``upper`` or ``fixed``.
A key, value pair is emitted if the bounds are not None.
"""
# Use value + 0 to convert any -0.0 to 0.0 which looks better.
if lowe... | python | def _generate_limit_items(lower, upper):
"""Yield key, value pairs for limits dictionary.
Yield pairs of key, value where key is ``lower``, ``upper`` or ``fixed``.
A key, value pair is emitted if the bounds are not None.
"""
# Use value + 0 to convert any -0.0 to 0.0 which looks better.
if lowe... | [
"def",
"_generate_limit_items",
"(",
"lower",
",",
"upper",
")",
":",
"# Use value + 0 to convert any -0.0 to 0.0 which looks better.",
"if",
"lower",
"is",
"not",
"None",
"and",
"upper",
"is",
"not",
"None",
"and",
"lower",
"==",
"upper",
":",
"yield",
"'fixed'",
... | Yield key, value pairs for limits dictionary.
Yield pairs of key, value where key is ``lower``, ``upper`` or ``fixed``.
A key, value pair is emitted if the bounds are not None. | [
"Yield",
"key",
"value",
"pairs",
"for",
"limits",
"dictionary",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L311-L324 | train | 65,226 |
zhanglab/psamm | psamm/importer.py | model_exchange | def model_exchange(model):
"""Return exchange definition as YAML dict."""
# Determine the default flux limits. If the value is already at the
# default it does not need to be included in the output.
lower_default, upper_default = None, None
if model.default_flux_limit is not None:
lower_defa... | python | def model_exchange(model):
"""Return exchange definition as YAML dict."""
# Determine the default flux limits. If the value is already at the
# default it does not need to be included in the output.
lower_default, upper_default = None, None
if model.default_flux_limit is not None:
lower_defa... | [
"def",
"model_exchange",
"(",
"model",
")",
":",
"# Determine the default flux limits. If the value is already at the",
"# default it does not need to be included in the output.",
"lower_default",
",",
"upper_default",
"=",
"None",
",",
"None",
"if",
"model",
".",
"default_flux_l... | Return exchange definition as YAML dict. | [
"Return",
"exchange",
"definition",
"as",
"YAML",
"dict",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L327-L349 | train | 65,227 |
zhanglab/psamm | psamm/importer.py | model_reaction_limits | def model_reaction_limits(model):
"""Yield model reaction limits as YAML dicts."""
for reaction in sorted(model.reactions, key=lambda r: r.id):
equation = reaction.properties.get('equation')
if equation is None:
continue
# Determine the default flux limits. If the value is a... | python | def model_reaction_limits(model):
"""Yield model reaction limits as YAML dicts."""
for reaction in sorted(model.reactions, key=lambda r: r.id):
equation = reaction.properties.get('equation')
if equation is None:
continue
# Determine the default flux limits. If the value is a... | [
"def",
"model_reaction_limits",
"(",
"model",
")",
":",
"for",
"reaction",
"in",
"sorted",
"(",
"model",
".",
"reactions",
",",
"key",
"=",
"lambda",
"r",
":",
"r",
".",
"id",
")",
":",
"equation",
"=",
"reaction",
".",
"properties",
".",
"get",
"(",
... | Yield model reaction limits as YAML dicts. | [
"Yield",
"model",
"reaction",
"limits",
"as",
"YAML",
"dicts",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L352-L383 | train | 65,228 |
zhanglab/psamm | psamm/importer.py | infer_compartment_entries | def infer_compartment_entries(model):
"""Infer compartment entries for model based on reaction compounds."""
compartment_ids = set()
for reaction in model.reactions:
equation = reaction.equation
if equation is None:
continue
for compound, _ in equation.compounds:
... | python | def infer_compartment_entries(model):
"""Infer compartment entries for model based on reaction compounds."""
compartment_ids = set()
for reaction in model.reactions:
equation = reaction.equation
if equation is None:
continue
for compound, _ in equation.compounds:
... | [
"def",
"infer_compartment_entries",
"(",
"model",
")",
":",
"compartment_ids",
"=",
"set",
"(",
")",
"for",
"reaction",
"in",
"model",
".",
"reactions",
":",
"equation",
"=",
"reaction",
".",
"equation",
"if",
"equation",
"is",
"None",
":",
"continue",
"for"... | Infer compartment entries for model based on reaction compounds. | [
"Infer",
"compartment",
"entries",
"for",
"model",
"based",
"on",
"reaction",
"compounds",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L386-L407 | train | 65,229 |
zhanglab/psamm | psamm/importer.py | infer_compartment_adjacency | def infer_compartment_adjacency(model):
"""Infer compartment adjacency for model based on reactions."""
def reaction_compartments(seq):
for compound, _ in seq:
compartment = compound.compartment
if compartment is None:
compartment = model.default_compartment
... | python | def infer_compartment_adjacency(model):
"""Infer compartment adjacency for model based on reactions."""
def reaction_compartments(seq):
for compound, _ in seq:
compartment = compound.compartment
if compartment is None:
compartment = model.default_compartment
... | [
"def",
"infer_compartment_adjacency",
"(",
"model",
")",
":",
"def",
"reaction_compartments",
"(",
"seq",
")",
":",
"for",
"compound",
",",
"_",
"in",
"seq",
":",
"compartment",
"=",
"compound",
".",
"compartment",
"if",
"compartment",
"is",
"None",
":",
"co... | Infer compartment adjacency for model based on reactions. | [
"Infer",
"compartment",
"adjacency",
"for",
"model",
"based",
"on",
"reactions",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L410-L432 | train | 65,230 |
zhanglab/psamm | psamm/importer.py | count_genes | def count_genes(model):
"""Count the number of distinct genes in model reactions."""
genes = set()
for reaction in model.reactions:
if reaction.genes is None:
continue
if isinstance(reaction.genes, boolean.Expression):
genes.update(v.symbol for v in reaction.genes.va... | python | def count_genes(model):
"""Count the number of distinct genes in model reactions."""
genes = set()
for reaction in model.reactions:
if reaction.genes is None:
continue
if isinstance(reaction.genes, boolean.Expression):
genes.update(v.symbol for v in reaction.genes.va... | [
"def",
"count_genes",
"(",
"model",
")",
":",
"genes",
"=",
"set",
"(",
")",
"for",
"reaction",
"in",
"model",
".",
"reactions",
":",
"if",
"reaction",
".",
"genes",
"is",
"None",
":",
"continue",
"if",
"isinstance",
"(",
"reaction",
".",
"genes",
",",... | Count the number of distinct genes in model reactions. | [
"Count",
"the",
"number",
"of",
"distinct",
"genes",
"in",
"model",
"reactions",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L435-L447 | train | 65,231 |
zhanglab/psamm | psamm/importer.py | Importer._try_parse_formula | def _try_parse_formula(self, compound_id, s):
"""Try to parse the given compound formula string.
Logs a warning if the formula could not be parsed.
"""
s = s.strip()
if s == '':
return None
try:
# Do not return the parsed formula. For now it is b... | python | def _try_parse_formula(self, compound_id, s):
"""Try to parse the given compound formula string.
Logs a warning if the formula could not be parsed.
"""
s = s.strip()
if s == '':
return None
try:
# Do not return the parsed formula. For now it is b... | [
"def",
"_try_parse_formula",
"(",
"self",
",",
"compound_id",
",",
"s",
")",
":",
"s",
"=",
"s",
".",
"strip",
"(",
")",
"if",
"s",
"==",
"''",
":",
"return",
"None",
"try",
":",
"# Do not return the parsed formula. For now it is better to keep",
"# the original... | Try to parse the given compound formula string.
Logs a warning if the formula could not be parsed. | [
"Try",
"to",
"parse",
"the",
"given",
"compound",
"formula",
"string",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L79-L96 | train | 65,232 |
zhanglab/psamm | psamm/importer.py | Importer._try_parse_reaction | def _try_parse_reaction(self, reaction_id, s,
parser=parse_reaction, **kwargs):
"""Try to parse the given reaction equation string.
Returns the parsed Reaction object, or raises an error if the reaction
could not be parsed.
"""
try:
return... | python | def _try_parse_reaction(self, reaction_id, s,
parser=parse_reaction, **kwargs):
"""Try to parse the given reaction equation string.
Returns the parsed Reaction object, or raises an error if the reaction
could not be parsed.
"""
try:
return... | [
"def",
"_try_parse_reaction",
"(",
"self",
",",
"reaction_id",
",",
"s",
",",
"parser",
"=",
"parse_reaction",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"parser",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
"except",
"ReactionParseError",
"as"... | Try to parse the given reaction equation string.
Returns the parsed Reaction object, or raises an error if the reaction
could not be parsed. | [
"Try",
"to",
"parse",
"the",
"given",
"reaction",
"equation",
"string",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L98-L112 | train | 65,233 |
zhanglab/psamm | psamm/importer.py | Importer._try_parse_gene_association | def _try_parse_gene_association(self, reaction_id, s):
"""Try to parse the given gene association rule.
Logs a warning if the association rule could not be parsed and returns
the original string. Otherwise, returns the boolean.Expression object.
"""
s = s.strip()
if s ==... | python | def _try_parse_gene_association(self, reaction_id, s):
"""Try to parse the given gene association rule.
Logs a warning if the association rule could not be parsed and returns
the original string. Otherwise, returns the boolean.Expression object.
"""
s = s.strip()
if s ==... | [
"def",
"_try_parse_gene_association",
"(",
"self",
",",
"reaction_id",
",",
"s",
")",
":",
"s",
"=",
"s",
".",
"strip",
"(",
")",
"if",
"s",
"==",
"''",
":",
"return",
"None",
"try",
":",
"return",
"boolean",
".",
"Expression",
"(",
"s",
")",
"except... | Try to parse the given gene association rule.
Logs a warning if the association rule could not be parsed and returns
the original string. Otherwise, returns the boolean.Expression object. | [
"Try",
"to",
"parse",
"the",
"given",
"gene",
"association",
"rule",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/importer.py#L114-L133 | train | 65,234 |
inveniosoftware/invenio-rest | invenio_rest/decorators.py | require_content_types | def require_content_types(*allowed_content_types):
r"""Decorator to test if proper Content-Type is provided.
:param \*allowed_content_types: List of allowed content types.
:raises invenio_rest.errors.InvalidContentType: It's rised if a content
type not allowed is required.
"""
def decorator... | python | def require_content_types(*allowed_content_types):
r"""Decorator to test if proper Content-Type is provided.
:param \*allowed_content_types: List of allowed content types.
:raises invenio_rest.errors.InvalidContentType: It's rised if a content
type not allowed is required.
"""
def decorator... | [
"def",
"require_content_types",
"(",
"*",
"allowed_content_types",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"request",
".",
"mimetype",
"... | r"""Decorator to test if proper Content-Type is provided.
:param \*allowed_content_types: List of allowed content types.
:raises invenio_rest.errors.InvalidContentType: It's rised if a content
type not allowed is required. | [
"r",
"Decorator",
"to",
"test",
"if",
"proper",
"Content",
"-",
"Type",
"is",
"provided",
"."
] | 4271708f0e2877e5100236be9242035b95b5ae6e | https://github.com/inveniosoftware/invenio-rest/blob/4271708f0e2877e5100236be9242035b95b5ae6e/invenio_rest/decorators.py#L20-L34 | train | 65,235 |
merll/docker-fabric | dockerfabric/base.py | DockerConnectionDict.get_connection | def get_connection(self, *args, **kwargs):
"""
Create a new connection, or return an existing one from the cache. Uses Fabric's current ``env.host_string``
and the URL to the Docker service.
:param args: Additional arguments for the client constructor, if a new client has to be instanti... | python | def get_connection(self, *args, **kwargs):
"""
Create a new connection, or return an existing one from the cache. Uses Fabric's current ``env.host_string``
and the URL to the Docker service.
:param args: Additional arguments for the client constructor, if a new client has to be instanti... | [
"def",
"get_connection",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"env",
".",
"get",
"(",
"'host_string'",
")",
",",
"kwargs",
".",
"get",
"(",
"'base_url'",
",",
"env",
".",
"get",
"(",
"'docker_base_url'",
")",
... | Create a new connection, or return an existing one from the cache. Uses Fabric's current ``env.host_string``
and the URL to the Docker service.
:param args: Additional arguments for the client constructor, if a new client has to be instantiated.
:param kwargs: Additional keyword args for the cl... | [
"Create",
"a",
"new",
"connection",
"or",
"return",
"an",
"existing",
"one",
"from",
"the",
"cache",
".",
"Uses",
"Fabric",
"s",
"current",
"env",
".",
"host_string",
"and",
"the",
"URL",
"to",
"the",
"Docker",
"service",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/base.py#L43-L58 | train | 65,236 |
zhanglab/psamm | psamm/lpsolver/generic.py | filter_solvers | def filter_solvers(solvers, requirements):
"""Yield solvers that fullfil the requirements."""
for solver in solvers:
for req, value in iteritems(requirements):
if (req in ('integer', 'quadratic', 'rational', 'name') and
(req not in solver or solver[req] != value)):
... | python | def filter_solvers(solvers, requirements):
"""Yield solvers that fullfil the requirements."""
for solver in solvers:
for req, value in iteritems(requirements):
if (req in ('integer', 'quadratic', 'rational', 'name') and
(req not in solver or solver[req] != value)):
... | [
"def",
"filter_solvers",
"(",
"solvers",
",",
"requirements",
")",
":",
"for",
"solver",
"in",
"solvers",
":",
"for",
"req",
",",
"value",
"in",
"iteritems",
"(",
"requirements",
")",
":",
"if",
"(",
"req",
"in",
"(",
"'integer'",
",",
"'quadratic'",
","... | Yield solvers that fullfil the requirements. | [
"Yield",
"solvers",
"that",
"fullfil",
"the",
"requirements",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/generic.py#L96-L104 | train | 65,237 |
zhanglab/psamm | psamm/lpsolver/generic.py | parse_solver_setting | def parse_solver_setting(s):
"""Parse a string containing a solver setting"""
try:
key, value = s.split('=', 1)
except ValueError:
key, value = s, 'yes'
if key in ('rational', 'integer', 'quadratic'):
value = value.lower() in ('1', 'yes', 'true', 'on')
elif key in ('threads... | python | def parse_solver_setting(s):
"""Parse a string containing a solver setting"""
try:
key, value = s.split('=', 1)
except ValueError:
key, value = s, 'yes'
if key in ('rational', 'integer', 'quadratic'):
value = value.lower() in ('1', 'yes', 'true', 'on')
elif key in ('threads... | [
"def",
"parse_solver_setting",
"(",
"s",
")",
":",
"try",
":",
"key",
",",
"value",
"=",
"s",
".",
"split",
"(",
"'='",
",",
"1",
")",
"except",
"ValueError",
":",
"key",
",",
"value",
"=",
"s",
",",
"'yes'",
"if",
"key",
"in",
"(",
"'rational'",
... | Parse a string containing a solver setting | [
"Parse",
"a",
"string",
"containing",
"a",
"solver",
"setting"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/generic.py#L159-L175 | train | 65,238 |
zhanglab/psamm | psamm/metabolicmodel.py | MetabolicModel.get_reaction_values | def get_reaction_values(self, reaction_id):
"""Return stoichiometric values of reaction as a dictionary"""
if reaction_id not in self._reaction_set:
raise ValueError('Unknown reaction: {}'.format(repr(reaction_id)))
return self._database.get_reaction_values(reaction_id) | python | def get_reaction_values(self, reaction_id):
"""Return stoichiometric values of reaction as a dictionary"""
if reaction_id not in self._reaction_set:
raise ValueError('Unknown reaction: {}'.format(repr(reaction_id)))
return self._database.get_reaction_values(reaction_id) | [
"def",
"get_reaction_values",
"(",
"self",
",",
"reaction_id",
")",
":",
"if",
"reaction_id",
"not",
"in",
"self",
".",
"_reaction_set",
":",
"raise",
"ValueError",
"(",
"'Unknown reaction: {}'",
".",
"format",
"(",
"repr",
"(",
"reaction_id",
")",
")",
")",
... | Return stoichiometric values of reaction as a dictionary | [
"Return",
"stoichiometric",
"values",
"of",
"reaction",
"as",
"a",
"dictionary"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/metabolicmodel.py#L211-L215 | train | 65,239 |
zhanglab/psamm | psamm/metabolicmodel.py | MetabolicModel.get_compound_reactions | def get_compound_reactions(self, compound_id):
"""Iterate over all reaction ids the includes the given compound"""
if compound_id not in self._compound_set:
raise ValueError('Compound not in model: {}'.format(compound_id))
for reaction_id in self._database.get_compound_reactions(com... | python | def get_compound_reactions(self, compound_id):
"""Iterate over all reaction ids the includes the given compound"""
if compound_id not in self._compound_set:
raise ValueError('Compound not in model: {}'.format(compound_id))
for reaction_id in self._database.get_compound_reactions(com... | [
"def",
"get_compound_reactions",
"(",
"self",
",",
"compound_id",
")",
":",
"if",
"compound_id",
"not",
"in",
"self",
".",
"_compound_set",
":",
"raise",
"ValueError",
"(",
"'Compound not in model: {}'",
".",
"format",
"(",
"compound_id",
")",
")",
"for",
"react... | Iterate over all reaction ids the includes the given compound | [
"Iterate",
"over",
"all",
"reaction",
"ids",
"the",
"includes",
"the",
"given",
"compound"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/metabolicmodel.py#L217-L224 | train | 65,240 |
zhanglab/psamm | psamm/metabolicmodel.py | MetabolicModel.is_reversible | def is_reversible(self, reaction_id):
"""Whether the given reaction is reversible"""
if reaction_id not in self._reaction_set:
raise ValueError('Reaction not in model: {}'.format(reaction_id))
return self._database.is_reversible(reaction_id) | python | def is_reversible(self, reaction_id):
"""Whether the given reaction is reversible"""
if reaction_id not in self._reaction_set:
raise ValueError('Reaction not in model: {}'.format(reaction_id))
return self._database.is_reversible(reaction_id) | [
"def",
"is_reversible",
"(",
"self",
",",
"reaction_id",
")",
":",
"if",
"reaction_id",
"not",
"in",
"self",
".",
"_reaction_set",
":",
"raise",
"ValueError",
"(",
"'Reaction not in model: {}'",
".",
"format",
"(",
"reaction_id",
")",
")",
"return",
"self",
".... | Whether the given reaction is reversible | [
"Whether",
"the",
"given",
"reaction",
"is",
"reversible"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/metabolicmodel.py#L226-L230 | train | 65,241 |
zhanglab/psamm | psamm/metabolicmodel.py | MetabolicModel.is_exchange | def is_exchange(self, reaction_id):
"""Whether the given reaction is an exchange reaction."""
reaction = self.get_reaction(reaction_id)
return (len(reaction.left) == 0) != (len(reaction.right) == 0) | python | def is_exchange(self, reaction_id):
"""Whether the given reaction is an exchange reaction."""
reaction = self.get_reaction(reaction_id)
return (len(reaction.left) == 0) != (len(reaction.right) == 0) | [
"def",
"is_exchange",
"(",
"self",
",",
"reaction_id",
")",
":",
"reaction",
"=",
"self",
".",
"get_reaction",
"(",
"reaction_id",
")",
"return",
"(",
"len",
"(",
"reaction",
".",
"left",
")",
"==",
"0",
")",
"!=",
"(",
"len",
"(",
"reaction",
".",
"... | Whether the given reaction is an exchange reaction. | [
"Whether",
"the",
"given",
"reaction",
"is",
"an",
"exchange",
"reaction",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/metabolicmodel.py#L232-L235 | train | 65,242 |
zhanglab/psamm | psamm/metabolicmodel.py | MetabolicModel.add_reaction | def add_reaction(self, reaction_id):
"""Add reaction to model"""
if reaction_id in self._reaction_set:
return
reaction = self._database.get_reaction(reaction_id)
self._reaction_set.add(reaction_id)
for compound, _ in reaction.compounds:
self._compound_se... | python | def add_reaction(self, reaction_id):
"""Add reaction to model"""
if reaction_id in self._reaction_set:
return
reaction = self._database.get_reaction(reaction_id)
self._reaction_set.add(reaction_id)
for compound, _ in reaction.compounds:
self._compound_se... | [
"def",
"add_reaction",
"(",
"self",
",",
"reaction_id",
")",
":",
"if",
"reaction_id",
"in",
"self",
".",
"_reaction_set",
":",
"return",
"reaction",
"=",
"self",
".",
"_database",
".",
"get_reaction",
"(",
"reaction_id",
")",
"self",
".",
"_reaction_set",
"... | Add reaction to model | [
"Add",
"reaction",
"to",
"model"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/metabolicmodel.py#L241-L250 | train | 65,243 |
zhanglab/psamm | psamm/metabolicmodel.py | MetabolicModel.remove_reaction | def remove_reaction(self, reaction):
"""Remove reaction from model"""
if reaction not in self._reaction_set:
return
self._reaction_set.remove(reaction)
self._limits_lower.pop(reaction, None)
self._limits_upper.pop(reaction, None)
# Remove compound from comp... | python | def remove_reaction(self, reaction):
"""Remove reaction from model"""
if reaction not in self._reaction_set:
return
self._reaction_set.remove(reaction)
self._limits_lower.pop(reaction, None)
self._limits_upper.pop(reaction, None)
# Remove compound from comp... | [
"def",
"remove_reaction",
"(",
"self",
",",
"reaction",
")",
":",
"if",
"reaction",
"not",
"in",
"self",
".",
"_reaction_set",
":",
"return",
"self",
".",
"_reaction_set",
".",
"remove",
"(",
"reaction",
")",
"self",
".",
"_limits_lower",
".",
"pop",
"(",
... | Remove reaction from model | [
"Remove",
"reaction",
"from",
"model"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/metabolicmodel.py#L252-L269 | train | 65,244 |
zhanglab/psamm | psamm/metabolicmodel.py | MetabolicModel.copy | def copy(self):
"""Return copy of model"""
model = self.__class__(self._database)
model._limits_lower = dict(self._limits_lower)
model._limits_upper = dict(self._limits_upper)
model._reaction_set = set(self._reaction_set)
model._compound_set = set(self._compound_set)
... | python | def copy(self):
"""Return copy of model"""
model = self.__class__(self._database)
model._limits_lower = dict(self._limits_lower)
model._limits_upper = dict(self._limits_upper)
model._reaction_set = set(self._reaction_set)
model._compound_set = set(self._compound_set)
... | [
"def",
"copy",
"(",
"self",
")",
":",
"model",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"_database",
")",
"model",
".",
"_limits_lower",
"=",
"dict",
"(",
"self",
".",
"_limits_lower",
")",
"model",
".",
"_limits_upper",
"=",
"dict",
"(",
"self... | Return copy of model | [
"Return",
"copy",
"of",
"model"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/metabolicmodel.py#L271-L279 | train | 65,245 |
zhanglab/psamm | psamm/metabolicmodel.py | MetabolicModel.load_model | def load_model(cls, database, reaction_iter=None, exchange=None,
limits=None, v_max=None):
"""Get model from reaction name iterator.
The model will contain all reactions of the iterator.
"""
model_args = {}
if v_max is not None:
model_args['v_max'... | python | def load_model(cls, database, reaction_iter=None, exchange=None,
limits=None, v_max=None):
"""Get model from reaction name iterator.
The model will contain all reactions of the iterator.
"""
model_args = {}
if v_max is not None:
model_args['v_max'... | [
"def",
"load_model",
"(",
"cls",
",",
"database",
",",
"reaction_iter",
"=",
"None",
",",
"exchange",
"=",
"None",
",",
"limits",
"=",
"None",
",",
"v_max",
"=",
"None",
")",
":",
"model_args",
"=",
"{",
"}",
"if",
"v_max",
"is",
"not",
"None",
":",
... | Get model from reaction name iterator.
The model will contain all reactions of the iterator. | [
"Get",
"model",
"from",
"reaction",
"name",
"iterator",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/metabolicmodel.py#L282-L325 | train | 65,246 |
zhanglab/psamm | psamm/commands/fba.py | FluxBalanceCommand.run | def run(self):
"""Run flux analysis command."""
# Load compound information
def compound_name(id):
if id not in self._model.compounds:
return id
return self._model.compounds[id].properties.get('name', id)
# Reaction genes information
def ... | python | def run(self):
"""Run flux analysis command."""
# Load compound information
def compound_name(id):
if id not in self._model.compounds:
return id
return self._model.compounds[id].properties.get('name', id)
# Reaction genes information
def ... | [
"def",
"run",
"(",
"self",
")",
":",
"# Load compound information",
"def",
"compound_name",
"(",
"id",
")",
":",
"if",
"id",
"not",
"in",
"self",
".",
"_model",
".",
"compounds",
":",
"return",
"id",
"return",
"self",
".",
"_model",
".",
"compounds",
"["... | Run flux analysis command. | [
"Run",
"flux",
"analysis",
"command",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/fba.py#L46-L95 | train | 65,247 |
zhanglab/psamm | psamm/commands/fba.py | FluxBalanceCommand.run_fba_minimized | def run_fba_minimized(self, reaction):
"""Run normal FBA and flux minimization on model."""
epsilon = self._args.epsilon
solver = self._get_solver()
p = fluxanalysis.FluxBalanceProblem(self._mm, solver)
start_time = time.time()
# Maximize reaction flux
try:
... | python | def run_fba_minimized(self, reaction):
"""Run normal FBA and flux minimization on model."""
epsilon = self._args.epsilon
solver = self._get_solver()
p = fluxanalysis.FluxBalanceProblem(self._mm, solver)
start_time = time.time()
# Maximize reaction flux
try:
... | [
"def",
"run_fba_minimized",
"(",
"self",
",",
"reaction",
")",
":",
"epsilon",
"=",
"self",
".",
"_args",
".",
"epsilon",
"solver",
"=",
"self",
".",
"_get_solver",
"(",
")",
"p",
"=",
"fluxanalysis",
".",
"FluxBalanceProblem",
"(",
"self",
".",
"_mm",
"... | Run normal FBA and flux minimization on model. | [
"Run",
"normal",
"FBA",
"and",
"flux",
"minimization",
"on",
"model",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/fba.py#L115-L147 | train | 65,248 |
zhanglab/psamm | psamm/commands/fba.py | FluxBalanceCommand.run_tfba | def run_tfba(self, reaction):
"""Run FBA and tFBA on model."""
solver = self._get_solver(integer=True)
p = fluxanalysis.FluxBalanceProblem(self._mm, solver)
start_time = time.time()
p.add_thermodynamic()
try:
p.maximize(reaction)
except fluxanalysi... | python | def run_tfba(self, reaction):
"""Run FBA and tFBA on model."""
solver = self._get_solver(integer=True)
p = fluxanalysis.FluxBalanceProblem(self._mm, solver)
start_time = time.time()
p.add_thermodynamic()
try:
p.maximize(reaction)
except fluxanalysi... | [
"def",
"run_tfba",
"(",
"self",
",",
"reaction",
")",
":",
"solver",
"=",
"self",
".",
"_get_solver",
"(",
"integer",
"=",
"True",
")",
"p",
"=",
"fluxanalysis",
".",
"FluxBalanceProblem",
"(",
"self",
".",
"_mm",
",",
"solver",
")",
"start_time",
"=",
... | Run FBA and tFBA on model. | [
"Run",
"FBA",
"and",
"tFBA",
"on",
"model",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/fba.py#L149-L168 | train | 65,249 |
zhanglab/psamm | psamm/massconsistency.py | is_consistent | def is_consistent(database, solver, exchange=set(), zeromass=set()):
"""Try to assign a positive mass to each compound
Return True if successful. The masses are simply constrained by m_i > 1 and
finding a solution under these conditions proves that the database is mass
consistent.
"""
prob = s... | python | def is_consistent(database, solver, exchange=set(), zeromass=set()):
"""Try to assign a positive mass to each compound
Return True if successful. The masses are simply constrained by m_i > 1 and
finding a solution under these conditions proves that the database is mass
consistent.
"""
prob = s... | [
"def",
"is_consistent",
"(",
"database",
",",
"solver",
",",
"exchange",
"=",
"set",
"(",
")",
",",
"zeromass",
"=",
"set",
"(",
")",
")",
":",
"prob",
"=",
"solver",
".",
"create_problem",
"(",
")",
"compound_set",
"=",
"_non_localized_compounds",
"(",
... | Try to assign a positive mass to each compound
Return True if successful. The masses are simply constrained by m_i > 1 and
finding a solution under these conditions proves that the database is mass
consistent. | [
"Try",
"to",
"assign",
"a",
"positive",
"mass",
"to",
"each",
"compound"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/massconsistency.py#L44-L71 | train | 65,250 |
zhanglab/psamm | psamm/massconsistency.py | check_reaction_consistency | def check_reaction_consistency(database, solver, exchange=set(),
checked=set(), zeromass=set(), weights={}):
"""Check inconsistent reactions by minimizing mass residuals
Return a reaction iterable, and compound iterable. The reaction iterable
yields reaction ids and mass resi... | python | def check_reaction_consistency(database, solver, exchange=set(),
checked=set(), zeromass=set(), weights={}):
"""Check inconsistent reactions by minimizing mass residuals
Return a reaction iterable, and compound iterable. The reaction iterable
yields reaction ids and mass resi... | [
"def",
"check_reaction_consistency",
"(",
"database",
",",
"solver",
",",
"exchange",
"=",
"set",
"(",
")",
",",
"checked",
"=",
"set",
"(",
")",
",",
"zeromass",
"=",
"set",
"(",
")",
",",
"weights",
"=",
"{",
"}",
")",
":",
"# Create Flux balance probl... | Check inconsistent reactions by minimizing mass residuals
Return a reaction iterable, and compound iterable. The reaction iterable
yields reaction ids and mass residuals. The compound iterable yields
compound ids and mass assignments.
Each compound is assigned a mass of at least one, and the masses ar... | [
"Check",
"inconsistent",
"reactions",
"by",
"minimizing",
"mass",
"residuals"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/massconsistency.py#L74-L138 | train | 65,251 |
zhanglab/psamm | psamm/massconsistency.py | check_compound_consistency | def check_compound_consistency(database, solver, exchange=set(),
zeromass=set()):
"""Yield each compound in the database with assigned mass
Each compound will be assigned a mass and the number of compounds having a
positive mass will be approximately maximized.
This is a... | python | def check_compound_consistency(database, solver, exchange=set(),
zeromass=set()):
"""Yield each compound in the database with assigned mass
Each compound will be assigned a mass and the number of compounds having a
positive mass will be approximately maximized.
This is a... | [
"def",
"check_compound_consistency",
"(",
"database",
",",
"solver",
",",
"exchange",
"=",
"set",
"(",
")",
",",
"zeromass",
"=",
"set",
"(",
")",
")",
":",
"# Create mass balance problem",
"prob",
"=",
"solver",
".",
"create_problem",
"(",
")",
"compound_set"... | Yield each compound in the database with assigned mass
Each compound will be assigned a mass and the number of compounds having a
positive mass will be approximately maximized.
This is an implementation of the solution originally proposed by
[Gevorgyan08]_ but using the new method proposed by [Thiele... | [
"Yield",
"each",
"compound",
"in",
"the",
"database",
"with",
"assigned",
"mass"
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/massconsistency.py#L141-L186 | train | 65,252 |
zhanglab/psamm | psamm/util.py | create_unique_id | def create_unique_id(prefix, existing_ids):
"""Return a unique string ID from the prefix.
First check if the prefix is itself a unique ID in the set-like parameter
existing_ids. If not, try integers in ascending order appended to the
prefix until a unique ID is found.
"""
if prefix in existing_... | python | def create_unique_id(prefix, existing_ids):
"""Return a unique string ID from the prefix.
First check if the prefix is itself a unique ID in the set-like parameter
existing_ids. If not, try integers in ascending order appended to the
prefix until a unique ID is found.
"""
if prefix in existing_... | [
"def",
"create_unique_id",
"(",
"prefix",
",",
"existing_ids",
")",
":",
"if",
"prefix",
"in",
"existing_ids",
":",
"suffix",
"=",
"1",
"while",
"True",
":",
"new_id",
"=",
"'{}_{}'",
".",
"format",
"(",
"prefix",
",",
"suffix",
")",
"if",
"new_id",
"not... | Return a unique string ID from the prefix.
First check if the prefix is itself a unique ID in the set-like parameter
existing_ids. If not, try integers in ascending order appended to the
prefix until a unique ID is found. | [
"Return",
"a",
"unique",
"string",
"ID",
"from",
"the",
"prefix",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/util.py#L178-L193 | train | 65,253 |
zhanglab/psamm | psamm/util.py | git_try_describe | def git_try_describe(repo_path):
"""Try to describe the current commit of a Git repository.
Return a string containing a string with the commit ID and/or a base tag,
if successful. Otherwise, return None.
"""
try:
p = subprocess.Popen(['git', 'describe', '--always', '--dirty'],
... | python | def git_try_describe(repo_path):
"""Try to describe the current commit of a Git repository.
Return a string containing a string with the commit ID and/or a base tag,
if successful. Otherwise, return None.
"""
try:
p = subprocess.Popen(['git', 'describe', '--always', '--dirty'],
... | [
"def",
"git_try_describe",
"(",
"repo_path",
")",
":",
"try",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'git'",
",",
"'describe'",
",",
"'--always'",
",",
"'--dirty'",
"]",
",",
"cwd",
"=",
"repo_path",
",",
"stdout",
"=",
"subprocess",
".",
... | Try to describe the current commit of a Git repository.
Return a string containing a string with the commit ID and/or a base tag,
if successful. Otherwise, return None. | [
"Try",
"to",
"describe",
"the",
"current",
"commit",
"of",
"a",
"Git",
"repository",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/util.py#L196-L213 | train | 65,254 |
zhanglab/psamm | psamm/util.py | convex_cardinality_relaxed | def convex_cardinality_relaxed(f, epsilon=1e-5):
"""Transform L1-norm optimization function into cardinality optimization.
The given function must optimize a convex problem with
a weighted L1-norm as the objective. The transformed function
will apply the iterated weighted L1 heuristic to approximately
... | python | def convex_cardinality_relaxed(f, epsilon=1e-5):
"""Transform L1-norm optimization function into cardinality optimization.
The given function must optimize a convex problem with
a weighted L1-norm as the objective. The transformed function
will apply the iterated weighted L1 heuristic to approximately
... | [
"def",
"convex_cardinality_relaxed",
"(",
"f",
",",
"epsilon",
"=",
"1e-5",
")",
":",
"def",
"convex_cardinality_wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"dict_result",
"(",
"r",
")",
":",
"if",
"isinstance",
"(",
"r",
",",
... | Transform L1-norm optimization function into cardinality optimization.
The given function must optimize a convex problem with
a weighted L1-norm as the objective. The transformed function
will apply the iterated weighted L1 heuristic to approximately
optimize the cardinality of the solution. This metho... | [
"Transform",
"L1",
"-",
"norm",
"optimization",
"function",
"into",
"cardinality",
"optimization",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/util.py#L216-L267 | train | 65,255 |
zhanglab/psamm | psamm/util.py | LoggerFile.write | def write(self, s):
"""Write message to logger."""
for line in re.split(r'\n+', s):
if line != '':
self._logger.log(self._level, line) | python | def write(self, s):
"""Write message to logger."""
for line in re.split(r'\n+', s):
if line != '':
self._logger.log(self._level, line) | [
"def",
"write",
"(",
"self",
",",
"s",
")",
":",
"for",
"line",
"in",
"re",
".",
"split",
"(",
"r'\\n+'",
",",
"s",
")",
":",
"if",
"line",
"!=",
"''",
":",
"self",
".",
"_logger",
".",
"log",
"(",
"self",
".",
"_level",
",",
"line",
")"
] | Write message to logger. | [
"Write",
"message",
"to",
"logger",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/util.py#L54-L58 | train | 65,256 |
hearsaycorp/normalize | normalize/property/__init__.py | Property.fullname | def fullname(self):
"""Returns the name of the ``Record`` class this ``Property`` is
attached to, and attribute name it is attached as."""
if not self.bound:
if self.name is not None:
return "(unbound).%s" % self.name
else:
return "(unbound... | python | def fullname(self):
"""Returns the name of the ``Record`` class this ``Property`` is
attached to, and attribute name it is attached as."""
if not self.bound:
if self.name is not None:
return "(unbound).%s" % self.name
else:
return "(unbound... | [
"def",
"fullname",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"bound",
":",
"if",
"self",
".",
"name",
"is",
"not",
"None",
":",
"return",
"\"(unbound).%s\"",
"%",
"self",
".",
"name",
"else",
":",
"return",
"\"(unbound)\"",
"elif",
"not",
"self"... | Returns the name of the ``Record`` class this ``Property`` is
attached to, and attribute name it is attached as. | [
"Returns",
"the",
"name",
"of",
"the",
"Record",
"class",
"this",
"Property",
"is",
"attached",
"to",
"and",
"attribute",
"name",
"it",
"is",
"attached",
"as",
"."
] | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/property/__init__.py#L189-L201 | train | 65,257 |
zhanglab/psamm | psamm/commands/robustness.py | RobustnessCommand.run | def run(self):
"""Run robustness command."""
reaction = self._get_objective()
if not self._mm.has_reaction(reaction):
self.fail('Specified biomass reaction is not in model: {}'.format(
reaction))
varying_reaction = self._args.varying
if not self._mm.... | python | def run(self):
"""Run robustness command."""
reaction = self._get_objective()
if not self._mm.has_reaction(reaction):
self.fail('Specified biomass reaction is not in model: {}'.format(
reaction))
varying_reaction = self._args.varying
if not self._mm.... | [
"def",
"run",
"(",
"self",
")",
":",
"reaction",
"=",
"self",
".",
"_get_objective",
"(",
")",
"if",
"not",
"self",
".",
"_mm",
".",
"has_reaction",
"(",
"reaction",
")",
":",
"self",
".",
"fail",
"(",
"'Specified biomass reaction is not in model: {}'",
".",... | Run robustness command. | [
"Run",
"robustness",
"command",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/robustness.py#L63-L146 | train | 65,258 |
zhanglab/psamm | psamm/lpsolver/glpk.py | Problem.set_objective | def set_objective(self, expression):
"""Set objective of problem."""
if isinstance(expression, numbers.Number):
# Allow expressions with no variables as objective,
# represented as a number
expression = Expression(offset=expression)
# Clear previous objectiv... | python | def set_objective(self, expression):
"""Set objective of problem."""
if isinstance(expression, numbers.Number):
# Allow expressions with no variables as objective,
# represented as a number
expression = Expression(offset=expression)
# Clear previous objectiv... | [
"def",
"set_objective",
"(",
"self",
",",
"expression",
")",
":",
"if",
"isinstance",
"(",
"expression",
",",
"numbers",
".",
"Number",
")",
":",
"# Allow expressions with no variables as objective,",
"# represented as a number",
"expression",
"=",
"Expression",
"(",
... | Set objective of problem. | [
"Set",
"objective",
"of",
"problem",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/glpk.py#L242-L258 | train | 65,259 |
zhanglab/psamm | psamm/lpsolver/glpk.py | Result.status | def status(self):
"""Return string indicating the error encountered on failure."""
self._check_valid()
if self._ret_val == swiglpk.GLP_ENOPFS:
return 'No primal feasible solution'
elif self._ret_val == swiglpk.GLP_ENODFS:
return 'No dual feasible solution'
... | python | def status(self):
"""Return string indicating the error encountered on failure."""
self._check_valid()
if self._ret_val == swiglpk.GLP_ENOPFS:
return 'No primal feasible solution'
elif self._ret_val == swiglpk.GLP_ENODFS:
return 'No dual feasible solution'
... | [
"def",
"status",
"(",
"self",
")",
":",
"self",
".",
"_check_valid",
"(",
")",
"if",
"self",
".",
"_ret_val",
"==",
"swiglpk",
".",
"GLP_ENOPFS",
":",
"return",
"'No primal feasible solution'",
"elif",
"self",
".",
"_ret_val",
"==",
"swiglpk",
".",
"GLP_ENOD... | Return string indicating the error encountered on failure. | [
"Return",
"string",
"indicating",
"the",
"error",
"encountered",
"on",
"failure",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/glpk.py#L407-L414 | train | 65,260 |
zhanglab/psamm | psamm/mapmaker.py | default_weight | def default_weight(element):
"""Return weight of formula element.
This implements the default weight proposed for MapMaker.
"""
if element in (Atom.N, Atom.O, Atom.P):
return 0.4
elif isinstance(element, Radical):
return 40.0
return 1.0 | python | def default_weight(element):
"""Return weight of formula element.
This implements the default weight proposed for MapMaker.
"""
if element in (Atom.N, Atom.O, Atom.P):
return 0.4
elif isinstance(element, Radical):
return 40.0
return 1.0 | [
"def",
"default_weight",
"(",
"element",
")",
":",
"if",
"element",
"in",
"(",
"Atom",
".",
"N",
",",
"Atom",
".",
"O",
",",
"Atom",
".",
"P",
")",
":",
"return",
"0.4",
"elif",
"isinstance",
"(",
"element",
",",
"Radical",
")",
":",
"return",
"40.... | Return weight of formula element.
This implements the default weight proposed for MapMaker. | [
"Return",
"weight",
"of",
"formula",
"element",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/mapmaker.py#L31-L40 | train | 65,261 |
zhanglab/psamm | psamm/mapmaker.py | _weighted_formula | def _weighted_formula(form, weight_func):
"""Yield weight of each formula element."""
for e, mf in form.items():
if e == Atom.H:
continue
yield e, mf, weight_func(e) | python | def _weighted_formula(form, weight_func):
"""Yield weight of each formula element."""
for e, mf in form.items():
if e == Atom.H:
continue
yield e, mf, weight_func(e) | [
"def",
"_weighted_formula",
"(",
"form",
",",
"weight_func",
")",
":",
"for",
"e",
",",
"mf",
"in",
"form",
".",
"items",
"(",
")",
":",
"if",
"e",
"==",
"Atom",
".",
"H",
":",
"continue",
"yield",
"e",
",",
"mf",
",",
"weight_func",
"(",
"e",
")... | Yield weight of each formula element. | [
"Yield",
"weight",
"of",
"each",
"formula",
"element",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/mapmaker.py#L43-L49 | train | 65,262 |
zhanglab/psamm | psamm/mapmaker.py | _transfers | def _transfers(reaction, delta, elements, result, epsilon):
"""Yield transfers obtained from result."""
left = set(c for c, _ in reaction.left)
right = set(c for c, _ in reaction.right)
for c1, c2 in product(left, right):
items = {}
for e in elements:
v = result.get_value(del... | python | def _transfers(reaction, delta, elements, result, epsilon):
"""Yield transfers obtained from result."""
left = set(c for c, _ in reaction.left)
right = set(c for c, _ in reaction.right)
for c1, c2 in product(left, right):
items = {}
for e in elements:
v = result.get_value(del... | [
"def",
"_transfers",
"(",
"reaction",
",",
"delta",
",",
"elements",
",",
"result",
",",
"epsilon",
")",
":",
"left",
"=",
"set",
"(",
"c",
"for",
"c",
",",
"_",
"in",
"reaction",
".",
"left",
")",
"right",
"=",
"set",
"(",
"c",
"for",
"c",
",",
... | Yield transfers obtained from result. | [
"Yield",
"transfers",
"obtained",
"from",
"result",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/mapmaker.py#L52-L67 | train | 65,263 |
hearsaycorp/normalize | normalize/coll.py | _make_generic | def _make_generic(of, coll):
"""Used to make a new Collection type, without that type having to be
defined explicitly. Generates a new type name using the item type and a
'suffix' Collection class property.
args:
``of=``\ *Record type*
The type of values of the collection
... | python | def _make_generic(of, coll):
"""Used to make a new Collection type, without that type having to be
defined explicitly. Generates a new type name using the item type and a
'suffix' Collection class property.
args:
``of=``\ *Record type*
The type of values of the collection
... | [
"def",
"_make_generic",
"(",
"of",
",",
"coll",
")",
":",
"assert",
"(",
"issubclass",
"(",
"coll",
",",
"Collection",
")",
")",
"key",
"=",
"(",
"coll",
".",
"__name__",
",",
"\"%s.%s\"",
"%",
"(",
"of",
".",
"__module__",
",",
"of",
".",
"__name__"... | Used to make a new Collection type, without that type having to be
defined explicitly. Generates a new type name using the item type and a
'suffix' Collection class property.
args:
``of=``\ *Record type*
The type of values of the collection
``coll=``\ *Collection sub-class*
... | [
"Used",
"to",
"make",
"a",
"new",
"Collection",
"type",
"without",
"that",
"type",
"having",
"to",
"be",
"defined",
"explicitly",
".",
"Generates",
"a",
"new",
"type",
"name",
"using",
"the",
"item",
"type",
"and",
"a",
"suffix",
"Collection",
"class",
"pr... | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/coll.py#L470-L498 | train | 65,264 |
hearsaycorp/normalize | normalize/coll.py | Collection.coerce_value | def coerce_value(cls, v):
"""Coerce a value to the right type for the collection, or return it if
it is already of the right type."""
if isinstance(v, cls.itemtype):
return v
else:
try:
return cls.coerceitem(v)
except Exception as e:
... | python | def coerce_value(cls, v):
"""Coerce a value to the right type for the collection, or return it if
it is already of the right type."""
if isinstance(v, cls.itemtype):
return v
else:
try:
return cls.coerceitem(v)
except Exception as e:
... | [
"def",
"coerce_value",
"(",
"cls",
",",
"v",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"cls",
".",
"itemtype",
")",
":",
"return",
"v",
"else",
":",
"try",
":",
"return",
"cls",
".",
"coerceitem",
"(",
"v",
")",
"except",
"Exception",
"as",
"e",... | Coerce a value to the right type for the collection, or return it if
it is already of the right type. | [
"Coerce",
"a",
"value",
"to",
"the",
"right",
"type",
"for",
"the",
"collection",
"or",
"return",
"it",
"if",
"it",
"is",
"already",
"of",
"the",
"right",
"type",
"."
] | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/coll.py#L133-L147 | train | 65,265 |
hearsaycorp/normalize | normalize/coll.py | ListCollection.extend | def extend(self, iterable):
"""Adds new values to the end of the collection, coercing items.
"""
# perhaps: self[len(self):len(self)] = iterable
self._values.extend(self.coerce_value(item) for item in iterable) | python | def extend(self, iterable):
"""Adds new values to the end of the collection, coercing items.
"""
# perhaps: self[len(self):len(self)] = iterable
self._values.extend(self.coerce_value(item) for item in iterable) | [
"def",
"extend",
"(",
"self",
",",
"iterable",
")",
":",
"# perhaps: self[len(self):len(self)] = iterable",
"self",
".",
"_values",
".",
"extend",
"(",
"self",
".",
"coerce_value",
"(",
"item",
")",
"for",
"item",
"in",
"iterable",
")"
] | Adds new values to the end of the collection, coercing items. | [
"Adds",
"new",
"values",
"to",
"the",
"end",
"of",
"the",
"collection",
"coercing",
"items",
"."
] | 8b36522ddca6d41b434580bd848f3bdaa7a999c8 | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/coll.py#L344-L348 | train | 65,266 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.parse_response | def parse_response(self, connection, command_name, **options):
"""
Parses a response from the ssdb server
"""
response = connection.read_response()
if command_name in self.response_callbacks and len(response):
status = nativestr(response[0])
if status == R... | python | def parse_response(self, connection, command_name, **options):
"""
Parses a response from the ssdb server
"""
response = connection.read_response()
if command_name in self.response_callbacks and len(response):
status = nativestr(response[0])
if status == R... | [
"def",
"parse_response",
"(",
"self",
",",
"connection",
",",
"command_name",
",",
"*",
"*",
"options",
")",
":",
"response",
"=",
"connection",
".",
"read_response",
"(",
")",
"if",
"command_name",
"in",
"self",
".",
"response_callbacks",
"and",
"len",
"(",... | Parses a response from the ssdb server | [
"Parses",
"a",
"response",
"from",
"the",
"ssdb",
"server"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L227-L242 | train | 65,267 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.incr | def incr(self, name, amount=1):
"""
Increase the value at key ``name`` by ``amount``. If no key exists, the value
will be initialized as ``amount`` .
Like **Redis.INCR**
:param string name: the key name
:param int amount: increments
:return: the integer value at... | python | def incr(self, name, amount=1):
"""
Increase the value at key ``name`` by ``amount``. If no key exists, the value
will be initialized as ``amount`` .
Like **Redis.INCR**
:param string name: the key name
:param int amount: increments
:return: the integer value at... | [
"def",
"incr",
"(",
"self",
",",
"name",
",",
"amount",
"=",
"1",
")",
":",
"amount",
"=",
"get_integer",
"(",
"'amount'",
",",
"amount",
")",
"return",
"self",
".",
"execute_command",
"(",
"'incr'",
",",
"name",
",",
"amount",
")"
] | Increase the value at key ``name`` by ``amount``. If no key exists, the value
will be initialized as ``amount`` .
Like **Redis.INCR**
:param string name: the key name
:param int amount: increments
:return: the integer value at key ``name``
:rtype: int
>>> ssdb.... | [
"Increase",
"the",
"value",
"at",
"key",
"name",
"by",
"amount",
".",
"If",
"no",
"key",
"exists",
"the",
"value",
"will",
"be",
"initialized",
"as",
"amount",
"."
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L426-L448 | train | 65,268 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.decr | def decr(self, name, amount=1):
"""
Decrease the value at key ``name`` by ``amount``. If no key exists, the value
will be initialized as 0 - ``amount`` .
Like **Redis.DECR**
:param string name: the key name
:param int amount: decrements
:return: the integer valu... | python | def decr(self, name, amount=1):
"""
Decrease the value at key ``name`` by ``amount``. If no key exists, the value
will be initialized as 0 - ``amount`` .
Like **Redis.DECR**
:param string name: the key name
:param int amount: decrements
:return: the integer valu... | [
"def",
"decr",
"(",
"self",
",",
"name",
",",
"amount",
"=",
"1",
")",
":",
"amount",
"=",
"get_positive_integer",
"(",
"'amount'",
",",
"amount",
")",
"return",
"self",
".",
"execute_command",
"(",
"'decr'",
",",
"name",
",",
"amount",
")"
] | Decrease the value at key ``name`` by ``amount``. If no key exists, the value
will be initialized as 0 - ``amount`` .
Like **Redis.DECR**
:param string name: the key name
:param int amount: decrements
:return: the integer value at key ``name``
:rtype: int
>>> s... | [
"Decrease",
"the",
"value",
"at",
"key",
"name",
"by",
"amount",
".",
"If",
"no",
"key",
"exists",
"the",
"value",
"will",
"be",
"initialized",
"as",
"0",
"-",
"amount",
"."
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L450-L470 | train | 65,269 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.getbit | def getbit(self, name, offset):
"""
Returns a boolean indicating the value of ``offset`` in ``name``
Like **Redis.GETBIT**
:param string name: the key name
:param int offset: the bit position
:param bool val: the bit value
:return: the bit at the ``offset`` , ``... | python | def getbit(self, name, offset):
"""
Returns a boolean indicating the value of ``offset`` in ``name``
Like **Redis.GETBIT**
:param string name: the key name
:param int offset: the bit position
:param bool val: the bit value
:return: the bit at the ``offset`` , ``... | [
"def",
"getbit",
"(",
"self",
",",
"name",
",",
"offset",
")",
":",
"offset",
"=",
"get_positive_integer",
"(",
"'offset'",
",",
"offset",
")",
"return",
"self",
".",
"execute_command",
"(",
"'getbit'",
",",
"name",
",",
"offset",
")"
] | Returns a boolean indicating the value of ``offset`` in ``name``
Like **Redis.GETBIT**
:param string name: the key name
:param int offset: the bit position
:param bool val: the bit value
:return: the bit at the ``offset`` , ``False`` if key doesn't exist or
offset exce... | [
"Returns",
"a",
"boolean",
"indicating",
"the",
"value",
"of",
"offset",
"in",
"name"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L472-L493 | train | 65,270 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.countbit | def countbit(self, name, start=None, size=None):
"""
Returns the count of set bits in the value of ``key``. Optional
``start`` and ``size`` paramaters indicate which bytes to consider.
Similiar with **Redis.BITCOUNT**
:param string name: the key name
:param int start: ... | python | def countbit(self, name, start=None, size=None):
"""
Returns the count of set bits in the value of ``key``. Optional
``start`` and ``size`` paramaters indicate which bytes to consider.
Similiar with **Redis.BITCOUNT**
:param string name: the key name
:param int start: ... | [
"def",
"countbit",
"(",
"self",
",",
"name",
",",
"start",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"if",
"start",
"is",
"not",
"None",
"and",
"size",
"is",
"not",
"None",
":",
"start",
"=",
"get_integer",
"(",
"'start'",
",",
"start",
")",... | Returns the count of set bits in the value of ``key``. Optional
``start`` and ``size`` paramaters indicate which bytes to consider.
Similiar with **Redis.BITCOUNT**
:param string name: the key name
:param int start: Optional, if start is negative, count from start'th
characte... | [
"Returns",
"the",
"count",
"of",
"set",
"bits",
"in",
"the",
"value",
"of",
"key",
".",
"Optional",
"start",
"and",
"size",
"paramaters",
"indicate",
"which",
"bytes",
"to",
"consider",
"."
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L523-L556 | train | 65,271 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.substr | def substr(self, name, start=None, size=None):
"""
Return a substring of the string at key ``name``. ``start`` and ``size``
are 0-based integers specifying the portion of the string to return.
Like **Redis.SUBSTR**
:param string name: the key name
:param int start: Opti... | python | def substr(self, name, start=None, size=None):
"""
Return a substring of the string at key ``name``. ``start`` and ``size``
are 0-based integers specifying the portion of the string to return.
Like **Redis.SUBSTR**
:param string name: the key name
:param int start: Opti... | [
"def",
"substr",
"(",
"self",
",",
"name",
",",
"start",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"if",
"start",
"is",
"not",
"None",
"and",
"size",
"is",
"not",
"None",
":",
"start",
"=",
"get_integer",
"(",
"'start'",
",",
"start",
")",
... | Return a substring of the string at key ``name``. ``start`` and ``size``
are 0-based integers specifying the portion of the string to return.
Like **Redis.SUBSTR**
:param string name: the key name
:param int start: Optional, the offset of first byte returned. If start
is negat... | [
"Return",
"a",
"substring",
"of",
"the",
"string",
"at",
"key",
"name",
".",
"start",
"and",
"size",
"are",
"0",
"-",
"based",
"integers",
"specifying",
"the",
"portion",
"of",
"the",
"string",
"to",
"return",
"."
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L559-L591 | train | 65,272 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.keys | def keys(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` keys between ``name_start`` and
``name_end``
Similiar with **Redis.KEYS**
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``na... | python | def keys(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` keys between ``name_start`` and
``name_end``
Similiar with **Redis.KEYS**
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``na... | [
"def",
"keys",
"(",
"self",
",",
"name_start",
",",
"name_end",
",",
"limit",
"=",
"10",
")",
":",
"limit",
"=",
"get_positive_integer",
"(",
"'limit'",
",",
"limit",
")",
"return",
"self",
".",
"execute_command",
"(",
"'keys'",
",",
"name_start",
",",
"... | Return a list of the top ``limit`` keys between ``name_start`` and
``name_end``
Similiar with **Redis.KEYS**
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``name_end`` is.
:param string name_start: The lower bound(not ... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"keys",
"between",
"name_start",
"and",
"name_end"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L664-L692 | train | 65,273 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.hincr | def hincr(self, name, key, amount=1):
"""
Increase the value of ``key`` in hash ``name`` by ``amount``. If no key
exists, the value will be initialized as ``amount``
Like **Redis.HINCR**
:param string name: the hash name
:param string key: the key name
... | python | def hincr(self, name, key, amount=1):
"""
Increase the value of ``key`` in hash ``name`` by ``amount``. If no key
exists, the value will be initialized as ``amount``
Like **Redis.HINCR**
:param string name: the hash name
:param string key: the key name
... | [
"def",
"hincr",
"(",
"self",
",",
"name",
",",
"key",
",",
"amount",
"=",
"1",
")",
":",
"amount",
"=",
"get_integer",
"(",
"'amount'",
",",
"amount",
")",
"return",
"self",
".",
"execute_command",
"(",
"'hincr'",
",",
"name",
",",
"key",
",",
"amoun... | Increase the value of ``key`` in hash ``name`` by ``amount``. If no key
exists, the value will be initialized as ``amount``
Like **Redis.HINCR**
:param string name: the hash name
:param string key: the key name
:param int amount: increments
:return: the ... | [
"Increase",
"the",
"value",
"of",
"key",
"in",
"hash",
"name",
"by",
"amount",
".",
"If",
"no",
"key",
"exists",
"the",
"value",
"will",
"be",
"initialized",
"as",
"amount"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L869-L892 | train | 65,274 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.hdecr | def hdecr(self, name, key, amount=1):
"""
Decrease the value of ``key`` in hash ``name`` by ``amount``. If no key
exists, the value will be initialized as 0 - ``amount``
:param string name: the hash name
:param string key: the key name
:param int amount: increme... | python | def hdecr(self, name, key, amount=1):
"""
Decrease the value of ``key`` in hash ``name`` by ``amount``. If no key
exists, the value will be initialized as 0 - ``amount``
:param string name: the hash name
:param string key: the key name
:param int amount: increme... | [
"def",
"hdecr",
"(",
"self",
",",
"name",
",",
"key",
",",
"amount",
"=",
"1",
")",
":",
"amount",
"=",
"get_positive_integer",
"(",
"'amount'",
",",
"amount",
")",
"return",
"self",
".",
"execute_command",
"(",
"'hdecr'",
",",
"name",
",",
"key",
",",... | Decrease the value of ``key`` in hash ``name`` by ``amount``. If no key
exists, the value will be initialized as 0 - ``amount``
:param string name: the hash name
:param string key: the key name
:param int amount: increments
:return: the integer value of ``key`` in hash ... | [
"Decrease",
"the",
"value",
"of",
"key",
"in",
"hash",
"name",
"by",
"amount",
".",
"If",
"no",
"key",
"exists",
"the",
"value",
"will",
"be",
"initialized",
"as",
"0",
"-",
"amount"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L894-L915 | train | 65,275 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.hkeys | def hkeys(self, name, key_start, key_end, limit=10):
"""
Return a list of the top ``limit`` keys between ``key_start`` and
``key_end`` in hash ``name``
Similiar with **Redis.HKEYS**
.. note:: The range is (``key_start``, ``key_end``]. The ``key_start``
isn't ... | python | def hkeys(self, name, key_start, key_end, limit=10):
"""
Return a list of the top ``limit`` keys between ``key_start`` and
``key_end`` in hash ``name``
Similiar with **Redis.HKEYS**
.. note:: The range is (``key_start``, ``key_end``]. The ``key_start``
isn't ... | [
"def",
"hkeys",
"(",
"self",
",",
"name",
",",
"key_start",
",",
"key_end",
",",
"limit",
"=",
"10",
")",
":",
"limit",
"=",
"get_positive_integer",
"(",
"'limit'",
",",
"limit",
")",
"return",
"self",
".",
"execute_command",
"(",
"'hkeys'",
",",
"name",... | Return a list of the top ``limit`` keys between ``key_start`` and
``key_end`` in hash ``name``
Similiar with **Redis.HKEYS**
.. note:: The range is (``key_start``, ``key_end``]. The ``key_start``
isn't in the range, but ``key_end`` is.
:param string name: the hash n... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"keys",
"between",
"key_start",
"and",
"key_end",
"in",
"hash",
"name"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L999-L1028 | train | 65,276 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.hlist | def hlist(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` hash's name between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
... | python | def hlist(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` hash's name between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
... | [
"def",
"hlist",
"(",
"self",
",",
"name_start",
",",
"name_end",
",",
"limit",
"=",
"10",
")",
":",
"limit",
"=",
"get_positive_integer",
"(",
"'limit'",
",",
"limit",
")",
"return",
"self",
".",
"execute_command",
"(",
"'hlist'",
",",
"name_start",
",",
... | Return a list of the top ``limit`` hash's name between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
:param string name_start: The lower bound(not included) of has... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"hash",
"s",
"name",
"between",
"name_start",
"and",
"name_end",
"in",
"ascending",
"order"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1045-L1069 | train | 65,277 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.hrlist | def hrlist(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` hash's name between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
... | python | def hrlist(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` hash's name between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
... | [
"def",
"hrlist",
"(",
"self",
",",
"name_start",
",",
"name_end",
",",
"limit",
"=",
"10",
")",
":",
"limit",
"=",
"get_positive_integer",
"(",
"'limit'",
",",
"limit",
")",
"return",
"self",
".",
"execute_command",
"(",
"'hrlist'",
",",
"name_start",
",",... | Return a list of the top ``limit`` hash's name between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
:param string name_start: The lower bound(not included) of ha... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"hash",
"s",
"name",
"between",
"name_start",
"and",
"name_end",
"in",
"descending",
"order"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1071-L1095 | train | 65,278 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.zset | def zset(self, name, key, score=1):
"""
Set the score of ``key`` from the zset ``name`` to ``score``
Like **Redis.ZADD**
:param string name: the zset name
:param string key: the key name
:param int score: the score for ranking
:return: ``True`` if ``zset`` creat... | python | def zset(self, name, key, score=1):
"""
Set the score of ``key`` from the zset ``name`` to ``score``
Like **Redis.ZADD**
:param string name: the zset name
:param string key: the key name
:param int score: the score for ranking
:return: ``True`` if ``zset`` creat... | [
"def",
"zset",
"(",
"self",
",",
"name",
",",
"key",
",",
"score",
"=",
"1",
")",
":",
"score",
"=",
"get_integer",
"(",
"'score'",
",",
"score",
")",
"return",
"self",
".",
"execute_command",
"(",
"'zset'",
",",
"name",
",",
"key",
",",
"score",
"... | Set the score of ``key`` from the zset ``name`` to ``score``
Like **Redis.ZADD**
:param string name: the zset name
:param string key: the key name
:param int score: the score for ranking
:return: ``True`` if ``zset`` created a new score, otherwise ``False``
:rtype: bool... | [
"Set",
"the",
"score",
"of",
"key",
"from",
"the",
"zset",
"name",
"to",
"score"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1159-L1181 | train | 65,279 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.zincr | def zincr(self, name, key, amount=1):
"""
Increase the score of ``key`` in zset ``name`` by ``amount``. If no key
exists, the value will be initialized as ``amount``
Like **Redis.ZINCR**
:param string name: the zset name
:param string key: the key name
:... | python | def zincr(self, name, key, amount=1):
"""
Increase the score of ``key`` in zset ``name`` by ``amount``. If no key
exists, the value will be initialized as ``amount``
Like **Redis.ZINCR**
:param string name: the zset name
:param string key: the key name
:... | [
"def",
"zincr",
"(",
"self",
",",
"name",
",",
"key",
",",
"amount",
"=",
"1",
")",
":",
"amount",
"=",
"get_integer",
"(",
"'amount'",
",",
"amount",
")",
"return",
"self",
".",
"execute_command",
"(",
"'zincr'",
",",
"name",
",",
"key",
",",
"amoun... | Increase the score of ``key`` in zset ``name`` by ``amount``. If no key
exists, the value will be initialized as ``amount``
Like **Redis.ZINCR**
:param string name: the zset name
:param string key: the key name
:param int amount: increments
:return: the integer ... | [
"Increase",
"the",
"score",
"of",
"key",
"in",
"zset",
"name",
"by",
"amount",
".",
"If",
"no",
"key",
"exists",
"the",
"value",
"will",
"be",
"initialized",
"as",
"amount"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1275-L1298 | train | 65,280 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.zdecr | def zdecr(self, name, key, amount=1):
"""
Decrease the value of ``key`` in zset ``name`` by ``amount``. If no key
exists, the value will be initialized as 0 - ``amount``
:param string name: the zset name
:param string key: the key name
:param int amount: increme... | python | def zdecr(self, name, key, amount=1):
"""
Decrease the value of ``key`` in zset ``name`` by ``amount``. If no key
exists, the value will be initialized as 0 - ``amount``
:param string name: the zset name
:param string key: the key name
:param int amount: increme... | [
"def",
"zdecr",
"(",
"self",
",",
"name",
",",
"key",
",",
"amount",
"=",
"1",
")",
":",
"amount",
"=",
"get_positive_integer",
"(",
"'amount'",
",",
"amount",
")",
"return",
"self",
".",
"execute_command",
"(",
"'zdecr'",
",",
"name",
",",
"key",
",",... | Decrease the value of ``key`` in zset ``name`` by ``amount``. If no key
exists, the value will be initialized as 0 - ``amount``
:param string name: the zset name
:param string key: the key name
:param int amount: increments
:return: the integer value of ``key`` in zset ... | [
"Decrease",
"the",
"value",
"of",
"key",
"in",
"zset",
"name",
"by",
"amount",
".",
"If",
"no",
"key",
"exists",
"the",
"value",
"will",
"be",
"initialized",
"as",
"0",
"-",
"amount"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1300-L1321 | train | 65,281 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.zlist | def zlist(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` zset's name between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
... | python | def zlist(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` zset's name between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
... | [
"def",
"zlist",
"(",
"self",
",",
"name_start",
",",
"name_end",
",",
"limit",
"=",
"10",
")",
":",
"limit",
"=",
"get_positive_integer",
"(",
"'limit'",
",",
"limit",
")",
"return",
"self",
".",
"execute_command",
"(",
"'zlist'",
",",
"name_start",
",",
... | Return a list of the top ``limit`` zset's name between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
:param string name_start: The lower bound(not included) of zse... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"zset",
"s",
"name",
"between",
"name_start",
"and",
"name_end",
"in",
"ascending",
"order"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1401-L1425 | train | 65,282 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.zrlist | def zrlist(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` zset's name between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
... | python | def zrlist(self, name_start, name_end, limit=10):
"""
Return a list of the top ``limit`` zset's name between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
... | [
"def",
"zrlist",
"(",
"self",
",",
"name_start",
",",
"name_end",
",",
"limit",
"=",
"10",
")",
":",
"limit",
"=",
"get_positive_integer",
"(",
"'limit'",
",",
"limit",
")",
"return",
"self",
".",
"execute_command",
"(",
"'zrlist'",
",",
"name_start",
",",... | Return a list of the top ``limit`` zset's name between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. The ``name_start``
isn't in the range, but ``name_end`` is.
:param string name_start: The lower bound(not included) of zs... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"zset",
"s",
"name",
"between",
"name_start",
"and",
"name_end",
"in",
"descending",
"order"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1427-L1451 | train | 65,283 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.zkeys | def zkeys(self, name, key_start, score_start, score_end, limit=10):
"""
Return a list of the top ``limit`` keys after ``key_start`` from zset
``name`` with scores between ``score_start`` and ``score_end``
.. note:: The range is (``key_start``+``score_start``, ``key_end``]. That
... | python | def zkeys(self, name, key_start, score_start, score_end, limit=10):
"""
Return a list of the top ``limit`` keys after ``key_start`` from zset
``name`` with scores between ``score_start`` and ``score_end``
.. note:: The range is (``key_start``+``score_start``, ``key_end``]. That
... | [
"def",
"zkeys",
"(",
"self",
",",
"name",
",",
"key_start",
",",
"score_start",
",",
"score_end",
",",
"limit",
"=",
"10",
")",
":",
"score_start",
"=",
"get_integer_or_emptystring",
"(",
"'score_start'",
",",
"score_start",
")",
"score_end",
"=",
"get_integer... | Return a list of the top ``limit`` keys after ``key_start`` from zset
``name`` with scores between ``score_start`` and ``score_end``
.. note:: The range is (``key_start``+``score_start``, ``key_end``]. That
means (key.score == score_start && key > key_start || key.score >
score_s... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"keys",
"after",
"key_start",
"from",
"zset",
"name",
"with",
"scores",
"between",
"score_start",
"and",
"score_end"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1453-L1484 | train | 65,284 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.zcount | def zcount(self, name, score_start, score_end):
"""
Returns the number of elements in the sorted set at key ``name`` with
a score between ``score_start`` and ``score_end``.
Like **Redis.ZCOUNT**
.. note:: The range is [``score_start``, ``score_end``]
:param string name... | python | def zcount(self, name, score_start, score_end):
"""
Returns the number of elements in the sorted set at key ``name`` with
a score between ``score_start`` and ``score_end``.
Like **Redis.ZCOUNT**
.. note:: The range is [``score_start``, ``score_end``]
:param string name... | [
"def",
"zcount",
"(",
"self",
",",
"name",
",",
"score_start",
",",
"score_end",
")",
":",
"score_start",
"=",
"get_integer_or_emptystring",
"(",
"'score_start'",
",",
"score_start",
")",
"score_end",
"=",
"get_integer_or_emptystring",
"(",
"'score_end'",
",",
"sc... | Returns the number of elements in the sorted set at key ``name`` with
a score between ``score_start`` and ``score_end``.
Like **Redis.ZCOUNT**
.. note:: The range is [``score_start``, ``score_end``]
:param string name: the zset name
:param int score_start: The minimum score re... | [
"Returns",
"the",
"number",
"of",
"elements",
"in",
"the",
"sorted",
"set",
"at",
"key",
"name",
"with",
"a",
"score",
"between",
"score_start",
"and",
"score_end",
"."
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1660-L1686 | train | 65,285 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.qget | def qget(self, name, index):
"""
Get the element of ``index`` within the queue ``name``
:param string name: the queue name
:param int index: the specified index, can < 0
:return: the value at ``index`` within queue ``name`` , or ``None`` if the
element doesn't exist
... | python | def qget(self, name, index):
"""
Get the element of ``index`` within the queue ``name``
:param string name: the queue name
:param int index: the specified index, can < 0
:return: the value at ``index`` within queue ``name`` , or ``None`` if the
element doesn't exist
... | [
"def",
"qget",
"(",
"self",
",",
"name",
",",
"index",
")",
":",
"index",
"=",
"get_integer",
"(",
"'index'",
",",
"index",
")",
"return",
"self",
".",
"execute_command",
"(",
"'qget'",
",",
"name",
",",
"index",
")"
] | Get the element of ``index`` within the queue ``name``
:param string name: the queue name
:param int index: the specified index, can < 0
:return: the value at ``index`` within queue ``name`` , or ``None`` if the
element doesn't exist
:rtype: string | [
"Get",
"the",
"element",
"of",
"index",
"within",
"the",
"queue",
"name"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1793-L1805 | train | 65,286 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.qset | def qset(self, name, index, value):
"""
Set the list element at ``index`` to ``value``.
:param string name: the queue name
:param int index: the specified index, can < 0
:param string value: the element value
:return: Unknown
:rtype: True
"""
... | python | def qset(self, name, index, value):
"""
Set the list element at ``index`` to ``value``.
:param string name: the queue name
:param int index: the specified index, can < 0
:param string value: the element value
:return: Unknown
:rtype: True
"""
... | [
"def",
"qset",
"(",
"self",
",",
"name",
",",
"index",
",",
"value",
")",
":",
"index",
"=",
"get_integer",
"(",
"'index'",
",",
"index",
")",
"return",
"self",
".",
"execute_command",
"(",
"'qset'",
",",
"name",
",",
"index",
",",
"value",
")"
] | Set the list element at ``index`` to ``value``.
:param string name: the queue name
:param int index: the specified index, can < 0
:param string value: the element value
:return: Unknown
:rtype: True | [
"Set",
"the",
"list",
"element",
"at",
"index",
"to",
"value",
"."
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1807-L1819 | train | 65,287 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.qpop_front | def qpop_front(self, name, size=1):
"""
Remove and return the first ``size`` item of the list ``name``
Like **Redis.LPOP**
:param string name: the queue name
:param int size: the length of result
:return: the list of pop elements
:rtype: list
... | python | def qpop_front(self, name, size=1):
"""
Remove and return the first ``size`` item of the list ``name``
Like **Redis.LPOP**
:param string name: the queue name
:param int size: the length of result
:return: the list of pop elements
:rtype: list
... | [
"def",
"qpop_front",
"(",
"self",
",",
"name",
",",
"size",
"=",
"1",
")",
":",
"size",
"=",
"get_positive_integer",
"(",
"\"size\"",
",",
"size",
")",
"return",
"self",
".",
"execute_command",
"(",
"'qpop_front'",
",",
"name",
",",
"size",
")"
] | Remove and return the first ``size`` item of the list ``name``
Like **Redis.LPOP**
:param string name: the queue name
:param int size: the length of result
:return: the list of pop elements
:rtype: list | [
"Remove",
"and",
"return",
"the",
"first",
"size",
"item",
"of",
"the",
"list",
"name"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1851-L1864 | train | 65,288 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.qpop_back | def qpop_back(self, name, size=1):
"""
Remove and return the last ``size`` item of the list ``name``
Like **Redis.RPOP**
:param string name: the queue name
:param int size: the length of result
:return: the list of pop elements
:rtype: list
"""
... | python | def qpop_back(self, name, size=1):
"""
Remove and return the last ``size`` item of the list ``name``
Like **Redis.RPOP**
:param string name: the queue name
:param int size: the length of result
:return: the list of pop elements
:rtype: list
"""
... | [
"def",
"qpop_back",
"(",
"self",
",",
"name",
",",
"size",
"=",
"1",
")",
":",
"size",
"=",
"get_positive_integer",
"(",
"\"size\"",
",",
"size",
")",
"return",
"self",
".",
"execute_command",
"(",
"'qpop_back'",
",",
"name",
",",
"size",
")"
] | Remove and return the last ``size`` item of the list ``name``
Like **Redis.RPOP**
:param string name: the queue name
:param int size: the length of result
:return: the list of pop elements
:rtype: list | [
"Remove",
"and",
"return",
"the",
"last",
"size",
"item",
"of",
"the",
"list",
"name"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1867-L1880 | train | 65,289 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.qlist | def qlist(self, name_start, name_end, limit):
"""
Return a list of the top ``limit`` keys between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``name_end`` is.
:param... | python | def qlist(self, name_start, name_end, limit):
"""
Return a list of the top ``limit`` keys between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``name_end`` is.
:param... | [
"def",
"qlist",
"(",
"self",
",",
"name_start",
",",
"name_end",
",",
"limit",
")",
":",
"limit",
"=",
"get_positive_integer",
"(",
"\"limit\"",
",",
"limit",
")",
"return",
"self",
".",
"execute_command",
"(",
"'qlist'",
",",
"name_start",
",",
"name_end",
... | Return a list of the top ``limit`` keys between ``name_start`` and
``name_end`` in ascending order
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``name_end`` is.
:param string name_start: The lower bound(not included) of keys to be
... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"keys",
"between",
"name_start",
"and",
"name_end",
"in",
"ascending",
"order"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1914-L1938 | train | 65,290 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.qrlist | def qrlist(self, name_start, name_end, limit):
"""
Return a list of the top ``limit`` keys between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``name_end`` is.
:par... | python | def qrlist(self, name_start, name_end, limit):
"""
Return a list of the top ``limit`` keys between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``name_end`` is.
:par... | [
"def",
"qrlist",
"(",
"self",
",",
"name_start",
",",
"name_end",
",",
"limit",
")",
":",
"limit",
"=",
"get_positive_integer",
"(",
"\"limit\"",
",",
"limit",
")",
"return",
"self",
".",
"execute_command",
"(",
"'qrlist'",
",",
"name_start",
",",
"name_end"... | Return a list of the top ``limit`` keys between ``name_start`` and
``name_end`` in descending order
.. note:: The range is (``name_start``, ``name_end``]. ``name_start``
isn't in the range, but ``name_end`` is.
:param string name_start: The lower bound(not included) of keys to be
... | [
"Return",
"a",
"list",
"of",
"the",
"top",
"limit",
"keys",
"between",
"name_start",
"and",
"name_end",
"in",
"descending",
"order"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1940-L1964 | train | 65,291 |
wrongwaycn/ssdb-py | ssdb/client.py | StrictSSDB.qrange | def qrange(self, name, offset, limit):
"""
Return a ``limit`` slice of the list ``name`` at position ``offset``
``offset`` can be negative numbers just like Python slicing notation
Similiar with **Redis.LRANGE**
:param string name: the queue name
:param int offset: the... | python | def qrange(self, name, offset, limit):
"""
Return a ``limit`` slice of the list ``name`` at position ``offset``
``offset`` can be negative numbers just like Python slicing notation
Similiar with **Redis.LRANGE**
:param string name: the queue name
:param int offset: the... | [
"def",
"qrange",
"(",
"self",
",",
"name",
",",
"offset",
",",
"limit",
")",
":",
"offset",
"=",
"get_integer",
"(",
"'offset'",
",",
"offset",
")",
"limit",
"=",
"get_positive_integer",
"(",
"'limit'",
",",
"limit",
")",
"return",
"self",
".",
"execute_... | Return a ``limit`` slice of the list ``name`` at position ``offset``
``offset`` can be negative numbers just like Python slicing notation
Similiar with **Redis.LRANGE**
:param string name: the queue name
:param int offset: the returned list will start at this offset
:param int... | [
"Return",
"a",
"limit",
"slice",
"of",
"the",
"list",
"name",
"at",
"position",
"offset"
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L1988-L2005 | train | 65,292 |
wrongwaycn/ssdb-py | ssdb/client.py | SSDB.setx | def setx(self, name, value, ttl):
"""
Set the value of key ``name`` to ``value`` that expires in ``ttl``
seconds. ``ttl`` can be represented by an integer or a Python
timedelta object.
Like **Redis.SETEX**
:param string name: the key name
:param string value: a ... | python | def setx(self, name, value, ttl):
"""
Set the value of key ``name`` to ``value`` that expires in ``ttl``
seconds. ``ttl`` can be represented by an integer or a Python
timedelta object.
Like **Redis.SETEX**
:param string name: the key name
:param string value: a ... | [
"def",
"setx",
"(",
"self",
",",
"name",
",",
"value",
",",
"ttl",
")",
":",
"if",
"isinstance",
"(",
"ttl",
",",
"datetime",
".",
"timedelta",
")",
":",
"ttl",
"=",
"ttl",
".",
"seconds",
"+",
"ttl",
".",
"days",
"*",
"24",
"*",
"3600",
"ttl",
... | Set the value of key ``name`` to ``value`` that expires in ``ttl``
seconds. ``ttl`` can be represented by an integer or a Python
timedelta object.
Like **Redis.SETEX**
:param string name: the key name
:param string value: a string or an object can be converted to string
... | [
"Set",
"the",
"value",
"of",
"key",
"name",
"to",
"value",
"that",
"expires",
"in",
"ttl",
"seconds",
".",
"ttl",
"can",
"be",
"represented",
"by",
"an",
"integer",
"or",
"a",
"Python",
"timedelta",
"object",
"."
] | ce7b1542f0faa06fe71a60c667fe15992af0f621 | https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L2153-L2179 | train | 65,293 |
merll/docker-fabric | dockerfabric/utils/net.py | get_ip6_address | def get_ip6_address(interface_name, expand=False):
"""
Extracts the IPv6 address for a particular interface from `ifconfig`.
:param interface_name: Name of the network interface (e.g. ``eth0``).
:type interface_name: unicode
:param expand: If set to ``True``, an abbreviated address is expanded to t... | python | def get_ip6_address(interface_name, expand=False):
"""
Extracts the IPv6 address for a particular interface from `ifconfig`.
:param interface_name: Name of the network interface (e.g. ``eth0``).
:type interface_name: unicode
:param expand: If set to ``True``, an abbreviated address is expanded to t... | [
"def",
"get_ip6_address",
"(",
"interface_name",
",",
"expand",
"=",
"False",
")",
":",
"address",
"=",
"_get_address",
"(",
"interface_name",
",",
"IP6_PATTERN",
")",
"if",
"address",
"and",
"expand",
":",
"return",
"':'",
".",
"join",
"(",
"_expand_groups",
... | Extracts the IPv6 address for a particular interface from `ifconfig`.
:param interface_name: Name of the network interface (e.g. ``eth0``).
:type interface_name: unicode
:param expand: If set to ``True``, an abbreviated address is expanded to the full address.
:type expand: bool
:return: IPv6 addre... | [
"Extracts",
"the",
"IPv6",
"address",
"for",
"a",
"particular",
"interface",
"from",
"ifconfig",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/net.py#L47-L61 | train | 65,294 |
merll/docker-fabric | dockerfabric/utils/base.py | get_current_roles | def get_current_roles():
"""
Determines the list of roles, that the current host is assigned to. If ``env.roledefs`` is not set, an empty list
is returned.
:return: List of roles of the current host.
:rtype: list
"""
current_host = env.host_string
roledefs = env.get('roledefs')
if r... | python | def get_current_roles():
"""
Determines the list of roles, that the current host is assigned to. If ``env.roledefs`` is not set, an empty list
is returned.
:return: List of roles of the current host.
:rtype: list
"""
current_host = env.host_string
roledefs = env.get('roledefs')
if r... | [
"def",
"get_current_roles",
"(",
")",
":",
"current_host",
"=",
"env",
".",
"host_string",
"roledefs",
"=",
"env",
".",
"get",
"(",
"'roledefs'",
")",
"if",
"roledefs",
":",
"return",
"[",
"role",
"for",
"role",
",",
"hosts",
"in",
"six",
".",
"iteritems... | Determines the list of roles, that the current host is assigned to. If ``env.roledefs`` is not set, an empty list
is returned.
:return: List of roles of the current host.
:rtype: list | [
"Determines",
"the",
"list",
"of",
"roles",
"that",
"the",
"current",
"host",
"is",
"assigned",
"to",
".",
"If",
"env",
".",
"roledefs",
"is",
"not",
"set",
"an",
"empty",
"list",
"is",
"returned",
"."
] | 785d84e40e17265b667d8b11a6e30d8e6b2bf8d4 | https://github.com/merll/docker-fabric/blob/785d84e40e17265b667d8b11a6e30d8e6b2bf8d4/dockerfabric/utils/base.py#L11-L23 | train | 65,295 |
zhanglab/psamm | psamm/gapfilling.py | add_all_database_reactions | def add_all_database_reactions(model, compartments):
"""Add all reactions from database that occur in given compartments.
Args:
model: :class:`psamm.metabolicmodel.MetabolicModel`.
"""
added = set()
for rxnid in model.database.reactions:
reaction = model.database.get_reaction(rxnid... | python | def add_all_database_reactions(model, compartments):
"""Add all reactions from database that occur in given compartments.
Args:
model: :class:`psamm.metabolicmodel.MetabolicModel`.
"""
added = set()
for rxnid in model.database.reactions:
reaction = model.database.get_reaction(rxnid... | [
"def",
"add_all_database_reactions",
"(",
"model",
",",
"compartments",
")",
":",
"added",
"=",
"set",
"(",
")",
"for",
"rxnid",
"in",
"model",
".",
"database",
".",
"reactions",
":",
"reaction",
"=",
"model",
".",
"database",
".",
"get_reaction",
"(",
"rx... | Add all reactions from database that occur in given compartments.
Args:
model: :class:`psamm.metabolicmodel.MetabolicModel`. | [
"Add",
"all",
"reactions",
"from",
"database",
"that",
"occur",
"in",
"given",
"compartments",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfilling.py#L38-L54 | train | 65,296 |
zhanglab/psamm | psamm/gapfilling.py | add_all_exchange_reactions | def add_all_exchange_reactions(model, compartment, allow_duplicates=False):
"""Add all exchange reactions to database and to model.
Args:
model: :class:`psamm.metabolicmodel.MetabolicModel`.
"""
all_reactions = {}
if not allow_duplicates:
# TODO: Avoid adding reactions that already... | python | def add_all_exchange_reactions(model, compartment, allow_duplicates=False):
"""Add all exchange reactions to database and to model.
Args:
model: :class:`psamm.metabolicmodel.MetabolicModel`.
"""
all_reactions = {}
if not allow_duplicates:
# TODO: Avoid adding reactions that already... | [
"def",
"add_all_exchange_reactions",
"(",
"model",
",",
"compartment",
",",
"allow_duplicates",
"=",
"False",
")",
":",
"all_reactions",
"=",
"{",
"}",
"if",
"not",
"allow_duplicates",
":",
"# TODO: Avoid adding reactions that already exist in the database.",
"# This should... | Add all exchange reactions to database and to model.
Args:
model: :class:`psamm.metabolicmodel.MetabolicModel`. | [
"Add",
"all",
"exchange",
"reactions",
"to",
"database",
"and",
"to",
"model",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfilling.py#L57-L95 | train | 65,297 |
zhanglab/psamm | psamm/gapfilling.py | add_all_transport_reactions | def add_all_transport_reactions(model, boundaries, allow_duplicates=False):
"""Add all transport reactions to database and to model.
Add transport reactions for all boundaries. Boundaries are defined
by pairs (2-tuples) of compartment IDs. Transport reactions are
added for all compounds in the model, n... | python | def add_all_transport_reactions(model, boundaries, allow_duplicates=False):
"""Add all transport reactions to database and to model.
Add transport reactions for all boundaries. Boundaries are defined
by pairs (2-tuples) of compartment IDs. Transport reactions are
added for all compounds in the model, n... | [
"def",
"add_all_transport_reactions",
"(",
"model",
",",
"boundaries",
",",
"allow_duplicates",
"=",
"False",
")",
":",
"all_reactions",
"=",
"{",
"}",
"if",
"not",
"allow_duplicates",
":",
"# TODO: Avoid adding reactions that already exist in the database.",
"# This should... | Add all transport reactions to database and to model.
Add transport reactions for all boundaries. Boundaries are defined
by pairs (2-tuples) of compartment IDs. Transport reactions are
added for all compounds in the model, not just for compounds in the
two boundary compartments.
Args:
mode... | [
"Add",
"all",
"transport",
"reactions",
"to",
"database",
"and",
"to",
"model",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfilling.py#L98-L156 | train | 65,298 |
zhanglab/psamm | psamm/gapfilling.py | create_extended_model | def create_extended_model(model, db_penalty=None, ex_penalty=None,
tp_penalty=None, penalties=None):
"""Create an extended model for gap-filling.
Create a :class:`psamm.metabolicmodel.MetabolicModel` with
all reactions added (the reaction database in the model is taken
to be t... | python | def create_extended_model(model, db_penalty=None, ex_penalty=None,
tp_penalty=None, penalties=None):
"""Create an extended model for gap-filling.
Create a :class:`psamm.metabolicmodel.MetabolicModel` with
all reactions added (the reaction database in the model is taken
to be t... | [
"def",
"create_extended_model",
"(",
"model",
",",
"db_penalty",
"=",
"None",
",",
"ex_penalty",
"=",
"None",
",",
"tp_penalty",
"=",
"None",
",",
"penalties",
"=",
"None",
")",
":",
"# Create metabolic model",
"model_extended",
"=",
"model",
".",
"create_metabo... | Create an extended model for gap-filling.
Create a :class:`psamm.metabolicmodel.MetabolicModel` with
all reactions added (the reaction database in the model is taken
to be the universal database) and also with artificial exchange
and transport reactions added. Return the extended
:class:`psamm.meta... | [
"Create",
"an",
"extended",
"model",
"for",
"gap",
"-",
"filling",
"."
] | dc427848c4f9d109ca590f0afa024c63b685b3f4 | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/gapfilling.py#L159-L231 | train | 65,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.