partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Reaction.functional | All required enzymes for reaction are functional.
Returns
-------
bool
True if the gene-protein-reaction (GPR) rule is fulfilled for
this reaction, or if reaction is not associated to a model,
otherwise False. | cobra/core/reaction.py | def functional(self):
"""All required enzymes for reaction are functional.
Returns
-------
bool
True if the gene-protein-reaction (GPR) rule is fulfilled for
this reaction, or if reaction is not associated to a model,
otherwise False.
"""
... | def functional(self):
"""All required enzymes for reaction are functional.
Returns
-------
bool
True if the gene-protein-reaction (GPR) rule is fulfilled for
this reaction, or if reaction is not associated to a model,
otherwise False.
"""
... | [
"All",
"required",
"enzymes",
"for",
"reaction",
"are",
"functional",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L490-L504 | [
"def",
"functional",
"(",
"self",
")",
":",
"if",
"self",
".",
"_model",
":",
"tree",
",",
"_",
"=",
"parse_gpr",
"(",
"self",
".",
"gene_reaction_rule",
")",
"return",
"eval_gpr",
"(",
"tree",
",",
"{",
"gene",
".",
"id",
"for",
"gene",
"in",
"self"... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction._update_awareness | Make sure all metabolites and genes that are associated with
this reaction are aware of it. | cobra/core/reaction.py | def _update_awareness(self):
"""Make sure all metabolites and genes that are associated with
this reaction are aware of it.
"""
for x in self._metabolites:
x._reaction.add(self)
for x in self._genes:
x._reaction.add(self) | def _update_awareness(self):
"""Make sure all metabolites and genes that are associated with
this reaction are aware of it.
"""
for x in self._metabolites:
x._reaction.add(self)
for x in self._genes:
x._reaction.add(self) | [
"Make",
"sure",
"all",
"metabolites",
"and",
"genes",
"that",
"are",
"associated",
"with",
"this",
"reaction",
"are",
"aware",
"of",
"it",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L553-L561 | [
"def",
"_update_awareness",
"(",
"self",
")",
":",
"for",
"x",
"in",
"self",
".",
"_metabolites",
":",
"x",
".",
"_reaction",
".",
"add",
"(",
"self",
")",
"for",
"x",
"in",
"self",
".",
"_genes",
":",
"x",
".",
"_reaction",
".",
"add",
"(",
"self"... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.remove_from_model | Removes the reaction from a model.
This removes all associations between a reaction the associated
model, metabolites and genes.
The change is reverted upon exit when using the model as a context.
Parameters
----------
remove_orphans : bool
Remove orphaned ... | cobra/core/reaction.py | def remove_from_model(self, remove_orphans=False):
"""Removes the reaction from a model.
This removes all associations between a reaction the associated
model, metabolites and genes.
The change is reverted upon exit when using the model as a context.
Parameters
-------... | def remove_from_model(self, remove_orphans=False):
"""Removes the reaction from a model.
This removes all associations between a reaction the associated
model, metabolites and genes.
The change is reverted upon exit when using the model as a context.
Parameters
-------... | [
"Removes",
"the",
"reaction",
"from",
"a",
"model",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L563-L577 | [
"def",
"remove_from_model",
"(",
"self",
",",
"remove_orphans",
"=",
"False",
")",
":",
"self",
".",
"_model",
".",
"remove_reactions",
"(",
"[",
"self",
"]",
",",
"remove_orphans",
"=",
"remove_orphans",
")"
] | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.delete | Removes the reaction from a model.
This removes all associations between a reaction the associated
model, metabolites and genes.
The change is reverted upon exit when using the model as a context.
Deprecated, use `reaction.remove_from_model` instead.
Parameters
------... | cobra/core/reaction.py | def delete(self, remove_orphans=False):
"""Removes the reaction from a model.
This removes all associations between a reaction the associated
model, metabolites and genes.
The change is reverted upon exit when using the model as a context.
Deprecated, use `reaction.remove_from... | def delete(self, remove_orphans=False):
"""Removes the reaction from a model.
This removes all associations between a reaction the associated
model, metabolites and genes.
The change is reverted upon exit when using the model as a context.
Deprecated, use `reaction.remove_from... | [
"Removes",
"the",
"reaction",
"from",
"a",
"model",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L579-L597 | [
"def",
"delete",
"(",
"self",
",",
"remove_orphans",
"=",
"False",
")",
":",
"warn",
"(",
"\"delete is deprecated. Use reaction.remove_from_model instead\"",
",",
"DeprecationWarning",
")",
"self",
".",
"remove_from_model",
"(",
"remove_orphans",
"=",
"remove_orphans",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.copy | Copy a reaction
The referenced metabolites and genes are also copied. | cobra/core/reaction.py | def copy(self):
"""Copy a reaction
The referenced metabolites and genes are also copied.
"""
# no references to model when copying
model = self._model
self._model = None
for i in self._metabolites:
i._model = None
for i in self._genes:
... | def copy(self):
"""Copy a reaction
The referenced metabolites and genes are also copied.
"""
# no references to model when copying
model = self._model
self._model = None
for i in self._metabolites:
i._model = None
for i in self._genes:
... | [
"Copy",
"a",
"reaction"
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L627-L648 | [
"def",
"copy",
"(",
"self",
")",
":",
"# no references to model when copying",
"model",
"=",
"self",
".",
"_model",
"self",
".",
"_model",
"=",
"None",
"for",
"i",
"in",
"self",
".",
"_metabolites",
":",
"i",
".",
"_model",
"=",
"None",
"for",
"i",
"in",... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.get_coefficient | Return the stoichiometric coefficient of a metabolite.
Parameters
----------
metabolite_id : str or cobra.Metabolite | cobra/core/reaction.py | def get_coefficient(self, metabolite_id):
"""
Return the stoichiometric coefficient of a metabolite.
Parameters
----------
metabolite_id : str or cobra.Metabolite
"""
if isinstance(metabolite_id, Metabolite):
return self._metabolites[metabolite_id]
... | def get_coefficient(self, metabolite_id):
"""
Return the stoichiometric coefficient of a metabolite.
Parameters
----------
metabolite_id : str or cobra.Metabolite
"""
if isinstance(metabolite_id, Metabolite):
return self._metabolites[metabolite_id]
... | [
"Return",
"the",
"stoichiometric",
"coefficient",
"of",
"a",
"metabolite",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L733-L746 | [
"def",
"get_coefficient",
"(",
"self",
",",
"metabolite_id",
")",
":",
"if",
"isinstance",
"(",
"metabolite_id",
",",
"Metabolite",
")",
":",
"return",
"self",
".",
"_metabolites",
"[",
"metabolite_id",
"]",
"_id_to_metabolites",
"=",
"{",
"m",
".",
"id",
":... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.add_metabolites | Add metabolites and stoichiometric coefficients to the reaction.
If the final coefficient for a metabolite is 0 then it is removed
from the reaction.
The change is reverted upon exit when using the model as a context.
Parameters
----------
metabolites_to_add : dict
... | cobra/core/reaction.py | def add_metabolites(self, metabolites_to_add, combine=True,
reversibly=True):
"""Add metabolites and stoichiometric coefficients to the reaction.
If the final coefficient for a metabolite is 0 then it is removed
from the reaction.
The change is reverted upon exit... | def add_metabolites(self, metabolites_to_add, combine=True,
reversibly=True):
"""Add metabolites and stoichiometric coefficients to the reaction.
If the final coefficient for a metabolite is 0 then it is removed
from the reaction.
The change is reverted upon exit... | [
"Add",
"metabolites",
"and",
"stoichiometric",
"coefficients",
"to",
"the",
"reaction",
".",
"If",
"the",
"final",
"coefficient",
"for",
"a",
"metabolite",
"is",
"0",
"then",
"it",
"is",
"removed",
"from",
"the",
"reaction",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L760-L867 | [
"def",
"add_metabolites",
"(",
"self",
",",
"metabolites_to_add",
",",
"combine",
"=",
"True",
",",
"reversibly",
"=",
"True",
")",
":",
"old_coefficients",
"=",
"self",
".",
"metabolites",
"new_metabolites",
"=",
"[",
"]",
"_id_to_metabolites",
"=",
"dict",
"... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.subtract_metabolites | Subtract metabolites from a reaction.
That means add the metabolites with -1*coefficient. If the final
coefficient for a metabolite is 0 then the metabolite is removed from
the reaction.
Notes
-----
* A final coefficient < 0 implies a reactant.
* The change is r... | cobra/core/reaction.py | def subtract_metabolites(self, metabolites, combine=True, reversibly=True):
"""Subtract metabolites from a reaction.
That means add the metabolites with -1*coefficient. If the final
coefficient for a metabolite is 0 then the metabolite is removed from
the reaction.
Notes
... | def subtract_metabolites(self, metabolites, combine=True, reversibly=True):
"""Subtract metabolites from a reaction.
That means add the metabolites with -1*coefficient. If the final
coefficient for a metabolite is 0 then the metabolite is removed from
the reaction.
Notes
... | [
"Subtract",
"metabolites",
"from",
"a",
"reaction",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L869-L900 | [
"def",
"subtract_metabolites",
"(",
"self",
",",
"metabolites",
",",
"combine",
"=",
"True",
",",
"reversibly",
"=",
"True",
")",
":",
"self",
".",
"add_metabolites",
"(",
"{",
"k",
":",
"-",
"v",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"metaboli... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.build_reaction_string | Generate a human readable reaction string | cobra/core/reaction.py | def build_reaction_string(self, use_metabolite_names=False):
"""Generate a human readable reaction string"""
def format(number):
return "" if number == 1 else str(number).rstrip(".") + " "
id_type = 'id'
if use_metabolite_names:
id_type = 'name'
reactant... | def build_reaction_string(self, use_metabolite_names=False):
"""Generate a human readable reaction string"""
def format(number):
return "" if number == 1 else str(number).rstrip(".") + " "
id_type = 'id'
if use_metabolite_names:
id_type = 'name'
reactant... | [
"Generate",
"a",
"human",
"readable",
"reaction",
"string"
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L911-L939 | [
"def",
"build_reaction_string",
"(",
"self",
",",
"use_metabolite_names",
"=",
"False",
")",
":",
"def",
"format",
"(",
"number",
")",
":",
"return",
"\"\"",
"if",
"number",
"==",
"1",
"else",
"str",
"(",
"number",
")",
".",
"rstrip",
"(",
"\".\"",
")",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.check_mass_balance | Compute mass and charge balance for the reaction
returns a dict of {element: amount} for unbalanced elements.
"charge" is treated as an element in this dict
This should be empty for balanced reactions. | cobra/core/reaction.py | def check_mass_balance(self):
"""Compute mass and charge balance for the reaction
returns a dict of {element: amount} for unbalanced elements.
"charge" is treated as an element in this dict
This should be empty for balanced reactions.
"""
reaction_element_dict = defaultd... | def check_mass_balance(self):
"""Compute mass and charge balance for the reaction
returns a dict of {element: amount} for unbalanced elements.
"charge" is treated as an element in this dict
This should be empty for balanced reactions.
"""
reaction_element_dict = defaultd... | [
"Compute",
"mass",
"and",
"charge",
"balance",
"for",
"the",
"reaction"
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L941-L959 | [
"def",
"check_mass_balance",
"(",
"self",
")",
":",
"reaction_element_dict",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"metabolite",
",",
"coefficient",
"in",
"iteritems",
"(",
"self",
".",
"_metabolites",
")",
":",
"if",
"metabolite",
".",
"charge",
"is",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.compartments | lists compartments the metabolites are in | cobra/core/reaction.py | def compartments(self):
"""lists compartments the metabolites are in"""
if self._compartments is None:
self._compartments = {met.compartment for met in self._metabolites
if met.compartment is not None}
return self._compartments | def compartments(self):
"""lists compartments the metabolites are in"""
if self._compartments is None:
self._compartments = {met.compartment for met in self._metabolites
if met.compartment is not None}
return self._compartments | [
"lists",
"compartments",
"the",
"metabolites",
"are",
"in"
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L962-L967 | [
"def",
"compartments",
"(",
"self",
")",
":",
"if",
"self",
".",
"_compartments",
"is",
"None",
":",
"self",
".",
"_compartments",
"=",
"{",
"met",
".",
"compartment",
"for",
"met",
"in",
"self",
".",
"_metabolites",
"if",
"met",
".",
"compartment",
"is"... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction._associate_gene | Associates a cobra.Gene object with a cobra.Reaction.
Parameters
----------
cobra_gene : cobra.core.Gene.Gene | cobra/core/reaction.py | def _associate_gene(self, cobra_gene):
"""Associates a cobra.Gene object with a cobra.Reaction.
Parameters
----------
cobra_gene : cobra.core.Gene.Gene
"""
self._genes.add(cobra_gene)
cobra_gene._reaction.add(self)
cobra_gene._model = self._model | def _associate_gene(self, cobra_gene):
"""Associates a cobra.Gene object with a cobra.Reaction.
Parameters
----------
cobra_gene : cobra.core.Gene.Gene
"""
self._genes.add(cobra_gene)
cobra_gene._reaction.add(self)
cobra_gene._model = self._model | [
"Associates",
"a",
"cobra",
".",
"Gene",
"object",
"with",
"a",
"cobra",
".",
"Reaction",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L974-L984 | [
"def",
"_associate_gene",
"(",
"self",
",",
"cobra_gene",
")",
":",
"self",
".",
"_genes",
".",
"add",
"(",
"cobra_gene",
")",
"cobra_gene",
".",
"_reaction",
".",
"add",
"(",
"self",
")",
"cobra_gene",
".",
"_model",
"=",
"self",
".",
"_model"
] | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction._dissociate_gene | Dissociates a cobra.Gene object with a cobra.Reaction.
Parameters
----------
cobra_gene : cobra.core.Gene.Gene | cobra/core/reaction.py | def _dissociate_gene(self, cobra_gene):
"""Dissociates a cobra.Gene object with a cobra.Reaction.
Parameters
----------
cobra_gene : cobra.core.Gene.Gene
"""
self._genes.discard(cobra_gene)
cobra_gene._reaction.discard(self) | def _dissociate_gene(self, cobra_gene):
"""Dissociates a cobra.Gene object with a cobra.Reaction.
Parameters
----------
cobra_gene : cobra.core.Gene.Gene
"""
self._genes.discard(cobra_gene)
cobra_gene._reaction.discard(self) | [
"Dissociates",
"a",
"cobra",
".",
"Gene",
"object",
"with",
"a",
"cobra",
".",
"Reaction",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L986-L995 | [
"def",
"_dissociate_gene",
"(",
"self",
",",
"cobra_gene",
")",
":",
"self",
".",
"_genes",
".",
"discard",
"(",
"cobra_gene",
")",
"cobra_gene",
".",
"_reaction",
".",
"discard",
"(",
"self",
")"
] | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | Reaction.build_reaction_from_string | Builds reaction from reaction equation reaction_str using parser
Takes a string and using the specifications supplied in the optional
arguments infers a set of metabolites, metabolite compartments and
stoichiometries for the reaction. It also infers the reversibility
of the reaction fr... | cobra/core/reaction.py | def build_reaction_from_string(self, reaction_str, verbose=True,
fwd_arrow=None, rev_arrow=None,
reversible_arrow=None, term_split="+"):
"""Builds reaction from reaction equation reaction_str using parser
Takes a string and using the... | def build_reaction_from_string(self, reaction_str, verbose=True,
fwd_arrow=None, rev_arrow=None,
reversible_arrow=None, term_split="+"):
"""Builds reaction from reaction equation reaction_str using parser
Takes a string and using the... | [
"Builds",
"reaction",
"from",
"reaction",
"equation",
"reaction_str",
"using",
"parser"
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/core/reaction.py#L1001-L1095 | [
"def",
"build_reaction_from_string",
"(",
"self",
",",
"reaction_str",
",",
"verbose",
"=",
"True",
",",
"fwd_arrow",
"=",
"None",
",",
"rev_arrow",
"=",
"None",
",",
"reversible_arrow",
"=",
"None",
",",
"term_split",
"=",
"\"+\"",
")",
":",
"# set the arrows... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _clip | Clips a prefix from the beginning of a string if it exists. | cobra/io/sbml.py | def _clip(sid, prefix):
"""Clips a prefix from the beginning of a string if it exists."""
return sid[len(prefix):] if sid.startswith(prefix) else sid | def _clip(sid, prefix):
"""Clips a prefix from the beginning of a string if it exists."""
return sid[len(prefix):] if sid.startswith(prefix) else sid | [
"Clips",
"a",
"prefix",
"from",
"the",
"beginning",
"of",
"a",
"string",
"if",
"it",
"exists",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L100-L102 | [
"def",
"_clip",
"(",
"sid",
",",
"prefix",
")",
":",
"return",
"sid",
"[",
"len",
"(",
"prefix",
")",
":",
"]",
"if",
"sid",
".",
"startswith",
"(",
"prefix",
")",
"else",
"sid"
] | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _f_gene | Clips gene prefix from id. | cobra/io/sbml.py | def _f_gene(sid, prefix="G_"):
"""Clips gene prefix from id."""
sid = sid.replace(SBML_DOT, ".")
return _clip(sid, prefix) | def _f_gene(sid, prefix="G_"):
"""Clips gene prefix from id."""
sid = sid.replace(SBML_DOT, ".")
return _clip(sid, prefix) | [
"Clips",
"gene",
"prefix",
"from",
"id",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L105-L108 | [
"def",
"_f_gene",
"(",
"sid",
",",
"prefix",
"=",
"\"G_\"",
")",
":",
"sid",
"=",
"sid",
".",
"replace",
"(",
"SBML_DOT",
",",
"\".\"",
")",
"return",
"_clip",
"(",
"sid",
",",
"prefix",
")"
] | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | read_sbml_model | Reads SBML model from given filename.
If the given filename ends with the suffix ''.gz'' (for example,
''myfile.xml.gz'),' the file is assumed to be compressed in gzip
format and will be automatically decompressed upon reading. Similarly,
if the given filename ends with ''.zip'' or ''.bz2',' the file i... | cobra/io/sbml.py | def read_sbml_model(filename, number=float, f_replace=F_REPLACE,
set_missing_bounds=False, **kwargs):
"""Reads SBML model from given filename.
If the given filename ends with the suffix ''.gz'' (for example,
''myfile.xml.gz'),' the file is assumed to be compressed in gzip
format and... | def read_sbml_model(filename, number=float, f_replace=F_REPLACE,
set_missing_bounds=False, **kwargs):
"""Reads SBML model from given filename.
If the given filename ends with the suffix ''.gz'' (for example,
''myfile.xml.gz'),' the file is assumed to be compressed in gzip
format and... | [
"Reads",
"SBML",
"model",
"from",
"given",
"filename",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L156-L226 | [
"def",
"read_sbml_model",
"(",
"filename",
",",
"number",
"=",
"float",
",",
"f_replace",
"=",
"F_REPLACE",
",",
"set_missing_bounds",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"doc",
"=",
"_get_doc_from_filename",
"(",
"filename",
")",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _get_doc_from_filename | Get SBMLDocument from given filename.
Parameters
----------
filename : path to SBML, or SBML string, or filehandle
Returns
-------
libsbml.SBMLDocument | cobra/io/sbml.py | def _get_doc_from_filename(filename):
"""Get SBMLDocument from given filename.
Parameters
----------
filename : path to SBML, or SBML string, or filehandle
Returns
-------
libsbml.SBMLDocument
"""
if isinstance(filename, string_types):
if ("win" in platform) and (len(filena... | def _get_doc_from_filename(filename):
"""Get SBMLDocument from given filename.
Parameters
----------
filename : path to SBML, or SBML string, or filehandle
Returns
-------
libsbml.SBMLDocument
"""
if isinstance(filename, string_types):
if ("win" in platform) and (len(filena... | [
"Get",
"SBMLDocument",
"from",
"given",
"filename",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L229-L266 | [
"def",
"_get_doc_from_filename",
"(",
"filename",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"string_types",
")",
":",
"if",
"(",
"\"win\"",
"in",
"platform",
")",
"and",
"(",
"len",
"(",
"filename",
")",
"<",
"260",
")",
"and",
"os",
".",
"pa... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _sbml_to_model | Creates cobra model from SBMLDocument.
Parameters
----------
doc: libsbml.SBMLDocument
number: data type of stoichiometry: {float, int}
In which data type should the stoichiometry be parsed.
f_replace : dict of replacement functions for id replacement
set_missing_bounds : flag to set mi... | cobra/io/sbml.py | def _sbml_to_model(doc, number=float, f_replace=F_REPLACE,
set_missing_bounds=False, **kwargs):
"""Creates cobra model from SBMLDocument.
Parameters
----------
doc: libsbml.SBMLDocument
number: data type of stoichiometry: {float, int}
In which data type should the stoichi... | def _sbml_to_model(doc, number=float, f_replace=F_REPLACE,
set_missing_bounds=False, **kwargs):
"""Creates cobra model from SBMLDocument.
Parameters
----------
doc: libsbml.SBMLDocument
number: data type of stoichiometry: {float, int}
In which data type should the stoichi... | [
"Creates",
"cobra",
"model",
"from",
"SBMLDocument",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L269-L796 | [
"def",
"_sbml_to_model",
"(",
"doc",
",",
"number",
"=",
"float",
",",
"f_replace",
"=",
"F_REPLACE",
",",
"set_missing_bounds",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"f_replace",
"is",
"None",
":",
"f_replace",
"=",
"{",
"}",
"# SBML mo... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | write_sbml_model | Writes cobra model to filename.
The created model is SBML level 3 version 1 (L1V3) with
fbc package v2 (fbc-v2).
If the given filename ends with the suffix ".gz" (for example,
"myfile.xml.gz"), libSBML assumes the caller wants the file to be
written compressed in gzip format. Similarly, if the giv... | cobra/io/sbml.py | def write_sbml_model(cobra_model, filename, f_replace=F_REPLACE, **kwargs):
"""Writes cobra model to filename.
The created model is SBML level 3 version 1 (L1V3) with
fbc package v2 (fbc-v2).
If the given filename ends with the suffix ".gz" (for example,
"myfile.xml.gz"), libSBML assumes the calle... | def write_sbml_model(cobra_model, filename, f_replace=F_REPLACE, **kwargs):
"""Writes cobra model to filename.
The created model is SBML level 3 version 1 (L1V3) with
fbc package v2 (fbc-v2).
If the given filename ends with the suffix ".gz" (for example,
"myfile.xml.gz"), libSBML assumes the calle... | [
"Writes",
"cobra",
"model",
"to",
"filename",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L802-L840 | [
"def",
"write_sbml_model",
"(",
"cobra_model",
",",
"filename",
",",
"f_replace",
"=",
"F_REPLACE",
",",
"*",
"*",
"kwargs",
")",
":",
"doc",
"=",
"_model_to_sbml",
"(",
"cobra_model",
",",
"f_replace",
"=",
"f_replace",
",",
"*",
"*",
"kwargs",
")",
"if",... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _model_to_sbml | Convert Cobra model to SBMLDocument.
Parameters
----------
cobra_model : cobra.core.Model
Cobra model instance
f_replace : dict of replacement functions
Replacement to apply on identifiers.
units : boolean
Should the FLUX_UNITS be written in the SBMLDocument.
Returns
... | cobra/io/sbml.py | def _model_to_sbml(cobra_model, f_replace=None, units=True):
"""Convert Cobra model to SBMLDocument.
Parameters
----------
cobra_model : cobra.core.Model
Cobra model instance
f_replace : dict of replacement functions
Replacement to apply on identifiers.
units : boolean
S... | def _model_to_sbml(cobra_model, f_replace=None, units=True):
"""Convert Cobra model to SBMLDocument.
Parameters
----------
cobra_model : cobra.core.Model
Cobra model instance
f_replace : dict of replacement functions
Replacement to apply on identifiers.
units : boolean
S... | [
"Convert",
"Cobra",
"model",
"to",
"SBMLDocument",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L843-L1103 | [
"def",
"_model_to_sbml",
"(",
"cobra_model",
",",
"f_replace",
"=",
"None",
",",
"units",
"=",
"True",
")",
":",
"if",
"f_replace",
"is",
"None",
":",
"f_replace",
"=",
"{",
"}",
"sbml_ns",
"=",
"libsbml",
".",
"SBMLNamespaces",
"(",
"3",
",",
"1",
")"... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _create_bound | Creates bound in model for given reaction.
Adds the parameters for the bounds to the SBML model.
Parameters
----------
model : libsbml.Model
SBML model instance
reaction : cobra.core.Reaction
Cobra reaction instance from which the bounds are read.
bound_type : {LOWER_BOUND, UPP... | cobra/io/sbml.py | def _create_bound(model, reaction, bound_type, f_replace, units=None,
flux_udef=None):
"""Creates bound in model for given reaction.
Adds the parameters for the bounds to the SBML model.
Parameters
----------
model : libsbml.Model
SBML model instance
reaction : cobra.... | def _create_bound(model, reaction, bound_type, f_replace, units=None,
flux_udef=None):
"""Creates bound in model for given reaction.
Adds the parameters for the bounds to the SBML model.
Parameters
----------
model : libsbml.Model
SBML model instance
reaction : cobra.... | [
"Creates",
"bound",
"in",
"model",
"for",
"given",
"reaction",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1106-L1146 | [
"def",
"_create_bound",
"(",
"model",
",",
"reaction",
",",
"bound_type",
",",
"f_replace",
",",
"units",
"=",
"None",
",",
"flux_udef",
"=",
"None",
")",
":",
"value",
"=",
"getattr",
"(",
"reaction",
",",
"bound_type",
")",
"if",
"value",
"==",
"config... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _create_parameter | Create parameter in SBML model. | cobra/io/sbml.py | def _create_parameter(model, pid, value, sbo=None, constant=True, units=None,
flux_udef=None):
"""Create parameter in SBML model."""
parameter = model.createParameter() # type: libsbml.Parameter
parameter.setId(pid)
parameter.setValue(value)
parameter.setConstant(constant)
... | def _create_parameter(model, pid, value, sbo=None, constant=True, units=None,
flux_udef=None):
"""Create parameter in SBML model."""
parameter = model.createParameter() # type: libsbml.Parameter
parameter.setId(pid)
parameter.setValue(value)
parameter.setConstant(constant)
... | [
"Create",
"parameter",
"in",
"SBML",
"model",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1149-L1159 | [
"def",
"_create_parameter",
"(",
"model",
",",
"pid",
",",
"value",
",",
"sbo",
"=",
"None",
",",
"constant",
"=",
"True",
",",
"units",
"=",
"None",
",",
"flux_udef",
"=",
"None",
")",
":",
"parameter",
"=",
"model",
".",
"createParameter",
"(",
")",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _check_required | Get required attribute from SBase.
Parameters
----------
sbase : libsbml.SBase
value : existing value
attribute: name of attribute
Returns
-------
attribute value (or value if already set) | cobra/io/sbml.py | def _check_required(sbase, value, attribute):
"""Get required attribute from SBase.
Parameters
----------
sbase : libsbml.SBase
value : existing value
attribute: name of attribute
Returns
-------
attribute value (or value if already set)
"""
if (value is None) or (value ==... | def _check_required(sbase, value, attribute):
"""Get required attribute from SBase.
Parameters
----------
sbase : libsbml.SBase
value : existing value
attribute: name of attribute
Returns
-------
attribute value (or value if already set)
"""
if (value is None) or (value ==... | [
"Get",
"required",
"attribute",
"from",
"SBase",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1162-L1186 | [
"def",
"_check_required",
"(",
"sbase",
",",
"value",
",",
"attribute",
")",
":",
"if",
"(",
"value",
"is",
"None",
")",
"or",
"(",
"value",
"==",
"\"\"",
")",
":",
"msg",
"=",
"\"Required attribute '%s' cannot be found or parsed in '%s'\"",
"%",
"(",
"attribu... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _check | Checks the libsbml return value and logs error messages.
If 'value' is None, logs an error message constructed using
'message' and then exits with status code 1. If 'value' is an integer,
it assumes it is a libSBML return status code. If the code value is
LIBSBML_OPERATION_SUCCESS, returns withou... | cobra/io/sbml.py | def _check(value, message):
"""
Checks the libsbml return value and logs error messages.
If 'value' is None, logs an error message constructed using
'message' and then exits with status code 1. If 'value' is an integer,
it assumes it is a libSBML return status code. If the code value is
L... | def _check(value, message):
"""
Checks the libsbml return value and logs error messages.
If 'value' is None, logs an error message constructed using
'message' and then exits with status code 1. If 'value' is an integer,
it assumes it is a libSBML return status code. If the code value is
L... | [
"Checks",
"the",
"libsbml",
"return",
"value",
"and",
"logs",
"error",
"messages",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1189-L1212 | [
"def",
"_check",
"(",
"value",
",",
"message",
")",
":",
"if",
"value",
"is",
"None",
":",
"LOGGER",
".",
"error",
"(",
"'Error: LibSBML returned a null value trying '",
"'to <'",
"+",
"message",
"+",
"'>.'",
")",
"elif",
"type",
"(",
"value",
")",
"is",
"... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _parse_notes_dict | Creates dictionary of COBRA notes.
Parameters
----------
sbase : libsbml.SBase
Returns
-------
dict of notes | cobra/io/sbml.py | def _parse_notes_dict(sbase):
""" Creates dictionary of COBRA notes.
Parameters
----------
sbase : libsbml.SBase
Returns
-------
dict of notes
"""
notes = sbase.getNotesString()
if notes and len(notes) > 0:
pattern = r"<p>\s*(\w+\s*\w*)\s*:\s*([\w|\s]+)<"
matche... | def _parse_notes_dict(sbase):
""" Creates dictionary of COBRA notes.
Parameters
----------
sbase : libsbml.SBase
Returns
-------
dict of notes
"""
notes = sbase.getNotesString()
if notes and len(notes) > 0:
pattern = r"<p>\s*(\w+\s*\w*)\s*:\s*([\w|\s]+)<"
matche... | [
"Creates",
"dictionary",
"of",
"COBRA",
"notes",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1218-L1236 | [
"def",
"_parse_notes_dict",
"(",
"sbase",
")",
":",
"notes",
"=",
"sbase",
".",
"getNotesString",
"(",
")",
"if",
"notes",
"and",
"len",
"(",
"notes",
")",
">",
"0",
":",
"pattern",
"=",
"r\"<p>\\s*(\\w+\\s*\\w*)\\s*:\\s*([\\w|\\s]+)<\"",
"matches",
"=",
"re",... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _sbase_notes_dict | Set SBase notes based on dictionary.
Parameters
----------
sbase : libsbml.SBase
SBML object to set notes on
notes : notes object
notes information from cobra object | cobra/io/sbml.py | def _sbase_notes_dict(sbase, notes):
"""Set SBase notes based on dictionary.
Parameters
----------
sbase : libsbml.SBase
SBML object to set notes on
notes : notes object
notes information from cobra object
"""
if notes and len(notes) > 0:
tokens = ['<html xmlns = "ht... | def _sbase_notes_dict(sbase, notes):
"""Set SBase notes based on dictionary.
Parameters
----------
sbase : libsbml.SBase
SBML object to set notes on
notes : notes object
notes information from cobra object
"""
if notes and len(notes) > 0:
tokens = ['<html xmlns = "ht... | [
"Set",
"SBase",
"notes",
"based",
"on",
"dictionary",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1239-L1256 | [
"def",
"_sbase_notes_dict",
"(",
"sbase",
",",
"notes",
")",
":",
"if",
"notes",
"and",
"len",
"(",
"notes",
")",
">",
"0",
":",
"tokens",
"=",
"[",
"'<html xmlns = \"http://www.w3.org/1999/xhtml\" >'",
"]",
"+",
"[",
"\"<p>{}: {}</p>\"",
".",
"format",
"(",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _parse_annotations | Parses cobra annotations from a given SBase object.
Annotations are dictionaries with the providers as keys.
Parameters
----------
sbase : libsbml.SBase
SBase from which the SBML annotations are read
Returns
-------
dict (annotation dictionary)
FIXME: annotation format must b... | cobra/io/sbml.py | def _parse_annotations(sbase):
"""Parses cobra annotations from a given SBase object.
Annotations are dictionaries with the providers as keys.
Parameters
----------
sbase : libsbml.SBase
SBase from which the SBML annotations are read
Returns
-------
dict (annotation dictionary... | def _parse_annotations(sbase):
"""Parses cobra annotations from a given SBase object.
Annotations are dictionaries with the providers as keys.
Parameters
----------
sbase : libsbml.SBase
SBase from which the SBML annotations are read
Returns
-------
dict (annotation dictionary... | [
"Parses",
"cobra",
"annotations",
"from",
"a",
"given",
"SBase",
"object",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1305-L1356 | [
"def",
"_parse_annotations",
"(",
"sbase",
")",
":",
"annotation",
"=",
"{",
"}",
"# SBO term",
"if",
"sbase",
".",
"isSetSBOTerm",
"(",
")",
":",
"# FIXME: correct handling of annotations",
"annotation",
"[",
"\"sbo\"",
"]",
"=",
"sbase",
".",
"getSBOTermID",
"... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _sbase_annotations | Set SBase annotations based on cobra annotations.
Parameters
----------
sbase : libsbml.SBase
SBML object to annotate
annotation : cobra annotation structure
cobra object with annotation information
FIXME: annotation format must be updated
(https://github.com/opencobra/cobr... | cobra/io/sbml.py | def _sbase_annotations(sbase, annotation):
"""Set SBase annotations based on cobra annotations.
Parameters
----------
sbase : libsbml.SBase
SBML object to annotate
annotation : cobra annotation structure
cobra object with annotation information
FIXME: annotation format must be ... | def _sbase_annotations(sbase, annotation):
"""Set SBase annotations based on cobra annotations.
Parameters
----------
sbase : libsbml.SBase
SBML object to annotate
annotation : cobra annotation structure
cobra object with annotation information
FIXME: annotation format must be ... | [
"Set",
"SBase",
"annotations",
"based",
"on",
"cobra",
"annotations",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1359-L1434 | [
"def",
"_sbase_annotations",
"(",
"sbase",
",",
"annotation",
")",
":",
"if",
"not",
"annotation",
"or",
"len",
"(",
"annotation",
")",
"==",
"0",
":",
"return",
"# standardize annotations",
"annotation_data",
"=",
"deepcopy",
"(",
"annotation",
")",
"for",
"k... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | validate_sbml_model | Validate SBML model and returns the model along with a list of errors.
Parameters
----------
filename : str
The filename (or SBML string) of the SBML model to be validated.
internal_consistency: boolean {True, False}
Check internal consistency.
check_units_consistency: boolean {True... | cobra/io/sbml.py | def validate_sbml_model(filename,
check_model=True,
internal_consistency=True,
check_units_consistency=False,
check_modeling_practice=False, **kwargs):
"""Validate SBML model and returns the model along with a list of er... | def validate_sbml_model(filename,
check_model=True,
internal_consistency=True,
check_units_consistency=False,
check_modeling_practice=False, **kwargs):
"""Validate SBML model and returns the model along with a list of er... | [
"Validate",
"SBML",
"model",
"and",
"returns",
"the",
"model",
"along",
"with",
"a",
"list",
"of",
"errors",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1440-L1579 | [
"def",
"validate_sbml_model",
"(",
"filename",
",",
"check_model",
"=",
"True",
",",
"internal_consistency",
"=",
"True",
",",
"check_units_consistency",
"=",
"False",
",",
"check_modeling_practice",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Errors and w... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _error_string | String representation of SBMLError.
Parameters
----------
error : libsbml.SBMLError
k : index of error
Returns
-------
string representation of error | cobra/io/sbml.py | def _error_string(error, k=None):
"""String representation of SBMLError.
Parameters
----------
error : libsbml.SBMLError
k : index of error
Returns
-------
string representation of error
"""
package = error.getPackage()
if package == '':
package = 'core'
templa... | def _error_string(error, k=None):
"""String representation of SBMLError.
Parameters
----------
error : libsbml.SBMLError
k : index of error
Returns
-------
string representation of error
"""
package = error.getPackage()
if package == '':
package = 'core'
templa... | [
"String",
"representation",
"of",
"SBMLError",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/sbml.py#L1582-L1603 | [
"def",
"_error_string",
"(",
"error",
",",
"k",
"=",
"None",
")",
":",
"package",
"=",
"error",
".",
"getPackage",
"(",
")",
"if",
"package",
"==",
"''",
":",
"package",
"=",
"'core'",
"template",
"=",
"'E{} ({}): {} ({}, L{}); {}; {}'",
"error_str",
"=",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | production_envelope | Calculate the objective value conditioned on all combinations of
fluxes for a set of chosen reactions
The production envelope can be used to analyze a model's ability to
produce a given compound conditional on the fluxes for another set of
reactions, such as the uptake rates. The model is alternately o... | cobra/flux_analysis/phenotype_phase_plane.py | def production_envelope(model, reactions, objective=None, carbon_sources=None,
points=20, threshold=None):
"""Calculate the objective value conditioned on all combinations of
fluxes for a set of chosen reactions
The production envelope can be used to analyze a model's ability to
... | def production_envelope(model, reactions, objective=None, carbon_sources=None,
points=20, threshold=None):
"""Calculate the objective value conditioned on all combinations of
fluxes for a set of chosen reactions
The production envelope can be used to analyze a model's ability to
... | [
"Calculate",
"the",
"objective",
"value",
"conditioned",
"on",
"all",
"combinations",
"of",
"fluxes",
"for",
"a",
"set",
"of",
"chosen",
"reactions"
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/phenotype_phase_plane.py#L22-L130 | [
"def",
"production_envelope",
"(",
"model",
",",
"reactions",
",",
"objective",
"=",
"None",
",",
"carbon_sources",
"=",
"None",
",",
"points",
"=",
"20",
",",
"threshold",
"=",
"None",
")",
":",
"reactions",
"=",
"model",
".",
"reactions",
".",
"get_by_an... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | total_yield | Compute total output per input unit.
Units are typically mol carbon atoms or gram of source and product.
Parameters
----------
input_fluxes : list
A list of input reaction fluxes in the same order as the
``input_components``.
input_elements : list
A list of reaction compone... | cobra/flux_analysis/phenotype_phase_plane.py | def total_yield(input_fluxes, input_elements, output_flux, output_elements):
"""
Compute total output per input unit.
Units are typically mol carbon atoms or gram of source and product.
Parameters
----------
input_fluxes : list
A list of input reaction fluxes in the same order as the
... | def total_yield(input_fluxes, input_elements, output_flux, output_elements):
"""
Compute total output per input unit.
Units are typically mol carbon atoms or gram of source and product.
Parameters
----------
input_fluxes : list
A list of input reaction fluxes in the same order as the
... | [
"Compute",
"total",
"output",
"per",
"input",
"unit",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/phenotype_phase_plane.py#L180-L213 | [
"def",
"total_yield",
"(",
"input_fluxes",
",",
"input_elements",
",",
"output_flux",
",",
"output_elements",
")",
":",
"carbon_input_flux",
"=",
"sum",
"(",
"total_components_flux",
"(",
"flux",
",",
"components",
",",
"consumption",
"=",
"True",
")",
"for",
"f... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | reaction_elements | Split metabolites into the atoms times their stoichiometric coefficients.
Parameters
----------
reaction : Reaction
The metabolic reaction whose components are desired.
Returns
-------
list
Each of the reaction's metabolites' desired carbon elements (if any)
times that ... | cobra/flux_analysis/phenotype_phase_plane.py | def reaction_elements(reaction):
"""
Split metabolites into the atoms times their stoichiometric coefficients.
Parameters
----------
reaction : Reaction
The metabolic reaction whose components are desired.
Returns
-------
list
Each of the reaction's metabolites' desired... | def reaction_elements(reaction):
"""
Split metabolites into the atoms times their stoichiometric coefficients.
Parameters
----------
reaction : Reaction
The metabolic reaction whose components are desired.
Returns
-------
list
Each of the reaction's metabolites' desired... | [
"Split",
"metabolites",
"into",
"the",
"atoms",
"times",
"their",
"stoichiometric",
"coefficients",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/phenotype_phase_plane.py#L216-L233 | [
"def",
"reaction_elements",
"(",
"reaction",
")",
":",
"c_elements",
"=",
"[",
"coeff",
"*",
"met",
".",
"elements",
".",
"get",
"(",
"'C'",
",",
"0",
")",
"for",
"met",
",",
"coeff",
"in",
"iteritems",
"(",
"reaction",
".",
"metabolites",
")",
"]",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | reaction_weight | Return the metabolite weight times its stoichiometric coefficient. | cobra/flux_analysis/phenotype_phase_plane.py | def reaction_weight(reaction):
"""Return the metabolite weight times its stoichiometric coefficient."""
if len(reaction.metabolites) != 1:
raise ValueError('Reaction weight is only defined for single '
'metabolite products or educts.')
met, coeff = next(iteritems(reaction.... | def reaction_weight(reaction):
"""Return the metabolite weight times its stoichiometric coefficient."""
if len(reaction.metabolites) != 1:
raise ValueError('Reaction weight is only defined for single '
'metabolite products or educts.')
met, coeff = next(iteritems(reaction.... | [
"Return",
"the",
"metabolite",
"weight",
"times",
"its",
"stoichiometric",
"coefficient",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/phenotype_phase_plane.py#L236-L245 | [
"def",
"reaction_weight",
"(",
"reaction",
")",
":",
"if",
"len",
"(",
"reaction",
".",
"metabolites",
")",
"!=",
"1",
":",
"raise",
"ValueError",
"(",
"'Reaction weight is only defined for single '",
"'metabolite products or educts.'",
")",
"met",
",",
"coeff",
"="... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | total_components_flux | Compute the total components consumption or production flux.
Parameters
----------
flux : float
The reaction flux for the components.
components : list
List of stoichiometrically weighted components.
consumption : bool, optional
Whether to sum up consumption or production fl... | cobra/flux_analysis/phenotype_phase_plane.py | def total_components_flux(flux, components, consumption=True):
"""
Compute the total components consumption or production flux.
Parameters
----------
flux : float
The reaction flux for the components.
components : list
List of stoichiometrically weighted components.
consumpt... | def total_components_flux(flux, components, consumption=True):
"""
Compute the total components consumption or production flux.
Parameters
----------
flux : float
The reaction flux for the components.
components : list
List of stoichiometrically weighted components.
consumpt... | [
"Compute",
"the",
"total",
"components",
"consumption",
"or",
"production",
"flux",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/phenotype_phase_plane.py#L248-L266 | [
"def",
"total_components_flux",
"(",
"flux",
",",
"components",
",",
"consumption",
"=",
"True",
")",
":",
"direction",
"=",
"1",
"if",
"consumption",
"else",
"-",
"1",
"c_flux",
"=",
"[",
"elem",
"*",
"flux",
"*",
"direction",
"for",
"elem",
"in",
"comp... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | find_carbon_sources | Find all active carbon source reactions.
Parameters
----------
model : Model
A genome-scale metabolic model.
Returns
-------
list
The medium reactions with carbon input flux. | cobra/flux_analysis/phenotype_phase_plane.py | def find_carbon_sources(model):
"""
Find all active carbon source reactions.
Parameters
----------
model : Model
A genome-scale metabolic model.
Returns
-------
list
The medium reactions with carbon input flux.
"""
try:
model.slim_optimize(error_value=N... | def find_carbon_sources(model):
"""
Find all active carbon source reactions.
Parameters
----------
model : Model
A genome-scale metabolic model.
Returns
-------
list
The medium reactions with carbon input flux.
"""
try:
model.slim_optimize(error_value=N... | [
"Find",
"all",
"active",
"carbon",
"source",
"reactions",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/phenotype_phase_plane.py#L269-L294 | [
"def",
"find_carbon_sources",
"(",
"model",
")",
":",
"try",
":",
"model",
".",
"slim_optimize",
"(",
"error_value",
"=",
"None",
")",
"except",
"OptimizationError",
":",
"return",
"[",
"]",
"reactions",
"=",
"model",
".",
"reactions",
".",
"get_by_any",
"("... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | assess | Assesses production capacity.
Assesses the capacity of the model to produce the precursors for the
reaction and absorb the production of the reaction while the reaction is
operating at, or above, the specified cutoff.
Parameters
----------
model : cobra.Model
The cobra model to assess ... | cobra/flux_analysis/reaction.py | def assess(model, reaction, flux_coefficient_cutoff=0.001, solver=None):
"""Assesses production capacity.
Assesses the capacity of the model to produce the precursors for the
reaction and absorb the production of the reaction while the reaction is
operating at, or above, the specified cutoff.
Para... | def assess(model, reaction, flux_coefficient_cutoff=0.001, solver=None):
"""Assesses production capacity.
Assesses the capacity of the model to produce the precursors for the
reaction and absorb the production of the reaction while the reaction is
operating at, or above, the specified cutoff.
Para... | [
"Assesses",
"production",
"capacity",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/reaction.py#L15-L57 | [
"def",
"assess",
"(",
"model",
",",
"reaction",
",",
"flux_coefficient_cutoff",
"=",
"0.001",
",",
"solver",
"=",
"None",
")",
":",
"reaction",
"=",
"model",
".",
"reactions",
".",
"get_by_any",
"(",
"reaction",
")",
"[",
"0",
"]",
"with",
"model",
"as",... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | assess_component | Assesses the ability of the model to provide sufficient precursors,
or absorb products, for a reaction operating at, or beyond,
the specified cutoff.
Parameters
----------
model : cobra.Model
The cobra model to assess production capacity for
reaction : reaction identifier or cobra.Reac... | cobra/flux_analysis/reaction.py | def assess_component(model, reaction, side, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses the ability of the model to provide sufficient precursors,
or absorb products, for a reaction operating at, or beyond,
the specified cutoff.
Parameters
----------
model : co... | def assess_component(model, reaction, side, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses the ability of the model to provide sufficient precursors,
or absorb products, for a reaction operating at, or beyond,
the specified cutoff.
Parameters
----------
model : co... | [
"Assesses",
"the",
"ability",
"of",
"the",
"model",
"to",
"provide",
"sufficient",
"precursors",
"or",
"absorb",
"products",
"for",
"a",
"reaction",
"operating",
"at",
"or",
"beyond",
"the",
"specified",
"cutoff",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/reaction.py#L60-L136 | [
"def",
"assess_component",
"(",
"model",
",",
"reaction",
",",
"side",
",",
"flux_coefficient_cutoff",
"=",
"0.001",
",",
"solver",
"=",
"None",
")",
":",
"reaction",
"=",
"model",
".",
"reactions",
".",
"get_by_any",
"(",
"reaction",
")",
"[",
"0",
"]",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | assess_precursors | Assesses the ability of the model to provide sufficient precursors for
a reaction operating at, or beyond, the specified cutoff.
Deprecated: use assess_component instead
Parameters
----------
model : cobra.Model
The cobra model to assess production capacity for
reaction : reaction ide... | cobra/flux_analysis/reaction.py | def assess_precursors(model, reaction, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses the ability of the model to provide sufficient precursors for
a reaction operating at, or beyond, the specified cutoff.
Deprecated: use assess_component instead
Parameters
--------... | def assess_precursors(model, reaction, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses the ability of the model to provide sufficient precursors for
a reaction operating at, or beyond, the specified cutoff.
Deprecated: use assess_component instead
Parameters
--------... | [
"Assesses",
"the",
"ability",
"of",
"the",
"model",
"to",
"provide",
"sufficient",
"precursors",
"for",
"a",
"reaction",
"operating",
"at",
"or",
"beyond",
"the",
"specified",
"cutoff",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/reaction.py#L143-L177 | [
"def",
"assess_precursors",
"(",
"model",
",",
"reaction",
",",
"flux_coefficient_cutoff",
"=",
"0.001",
",",
"solver",
"=",
"None",
")",
":",
"warn",
"(",
"'use assess_component instead'",
",",
"DeprecationWarning",
")",
"return",
"assess_component",
"(",
"model",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | assess_products | Assesses whether the model has the capacity to absorb the products of
a reaction at a given flux rate.
Useful for identifying which components might be blocking a reaction
from achieving a specific flux rate.
Deprecated: use assess_component instead
Parameters
----------
model : cobra.Mod... | cobra/flux_analysis/reaction.py | def assess_products(model, reaction, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses whether the model has the capacity to absorb the products of
a reaction at a given flux rate.
Useful for identifying which components might be blocking a reaction
from achieving a specific ... | def assess_products(model, reaction, flux_coefficient_cutoff=0.001,
solver=None):
"""Assesses whether the model has the capacity to absorb the products of
a reaction at a given flux rate.
Useful for identifying which components might be blocking a reaction
from achieving a specific ... | [
"Assesses",
"whether",
"the",
"model",
"has",
"the",
"capacity",
"to",
"absorb",
"the",
"products",
"of",
"a",
"reaction",
"at",
"a",
"given",
"flux",
"rate",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/reaction.py#L180-L217 | [
"def",
"assess_products",
"(",
"model",
",",
"reaction",
",",
"flux_coefficient_cutoff",
"=",
"0.001",
",",
"solver",
"=",
"None",
")",
":",
"warn",
"(",
"'use assess_component instead'",
",",
"DeprecationWarning",
")",
"return",
"assess_component",
"(",
"model",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | add_loopless | Modify a model so all feasible flux distributions are loopless.
In most cases you probably want to use the much faster `loopless_solution`.
May be used in cases where you want to add complex constraints and
objecives (for instance quadratic objectives) to the model afterwards
or use an approximation of... | cobra/flux_analysis/loopless.py | def add_loopless(model, zero_cutoff=None):
"""Modify a model so all feasible flux distributions are loopless.
In most cases you probably want to use the much faster `loopless_solution`.
May be used in cases where you want to add complex constraints and
objecives (for instance quadratic objectives) to t... | def add_loopless(model, zero_cutoff=None):
"""Modify a model so all feasible flux distributions are loopless.
In most cases you probably want to use the much faster `loopless_solution`.
May be used in cases where you want to add complex constraints and
objecives (for instance quadratic objectives) to t... | [
"Modify",
"a",
"model",
"so",
"all",
"feasible",
"flux",
"distributions",
"are",
"loopless",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/loopless.py#L20-L86 | [
"def",
"add_loopless",
"(",
"model",
",",
"zero_cutoff",
"=",
"None",
")",
":",
"zero_cutoff",
"=",
"normalize_cutoff",
"(",
"model",
",",
"zero_cutoff",
")",
"internal",
"=",
"[",
"i",
"for",
"i",
",",
"r",
"in",
"enumerate",
"(",
"model",
".",
"reactio... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | _add_cycle_free | Add constraints for CycleFreeFlux. | cobra/flux_analysis/loopless.py | def _add_cycle_free(model, fluxes):
"""Add constraints for CycleFreeFlux."""
model.objective = model.solver.interface.Objective(
Zero, direction="min", sloppy=True)
objective_vars = []
for rxn in model.reactions:
flux = fluxes[rxn.id]
if rxn.boundary:
rxn.bounds = (fl... | def _add_cycle_free(model, fluxes):
"""Add constraints for CycleFreeFlux."""
model.objective = model.solver.interface.Objective(
Zero, direction="min", sloppy=True)
objective_vars = []
for rxn in model.reactions:
flux = fluxes[rxn.id]
if rxn.boundary:
rxn.bounds = (fl... | [
"Add",
"constraints",
"for",
"CycleFreeFlux",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/loopless.py#L89-L106 | [
"def",
"_add_cycle_free",
"(",
"model",
",",
"fluxes",
")",
":",
"model",
".",
"objective",
"=",
"model",
".",
"solver",
".",
"interface",
".",
"Objective",
"(",
"Zero",
",",
"direction",
"=",
"\"min\"",
",",
"sloppy",
"=",
"True",
")",
"objective_vars",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | loopless_solution | Convert an existing solution to a loopless one.
Removes as many loops as possible (see Notes).
Uses the method from CycleFreeFlux [1]_ and is much faster than
`add_loopless` and should therefore be the preferred option to get loopless
flux distributions.
Parameters
----------
model : cobra... | cobra/flux_analysis/loopless.py | def loopless_solution(model, fluxes=None):
"""Convert an existing solution to a loopless one.
Removes as many loops as possible (see Notes).
Uses the method from CycleFreeFlux [1]_ and is much faster than
`add_loopless` and should therefore be the preferred option to get loopless
flux distributions... | def loopless_solution(model, fluxes=None):
"""Convert an existing solution to a loopless one.
Removes as many loops as possible (see Notes).
Uses the method from CycleFreeFlux [1]_ and is much faster than
`add_loopless` and should therefore be the preferred option to get loopless
flux distributions... | [
"Convert",
"an",
"existing",
"solution",
"to",
"a",
"loopless",
"one",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/loopless.py#L109-L171 | [
"def",
"loopless_solution",
"(",
"model",
",",
"fluxes",
"=",
"None",
")",
":",
"# Need to reoptimize otherwise spurious solution artifacts can cause",
"# all kinds of havoc",
"# TODO: check solution status",
"if",
"fluxes",
"is",
"None",
":",
"sol",
"=",
"model",
".",
"o... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | loopless_fva_iter | Plugin to get a loopless FVA solution from single FVA iteration.
Assumes the following about `model` and `reaction`:
1. the model objective is set to be `reaction`
2. the model has been optimized and contains the minimum/maximum flux for
`reaction`
3. the model contains an auxiliary variable cal... | cobra/flux_analysis/loopless.py | def loopless_fva_iter(model, reaction, solution=False, zero_cutoff=None):
"""Plugin to get a loopless FVA solution from single FVA iteration.
Assumes the following about `model` and `reaction`:
1. the model objective is set to be `reaction`
2. the model has been optimized and contains the minimum/maxim... | def loopless_fva_iter(model, reaction, solution=False, zero_cutoff=None):
"""Plugin to get a loopless FVA solution from single FVA iteration.
Assumes the following about `model` and `reaction`:
1. the model objective is set to be `reaction`
2. the model has been optimized and contains the minimum/maxim... | [
"Plugin",
"to",
"get",
"a",
"loopless",
"FVA",
"solution",
"from",
"single",
"FVA",
"iteration",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/loopless.py#L174-L251 | [
"def",
"loopless_fva_iter",
"(",
"model",
",",
"reaction",
",",
"solution",
"=",
"False",
",",
"zero_cutoff",
"=",
"None",
")",
":",
"zero_cutoff",
"=",
"normalize_cutoff",
"(",
"model",
",",
"zero_cutoff",
")",
"current",
"=",
"model",
".",
"objective",
"."... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | create_stoichiometric_matrix | Return a stoichiometric array representation of the given model.
The the columns represent the reactions and rows represent
metabolites. S[i,j] therefore contains the quantity of metabolite `i`
produced (negative for consumed) by reaction `j`.
Parameters
----------
model : cobra.Model
... | cobra/util/array.py | def create_stoichiometric_matrix(model, array_type='dense', dtype=None):
"""Return a stoichiometric array representation of the given model.
The the columns represent the reactions and rows represent
metabolites. S[i,j] therefore contains the quantity of metabolite `i`
produced (negative for consumed) ... | def create_stoichiometric_matrix(model, array_type='dense', dtype=None):
"""Return a stoichiometric array representation of the given model.
The the columns represent the reactions and rows represent
metabolites. S[i,j] therefore contains the quantity of metabolite `i`
produced (negative for consumed) ... | [
"Return",
"a",
"stoichiometric",
"array",
"representation",
"of",
"the",
"given",
"model",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/array.py#L18-L71 | [
"def",
"create_stoichiometric_matrix",
"(",
"model",
",",
"array_type",
"=",
"'dense'",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"array_type",
"not",
"in",
"(",
"'DataFrame'",
",",
"'dense'",
")",
"and",
"not",
"dok_matrix",
":",
"raise",
"ValueError",
"("... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | nullspace | Compute an approximate basis for the nullspace of A.
The algorithm used by this function is based on the singular value
decomposition of `A`.
Parameters
----------
A : numpy.ndarray
A should be at most 2-D. A 1-D array with length k will be treated
as a 2-D with shape (1, k)
at... | cobra/util/array.py | def nullspace(A, atol=1e-13, rtol=0):
"""Compute an approximate basis for the nullspace of A.
The algorithm used by this function is based on the singular value
decomposition of `A`.
Parameters
----------
A : numpy.ndarray
A should be at most 2-D. A 1-D array with length k will be trea... | def nullspace(A, atol=1e-13, rtol=0):
"""Compute an approximate basis for the nullspace of A.
The algorithm used by this function is based on the singular value
decomposition of `A`.
Parameters
----------
A : numpy.ndarray
A should be at most 2-D. A 1-D array with length k will be trea... | [
"Compute",
"an",
"approximate",
"basis",
"for",
"the",
"nullspace",
"of",
"A",
".",
"The",
"algorithm",
"used",
"by",
"this",
"function",
"is",
"based",
"on",
"the",
"singular",
"value",
"decomposition",
"of",
"A",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/array.py#L74-L114 | [
"def",
"nullspace",
"(",
"A",
",",
"atol",
"=",
"1e-13",
",",
"rtol",
"=",
"0",
")",
":",
"A",
"=",
"np",
".",
"atleast_2d",
"(",
"A",
")",
"u",
",",
"s",
",",
"vh",
"=",
"np",
".",
"linalg",
".",
"svd",
"(",
"A",
")",
"tol",
"=",
"max",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | constraint_matrices | Create a matrix representation of the problem.
This is used for alternative solution approaches that do not use optlang.
The function will construct the equality matrix, inequality matrix and
bounds for the complete problem.
Notes
-----
To accomodate non-zero equalities the problem will add th... | cobra/util/array.py | def constraint_matrices(model, array_type='dense', include_vars=False,
zero_tol=1e-6):
"""Create a matrix representation of the problem.
This is used for alternative solution approaches that do not use optlang.
The function will construct the equality matrix, inequality matrix and
... | def constraint_matrices(model, array_type='dense', include_vars=False,
zero_tol=1e-6):
"""Create a matrix representation of the problem.
This is used for alternative solution approaches that do not use optlang.
The function will construct the equality matrix, inequality matrix and
... | [
"Create",
"a",
"matrix",
"representation",
"of",
"the",
"problem",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/array.py#L117-L200 | [
"def",
"constraint_matrices",
"(",
"model",
",",
"array_type",
"=",
"'dense'",
",",
"include_vars",
"=",
"False",
",",
"zero_tol",
"=",
"1e-6",
")",
":",
"if",
"array_type",
"not",
"in",
"(",
"'DataFrame'",
",",
"'dense'",
")",
"and",
"not",
"dok_matrix",
... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | room | Compute a single solution based on regulatory on/off minimization (ROOM).
Compute a new flux distribution that minimizes the number of active
reactions needed to accommodate a previous reference solution.
Regulatory on/off minimization (ROOM) is generally used to assess the
impact of knock-outs. Thus t... | cobra/flux_analysis/room.py | def room(model, solution=None, linear=False, delta=0.03, epsilon=1E-03):
"""
Compute a single solution based on regulatory on/off minimization (ROOM).
Compute a new flux distribution that minimizes the number of active
reactions needed to accommodate a previous reference solution.
Regulatory on/off... | def room(model, solution=None, linear=False, delta=0.03, epsilon=1E-03):
"""
Compute a single solution based on regulatory on/off minimization (ROOM).
Compute a new flux distribution that minimizes the number of active
reactions needed to accommodate a previous reference solution.
Regulatory on/off... | [
"Compute",
"a",
"single",
"solution",
"based",
"on",
"regulatory",
"on",
"/",
"off",
"minimization",
"(",
"ROOM",
")",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/room.py#L12-L50 | [
"def",
"room",
"(",
"model",
",",
"solution",
"=",
"None",
",",
"linear",
"=",
"False",
",",
"delta",
"=",
"0.03",
",",
"epsilon",
"=",
"1E-03",
")",
":",
"with",
"model",
":",
"add_room",
"(",
"model",
"=",
"model",
",",
"solution",
"=",
"solution",... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | add_room | r"""
Add constraints and objective for ROOM.
This function adds variables and constraints for applying regulatory
on/off minimization (ROOM) to the model.
Parameters
----------
model : cobra.Model
The model to add ROOM constraints and objective to.
solution : cobra.Solution, option... | cobra/flux_analysis/room.py | def add_room(model, solution=None, linear=False, delta=0.03, epsilon=1E-03):
r"""
Add constraints and objective for ROOM.
This function adds variables and constraints for applying regulatory
on/off minimization (ROOM) to the model.
Parameters
----------
model : cobra.Model
The mode... | def add_room(model, solution=None, linear=False, delta=0.03, epsilon=1E-03):
r"""
Add constraints and objective for ROOM.
This function adds variables and constraints for applying regulatory
on/off minimization (ROOM) to the model.
Parameters
----------
model : cobra.Model
The mode... | [
"r",
"Add",
"constraints",
"and",
"objective",
"for",
"ROOM",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/room.py#L53-L150 | [
"def",
"add_room",
"(",
"model",
",",
"solution",
"=",
"None",
",",
"linear",
"=",
"False",
",",
"delta",
"=",
"0.03",
",",
"epsilon",
"=",
"1E-03",
")",
":",
"if",
"'room_old_objective'",
"in",
"model",
".",
"solver",
".",
"variables",
":",
"raise",
"... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | sample | Sample valid flux distributions from a cobra model.
The function samples valid flux distributions from a cobra model.
Currently we support two methods:
1. 'optgp' (default) which uses the OptGPSampler that supports parallel
sampling [1]_. Requires large numbers of samples to be performant
... | cobra/sampling/sampling.py | def sample(model, n, method="optgp", thinning=100, processes=1, seed=None):
"""Sample valid flux distributions from a cobra model.
The function samples valid flux distributions from a cobra model.
Currently we support two methods:
1. 'optgp' (default) which uses the OptGPSampler that supports parallel... | def sample(model, n, method="optgp", thinning=100, processes=1, seed=None):
"""Sample valid flux distributions from a cobra model.
The function samples valid flux distributions from a cobra model.
Currently we support two methods:
1. 'optgp' (default) which uses the OptGPSampler that supports parallel... | [
"Sample",
"valid",
"flux",
"distributions",
"from",
"a",
"cobra",
"model",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/sampling.py#L13-L83 | [
"def",
"sample",
"(",
"model",
",",
"n",
",",
"method",
"=",
"\"optgp\"",
",",
"thinning",
"=",
"100",
",",
"processes",
"=",
"1",
",",
"seed",
"=",
"None",
")",
":",
"if",
"method",
"==",
"\"optgp\"",
":",
"sampler",
"=",
"OptGPSampler",
"(",
"model... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | fastcc | r"""
Check consistency of a metabolic network using FASTCC [1]_.
FASTCC (Fast Consistency Check) is an algorithm for rapid and
efficient consistency check in metabolic networks. FASTCC is
a pure LP implementation and is low on computation resource
demand. FASTCC also circumvents the problem associa... | cobra/flux_analysis/fastcc.py | def fastcc(model, flux_threshold=1.0, zero_cutoff=None):
r"""
Check consistency of a metabolic network using FASTCC [1]_.
FASTCC (Fast Consistency Check) is an algorithm for rapid and
efficient consistency check in metabolic networks. FASTCC is
a pure LP implementation and is low on computation res... | def fastcc(model, flux_threshold=1.0, zero_cutoff=None):
r"""
Check consistency of a metabolic network using FASTCC [1]_.
FASTCC (Fast Consistency Check) is an algorithm for rapid and
efficient consistency check in metabolic networks. FASTCC is
a pure LP implementation and is low on computation res... | [
"r",
"Check",
"consistency",
"of",
"a",
"metabolic",
"network",
"using",
"FASTCC",
"[",
"1",
"]",
"_",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/flux_analysis/fastcc.py#L17-L86 | [
"def",
"fastcc",
"(",
"model",
",",
"flux_threshold",
"=",
"1.0",
",",
"zero_cutoff",
"=",
"None",
")",
":",
"zero_cutoff",
"=",
"normalize_cutoff",
"(",
"model",
",",
"zero_cutoff",
")",
"with",
"model",
":",
"obj_vars",
"=",
"[",
"]",
"vars_and_cons",
"=... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | ACHRSampler.sample | Generate a set of samples.
This is the basic sampling function for all hit-and-run samplers.
Parameters
----------
n : int
The number of samples that are generated at once.
fluxes : boolean
Whether to return fluxes or the internal solver variables. If se... | cobra/sampling/achr.py | def sample(self, n, fluxes=True):
"""Generate a set of samples.
This is the basic sampling function for all hit-and-run samplers.
Parameters
----------
n : int
The number of samples that are generated at once.
fluxes : boolean
Whether to return f... | def sample(self, n, fluxes=True):
"""Generate a set of samples.
This is the basic sampling function for all hit-and-run samplers.
Parameters
----------
n : int
The number of samples that are generated at once.
fluxes : boolean
Whether to return f... | [
"Generate",
"a",
"set",
"of",
"samples",
"."
] | opencobra/cobrapy | python | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/sampling/achr.py#L119-L163 | [
"def",
"sample",
"(",
"self",
",",
"n",
",",
"fluxes",
"=",
"True",
")",
":",
"samples",
"=",
"np",
".",
"zeros",
"(",
"(",
"n",
",",
"self",
".",
"warmup",
".",
"shape",
"[",
"1",
"]",
")",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"s... | 9d1987cdb3a395cf4125a3439c3b002ff2be2009 |
valid | optimizely | Optimizely template tag.
Renders Javascript code to set-up A/B testing. You must supply
your Optimizely account number in the ``OPTIMIZELY_ACCOUNT_NUMBER``
setting. | analytical/templatetags/optimizely.py | def optimizely(parser, token):
"""
Optimizely template tag.
Renders Javascript code to set-up A/B testing. You must supply
your Optimizely account number in the ``OPTIMIZELY_ACCOUNT_NUMBER``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError(... | def optimizely(parser, token):
"""
Optimizely template tag.
Renders Javascript code to set-up A/B testing. You must supply
your Optimizely account number in the ``OPTIMIZELY_ACCOUNT_NUMBER``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError(... | [
"Optimizely",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/optimizely.py#L22-L33 | [
"def",
"optimizely",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | google_analytics | Google Analytics tracking template tag.
Renders Javascript code to track page visits. You must supply
your website property ID (as a string) in the
``GOOGLE_ANALYTICS_PROPERTY_ID`` setting. | analytical/templatetags/google_analytics.py | def google_analytics(parser, token):
"""
Google Analytics tracking template tag.
Renders Javascript code to track page visits. You must supply
your website property ID (as a string) in the
``GOOGLE_ANALYTICS_PROPERTY_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
... | def google_analytics(parser, token):
"""
Google Analytics tracking template tag.
Renders Javascript code to track page visits. You must supply
your website property ID (as a string) in the
``GOOGLE_ANALYTICS_PROPERTY_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
... | [
"Google",
"Analytics",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/google_analytics.py#L68-L79 | [
"def",
"google_analytics",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0"... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | google_analytics_js | Google Analytics tracking template tag.
Renders Javascript code to track page visits. You must supply
your website property ID (as a string) in the
``GOOGLE_ANALYTICS_JS_PROPERTY_ID`` setting. | analytical/templatetags/google_analytics_js.py | def google_analytics_js(parser, token):
"""
Google Analytics tracking template tag.
Renders Javascript code to track page visits. You must supply
your website property ID (as a string) in the
``GOOGLE_ANALYTICS_JS_PROPERTY_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > ... | def google_analytics_js(parser, token):
"""
Google Analytics tracking template tag.
Renders Javascript code to track page visits. You must supply
your website property ID (as a string) in the
``GOOGLE_ANALYTICS_JS_PROPERTY_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > ... | [
"Google",
"Analytics",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/google_analytics_js.py#L44-L55 | [
"def",
"google_analytics_js",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | rating_mailru | Rating@Mail.ru counter template tag.
Renders Javascript code to track page visits. You must supply
your website counter ID (as a string) in the
``RATING_MAILRU_COUNTER_ID`` setting. | analytical/templatetags/rating_mailru.py | def rating_mailru(parser, token):
"""
Rating@Mail.ru counter template tag.
Renders Javascript code to track page visits. You must supply
your website counter ID (as a string) in the
``RATING_MAILRU_COUNTER_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise T... | def rating_mailru(parser, token):
"""
Rating@Mail.ru counter template tag.
Renders Javascript code to track page visits. You must supply
your website counter ID (as a string) in the
``RATING_MAILRU_COUNTER_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise T... | [
"Rating@Mail",
".",
"ru",
"counter",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/rating_mailru.py#L38-L49 | [
"def",
"rating_mailru",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | clicky | Clicky tracking template tag.
Renders Javascript code to track page visits. You must supply
your Clicky Site ID (as a string) in the ``CLICKY_SITE_ID``
setting. | analytical/templatetags/clicky.py | def clicky(parser, token):
"""
Clicky tracking template tag.
Renders Javascript code to track page visits. You must supply
your Clicky Site ID (as a string) in the ``CLICKY_SITE_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' ta... | def clicky(parser, token):
"""
Clicky tracking template tag.
Renders Javascript code to track page visits. You must supply
your Clicky Site ID (as a string) in the ``CLICKY_SITE_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' ta... | [
"Clicky",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/clicky.py#L38-L49 | [
"def",
"clicky",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | chartbeat_top | Top Chartbeat template tag.
Render the top Javascript code for Chartbeat. | analytical/templatetags/chartbeat.py | def chartbeat_top(parser, token):
"""
Top Chartbeat template tag.
Render the top Javascript code for Chartbeat.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % bits[0])
return ChartbeatTopNode() | def chartbeat_top(parser, token):
"""
Top Chartbeat template tag.
Render the top Javascript code for Chartbeat.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % bits[0])
return ChartbeatTopNode() | [
"Top",
"Chartbeat",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/chartbeat.py#L46-L55 | [
"def",
"chartbeat_top",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | chartbeat_bottom | Bottom Chartbeat template tag.
Render the bottom Javascript code for Chartbeat. You must supply
your Chartbeat User ID (as a string) in the ``CHARTBEAT_USER_ID``
setting. | analytical/templatetags/chartbeat.py | def chartbeat_bottom(parser, token):
"""
Bottom Chartbeat template tag.
Render the bottom Javascript code for Chartbeat. You must supply
your Chartbeat User ID (as a string) in the ``CHARTBEAT_USER_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Template... | def chartbeat_bottom(parser, token):
"""
Bottom Chartbeat template tag.
Render the bottom Javascript code for Chartbeat. You must supply
your Chartbeat User ID (as a string) in the ``CHARTBEAT_USER_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Template... | [
"Bottom",
"Chartbeat",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/chartbeat.py#L66-L77 | [
"def",
"chartbeat_bottom",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0"... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | woopra | Woopra tracking template tag.
Renders Javascript code to track page visits. You must supply
your Woopra domain in the ``WOOPRA_DOMAIN`` setting. | analytical/templatetags/woopra.py | def woopra(parser, token):
"""
Woopra tracking template tag.
Renders Javascript code to track page visits. You must supply
your Woopra domain in the ``WOOPRA_DOMAIN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % ... | def woopra(parser, token):
"""
Woopra tracking template tag.
Renders Javascript code to track page visits. You must supply
your Woopra domain in the ``WOOPRA_DOMAIN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % ... | [
"Woopra",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/woopra.py#L38-L48 | [
"def",
"woopra",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | spring_metrics | Spring Metrics tracking template tag.
Renders Javascript code to track page visits. You must supply
your Spring Metrics Tracking ID in the
``SPRING_METRICS_TRACKING_ID`` setting. | analytical/templatetags/spring_metrics.py | def spring_metrics(parser, token):
"""
Spring Metrics tracking template tag.
Renders Javascript code to track page visits. You must supply
your Spring Metrics Tracking ID in the
``SPRING_METRICS_TRACKING_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Te... | def spring_metrics(parser, token):
"""
Spring Metrics tracking template tag.
Renders Javascript code to track page visits. You must supply
your Spring Metrics Tracking ID in the
``SPRING_METRICS_TRACKING_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Te... | [
"Spring",
"Metrics",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/spring_metrics.py#L38-L49 | [
"def",
"spring_metrics",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | kiss_insights | KISSinsights set-up template tag.
Renders Javascript code to set-up surveys. You must supply
your account number and site code in the
``KISS_INSIGHTS_ACCOUNT_NUMBER`` and ``KISS_INSIGHTS_SITE_CODE``
settings. | analytical/templatetags/kiss_insights.py | def kiss_insights(parser, token):
"""
KISSinsights set-up template tag.
Renders Javascript code to set-up surveys. You must supply
your account number and site code in the
``KISS_INSIGHTS_ACCOUNT_NUMBER`` and ``KISS_INSIGHTS_SITE_CODE``
settings.
"""
bits = token.split_contents()
i... | def kiss_insights(parser, token):
"""
KISSinsights set-up template tag.
Renders Javascript code to set-up surveys. You must supply
your account number and site code in the
``KISS_INSIGHTS_ACCOUNT_NUMBER`` and ``KISS_INSIGHTS_SITE_CODE``
settings.
"""
bits = token.split_contents()
i... | [
"KISSinsights",
"set",
"-",
"up",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/kiss_insights.py#L29-L41 | [
"def",
"kiss_insights",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | matomo | Matomo tracking template tag.
Renders Javascript code to track page visits. You must supply
your Matomo domain (plus optional URI path), and tracked site ID
in the ``MATOMO_DOMAIN_PATH`` and the ``MATOMO_SITE_ID`` setting.
Custom variables can be passed in the ``matomo_vars`` context
variable. I... | analytical/templatetags/matomo.py | def matomo(parser, token):
"""
Matomo tracking template tag.
Renders Javascript code to track page visits. You must supply
your Matomo domain (plus optional URI path), and tracked site ID
in the ``MATOMO_DOMAIN_PATH`` and the ``MATOMO_SITE_ID`` setting.
Custom variables can be passed in the `... | def matomo(parser, token):
"""
Matomo tracking template tag.
Renders Javascript code to track page visits. You must supply
your Matomo domain (plus optional URI path), and tracked site ID
in the ``MATOMO_DOMAIN_PATH`` and the ``MATOMO_SITE_ID`` setting.
Custom variables can be passed in the `... | [
"Matomo",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/matomo.py#L55-L72 | [
"def",
"matomo",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | snapengage | SnapEngage set-up template tag.
Renders Javascript code to set-up SnapEngage chat. You must supply
your widget ID in the ``SNAPENGAGE_WIDGET_ID`` setting. | analytical/templatetags/snapengage.py | def snapengage(parser, token):
"""
SnapEngage set-up template tag.
Renders Javascript code to set-up SnapEngage chat. You must supply
your widget ID in the ``SNAPENGAGE_WIDGET_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no... | def snapengage(parser, token):
"""
SnapEngage set-up template tag.
Renders Javascript code to set-up SnapEngage chat. You must supply
your widget ID in the ``SNAPENGAGE_WIDGET_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no... | [
"SnapEngage",
"set",
"-",
"up",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/snapengage.py#L56-L66 | [
"def",
"snapengage",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | performable | Performable template tag.
Renders Javascript code to set-up Performable tracking. You must
supply your Performable API key in the ``PERFORMABLE_API_KEY``
setting. | analytical/templatetags/performable.py | def performable(parser, token):
"""
Performable template tag.
Renders Javascript code to set-up Performable tracking. You must
supply your Performable API key in the ``PERFORMABLE_API_KEY``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("... | def performable(parser, token):
"""
Performable template tag.
Renders Javascript code to set-up Performable tracking. You must
supply your Performable API key in the ``PERFORMABLE_API_KEY``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("... | [
"Performable",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/performable.py#L41-L52 | [
"def",
"performable",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | _timestamp | Python 2 compatibility for `datetime.timestamp()`. | analytical/templatetags/intercom.py | def _timestamp(when):
"""
Python 2 compatibility for `datetime.timestamp()`.
"""
return (time.mktime(when.timetuple()) if sys.version_info < (3,) else
when.timestamp()) | def _timestamp(when):
"""
Python 2 compatibility for `datetime.timestamp()`.
"""
return (time.mktime(when.timetuple()) if sys.version_info < (3,) else
when.timestamp()) | [
"Python",
"2",
"compatibility",
"for",
"datetime",
".",
"timestamp",
"()",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/intercom.py#L32-L37 | [
"def",
"_timestamp",
"(",
"when",
")",
":",
"return",
"(",
"time",
".",
"mktime",
"(",
"when",
".",
"timetuple",
"(",
")",
")",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
")",
"else",
"when",
".",
"timestamp",
"(",
")",
")"
] | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | _hashable_bytes | Coerce strings to hashable bytes. | analytical/templatetags/intercom.py | def _hashable_bytes(data):
"""
Coerce strings to hashable bytes.
"""
if isinstance(data, bytes):
return data
elif isinstance(data, str):
return data.encode('ascii') # Fail on anything non-ASCII.
else:
raise TypeError(data) | def _hashable_bytes(data):
"""
Coerce strings to hashable bytes.
"""
if isinstance(data, bytes):
return data
elif isinstance(data, str):
return data.encode('ascii') # Fail on anything non-ASCII.
else:
raise TypeError(data) | [
"Coerce",
"strings",
"to",
"hashable",
"bytes",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/intercom.py#L40-L49 | [
"def",
"_hashable_bytes",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"bytes",
")",
":",
"return",
"data",
"elif",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"return",
"data",
".",
"encode",
"(",
"'ascii'",
")",
"# Fail on anything... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | intercom_user_hash | Return a SHA-256 HMAC `user_hash` as expected by Intercom, if configured.
Return None if the `INTERCOM_HMAC_SECRET_KEY` setting is not configured. | analytical/templatetags/intercom.py | def intercom_user_hash(data):
"""
Return a SHA-256 HMAC `user_hash` as expected by Intercom, if configured.
Return None if the `INTERCOM_HMAC_SECRET_KEY` setting is not configured.
"""
if getattr(settings, 'INTERCOM_HMAC_SECRET_KEY', None):
return hmac.new(
key=_hashable_bytes(s... | def intercom_user_hash(data):
"""
Return a SHA-256 HMAC `user_hash` as expected by Intercom, if configured.
Return None if the `INTERCOM_HMAC_SECRET_KEY` setting is not configured.
"""
if getattr(settings, 'INTERCOM_HMAC_SECRET_KEY', None):
return hmac.new(
key=_hashable_bytes(s... | [
"Return",
"a",
"SHA",
"-",
"256",
"HMAC",
"user_hash",
"as",
"expected",
"by",
"Intercom",
"if",
"configured",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/intercom.py#L52-L65 | [
"def",
"intercom_user_hash",
"(",
"data",
")",
":",
"if",
"getattr",
"(",
"settings",
",",
"'INTERCOM_HMAC_SECRET_KEY'",
",",
"None",
")",
":",
"return",
"hmac",
".",
"new",
"(",
"key",
"=",
"_hashable_bytes",
"(",
"settings",
".",
"INTERCOM_HMAC_SECRET_KEY",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | intercom | Intercom.io template tag.
Renders Javascript code to intercom.io testing. You must supply
your APP ID account number in the ``INTERCOM_APP_ID``
setting. | analytical/templatetags/intercom.py | def intercom(parser, token):
"""
Intercom.io template tag.
Renders Javascript code to intercom.io testing. You must supply
your APP ID account number in the ``INTERCOM_APP_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no... | def intercom(parser, token):
"""
Intercom.io template tag.
Renders Javascript code to intercom.io testing. You must supply
your APP ID account number in the ``INTERCOM_APP_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no... | [
"Intercom",
".",
"io",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/intercom.py#L69-L80 | [
"def",
"intercom",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | uservoice | UserVoice tracking template tag.
Renders Javascript code to track page visits. You must supply
your UserVoice Widget Key in the ``USERVOICE_WIDGET_KEY``
setting or the ``uservoice_widget_key`` template context variable. | analytical/templatetags/uservoice.py | def uservoice(parser, token):
"""
UserVoice tracking template tag.
Renders Javascript code to track page visits. You must supply
your UserVoice Widget Key in the ``USERVOICE_WIDGET_KEY``
setting or the ``uservoice_widget_key`` template context variable.
"""
bits = token.split_contents()
... | def uservoice(parser, token):
"""
UserVoice tracking template tag.
Renders Javascript code to track page visits. You must supply
your UserVoice Widget Key in the ``USERVOICE_WIDGET_KEY``
setting or the ``uservoice_widget_key`` template context variable.
"""
bits = token.split_contents()
... | [
"UserVoice",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/uservoice.py#L36-L47 | [
"def",
"uservoice",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]"... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | kiss_metrics | KISSinsights tracking template tag.
Renders Javascript code to track page visits. You must supply
your KISSmetrics API key in the ``KISS_METRICS_API_KEY``
setting. | analytical/templatetags/kiss_metrics.py | def kiss_metrics(parser, token):
"""
KISSinsights tracking template tag.
Renders Javascript code to track page visits. You must supply
your KISSmetrics API key in the ``KISS_METRICS_API_KEY``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError... | def kiss_metrics(parser, token):
"""
KISSinsights tracking template tag.
Renders Javascript code to track page visits. You must supply
your KISSmetrics API key in the ``KISS_METRICS_API_KEY``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError... | [
"KISSinsights",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/kiss_metrics.py#L48-L59 | [
"def",
"kiss_metrics",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | piwik | Piwik tracking template tag.
Renders Javascript code to track page visits. You must supply
your Piwik domain (plus optional URI path), and tracked site ID
in the ``PIWIK_DOMAIN_PATH`` and the ``PIWIK_SITE_ID`` setting.
Custom variables can be passed in the ``piwik_vars`` context
variable. It is ... | analytical/templatetags/piwik.py | def piwik(parser, token):
"""
Piwik tracking template tag.
Renders Javascript code to track page visits. You must supply
your Piwik domain (plus optional URI path), and tracked site ID
in the ``PIWIK_DOMAIN_PATH`` and the ``PIWIK_SITE_ID`` setting.
Custom variables can be passed in the ``piwi... | def piwik(parser, token):
"""
Piwik tracking template tag.
Renders Javascript code to track page visits. You must supply
your Piwik domain (plus optional URI path), and tracked site ID
in the ``PIWIK_DOMAIN_PATH`` and the ``PIWIK_SITE_ID`` setting.
Custom variables can be passed in the ``piwi... | [
"Piwik",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/piwik.py#L57-L74 | [
"def",
"piwik",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | get_required_setting | Return a constant from ``django.conf.settings``. The `setting`
argument is the constant name, the `value_re` argument is a regular
expression used to validate the setting value and the `invalid_msg`
argument is used as exception message if the value is not valid. | analytical/utils.py | def get_required_setting(setting, value_re, invalid_msg):
"""
Return a constant from ``django.conf.settings``. The `setting`
argument is the constant name, the `value_re` argument is a regular
expression used to validate the setting value and the `invalid_msg`
argument is used as exception message ... | def get_required_setting(setting, value_re, invalid_msg):
"""
Return a constant from ``django.conf.settings``. The `setting`
argument is the constant name, the `value_re` argument is a regular
expression used to validate the setting value and the `invalid_msg`
argument is used as exception message ... | [
"Return",
"a",
"constant",
"from",
"django",
".",
"conf",
".",
"settings",
".",
"The",
"setting",
"argument",
"is",
"the",
"constant",
"name",
"the",
"value_re",
"argument",
"is",
"a",
"regular",
"expression",
"used",
"to",
"validate",
"the",
"setting",
"val... | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/utils.py#L13-L30 | [
"def",
"get_required_setting",
"(",
"setting",
",",
"value_re",
",",
"invalid_msg",
")",
":",
"try",
":",
"value",
"=",
"getattr",
"(",
"settings",
",",
"setting",
")",
"except",
"AttributeError",
":",
"raise",
"AnalyticalException",
"(",
"\"%s setting: not found\... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | get_user_from_context | Get the user instance from the template context, if possible.
If the context does not contain a `request` or `user` attribute,
`None` is returned. | analytical/utils.py | def get_user_from_context(context):
"""
Get the user instance from the template context, if possible.
If the context does not contain a `request` or `user` attribute,
`None` is returned.
"""
try:
return context['user']
except KeyError:
pass
try:
request = context... | def get_user_from_context(context):
"""
Get the user instance from the template context, if possible.
If the context does not contain a `request` or `user` attribute,
`None` is returned.
"""
try:
return context['user']
except KeyError:
pass
try:
request = context... | [
"Get",
"the",
"user",
"instance",
"from",
"the",
"template",
"context",
"if",
"possible",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/utils.py#L33-L49 | [
"def",
"get_user_from_context",
"(",
"context",
")",
":",
"try",
":",
"return",
"context",
"[",
"'user'",
"]",
"except",
"KeyError",
":",
"pass",
"try",
":",
"request",
"=",
"context",
"[",
"'request'",
"]",
"return",
"request",
".",
"user",
"except",
"(",... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | get_identity | Get the identity of a logged in user from a template context.
The `prefix` argument is used to provide different identities to
different analytics services. The `identity_func` argument is a
function that returns the identity of the user; by default the
identity is the username. | analytical/utils.py | def get_identity(context, prefix=None, identity_func=None, user=None):
"""
Get the identity of a logged in user from a template context.
The `prefix` argument is used to provide different identities to
different analytics services. The `identity_func` argument is a
function that returns the identi... | def get_identity(context, prefix=None, identity_func=None, user=None):
"""
Get the identity of a logged in user from a template context.
The `prefix` argument is used to provide different identities to
different analytics services. The `identity_func` argument is a
function that returns the identi... | [
"Get",
"the",
"identity",
"of",
"a",
"logged",
"in",
"user",
"from",
"a",
"template",
"context",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/utils.py#L65-L94 | [
"def",
"get_identity",
"(",
"context",
",",
"prefix",
"=",
"None",
",",
"identity_func",
"=",
"None",
",",
"user",
"=",
"None",
")",
":",
"if",
"prefix",
"is",
"not",
"None",
":",
"try",
":",
"return",
"context",
"[",
"'%s_identity'",
"%",
"prefix",
"]... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | get_domain | Return the domain used for the tracking code. Each service may be
configured with its own domain (called `<name>_domain`), or a
django-analytical-wide domain may be set (using `analytical_domain`.
If no explicit domain is found in either the context or the
settings, try to get the domain from the cont... | analytical/utils.py | def get_domain(context, prefix):
"""
Return the domain used for the tracking code. Each service may be
configured with its own domain (called `<name>_domain`), or a
django-analytical-wide domain may be set (using `analytical_domain`.
If no explicit domain is found in either the context or the
... | def get_domain(context, prefix):
"""
Return the domain used for the tracking code. Each service may be
configured with its own domain (called `<name>_domain`), or a
django-analytical-wide domain may be set (using `analytical_domain`.
If no explicit domain is found in either the context or the
... | [
"Return",
"the",
"domain",
"used",
"for",
"the",
"tracking",
"code",
".",
"Each",
"service",
"may",
"be",
"configured",
"with",
"its",
"own",
"domain",
"(",
"called",
"<name",
">",
"_domain",
")",
"or",
"a",
"django",
"-",
"analytical",
"-",
"wide",
"dom... | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/utils.py#L97-L120 | [
"def",
"get_domain",
"(",
"context",
",",
"prefix",
")",
":",
"domain",
"=",
"context",
".",
"get",
"(",
"'%s_domain'",
"%",
"prefix",
")",
"if",
"domain",
"is",
"None",
":",
"domain",
"=",
"context",
".",
"get",
"(",
"'analytical_domain'",
")",
"if",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | is_internal_ip | Return whether the visitor is coming from an internal IP address,
based on information from the template context.
The prefix is used to allow different analytics services to have
different notions of internal addresses. | analytical/utils.py | def is_internal_ip(context, prefix=None):
"""
Return whether the visitor is coming from an internal IP address,
based on information from the template context.
The prefix is used to allow different analytics services to have
different notions of internal addresses.
"""
try:
request ... | def is_internal_ip(context, prefix=None):
"""
Return whether the visitor is coming from an internal IP address,
based on information from the template context.
The prefix is used to allow different analytics services to have
different notions of internal addresses.
"""
try:
request ... | [
"Return",
"whether",
"the",
"visitor",
"is",
"coming",
"from",
"an",
"internal",
"IP",
"address",
"based",
"on",
"information",
"from",
"the",
"template",
"context",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/utils.py#L123-L149 | [
"def",
"is_internal_ip",
"(",
"context",
",",
"prefix",
"=",
"None",
")",
":",
"try",
":",
"request",
"=",
"context",
"[",
"'request'",
"]",
"remote_ip",
"=",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_FORWARDED_FOR'",
",",
"''",
")",
"if",
"not",... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | mixpanel | Mixpanel tracking template tag.
Renders Javascript code to track page visits. You must supply
your Mixpanel token in the ``MIXPANEL_API_TOKEN`` setting. | analytical/templatetags/mixpanel.py | def mixpanel(parser, token):
"""
Mixpanel tracking template tag.
Renders Javascript code to track page visits. You must supply
your Mixpanel token in the ``MIXPANEL_API_TOKEN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arg... | def mixpanel(parser, token):
"""
Mixpanel tracking template tag.
Renders Javascript code to track page visits. You must supply
your Mixpanel token in the ``MIXPANEL_API_TOKEN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arg... | [
"Mixpanel",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/mixpanel.py#L35-L45 | [
"def",
"mixpanel",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | gosquared | GoSquared tracking template tag.
Renders Javascript code to track page visits. You must supply
your GoSquared site token in the ``GOSQUARED_SITE_TOKEN`` setting. | analytical/templatetags/gosquared.py | def gosquared(parser, token):
"""
GoSquared tracking template tag.
Renders Javascript code to track page visits. You must supply
your GoSquared site token in the ``GOSQUARED_SITE_TOKEN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' ta... | def gosquared(parser, token):
"""
GoSquared tracking template tag.
Renders Javascript code to track page visits. You must supply
your GoSquared site token in the ``GOSQUARED_SITE_TOKEN`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' ta... | [
"GoSquared",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/gosquared.py#L38-L48 | [
"def",
"gosquared",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]"... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | olark | Olark set-up template tag.
Renders Javascript code to set-up Olark chat. You must supply
your site ID in the ``OLARK_SITE_ID`` setting. | analytical/templatetags/olark.py | def olark(parser, token):
"""
Olark set-up template tag.
Renders Javascript code to set-up Olark chat. You must supply
your site ID in the ``OLARK_SITE_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % bits[0])
... | def olark(parser, token):
"""
Olark set-up template tag.
Renders Javascript code to set-up Olark chat. You must supply
your site ID in the ``OLARK_SITE_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments" % bits[0])
... | [
"Olark",
"set",
"-",
"up",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/olark.py#L46-L56 | [
"def",
"olark",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | clickmap | Clickmap tracker template tag.
Renders Javascript code to track page visits. You must supply
your clickmap tracker ID (as a string) in the ``CLICKMAP_TRACKER_ID``
setting. | analytical/templatetags/clickmap.py | def clickmap(parser, token):
"""
Clickmap tracker template tag.
Renders Javascript code to track page visits. You must supply
your clickmap tracker ID (as a string) in the ``CLICKMAP_TRACKER_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxE... | def clickmap(parser, token):
"""
Clickmap tracker template tag.
Renders Javascript code to track page visits. You must supply
your clickmap tracker ID (as a string) in the ``CLICKMAP_TRACKER_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxE... | [
"Clickmap",
"tracker",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/clickmap.py#L32-L43 | [
"def",
"clickmap",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | gauges | Gaug.es template tag.
Renders Javascript code to gaug.es testing. You must supply
your Site ID account number in the ``GAUGES_SITE_ID``
setting. | analytical/templatetags/gauges.py | def gauges(parser, token):
"""
Gaug.es template tag.
Renders Javascript code to gaug.es testing. You must supply
your Site ID account number in the ``GAUGES_SITE_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments... | def gauges(parser, token):
"""
Gaug.es template tag.
Renders Javascript code to gaug.es testing. You must supply
your Site ID account number in the ``GAUGES_SITE_ID``
setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes no arguments... | [
"Gaug",
".",
"es",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/gauges.py#L34-L45 | [
"def",
"gauges",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | crazy_egg | Crazy Egg tracking template tag.
Renders Javascript code to track page clicks. You must supply
your Crazy Egg account number (as a string) in the
``CRAZY_EGG_ACCOUNT_NUMBER`` setting. | analytical/templatetags/crazy_egg.py | def crazy_egg(parser, token):
"""
Crazy Egg tracking template tag.
Renders Javascript code to track page clicks. You must supply
your Crazy Egg account number (as a string) in the
``CRAZY_EGG_ACCOUNT_NUMBER`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Te... | def crazy_egg(parser, token):
"""
Crazy Egg tracking template tag.
Renders Javascript code to track page clicks. You must supply
your Crazy Egg account number (as a string) in the
``CRAZY_EGG_ACCOUNT_NUMBER`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise Te... | [
"Crazy",
"Egg",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/crazy_egg.py#L26-L37 | [
"def",
"crazy_egg",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]"... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | yandex_metrica | Yandex.Metrica counter template tag.
Renders Javascript code to track page visits. You must supply
your website counter ID (as a string) in the
``YANDEX_METRICA_COUNTER_ID`` setting. | analytical/templatetags/yandex_metrica.py | def yandex_metrica(parser, token):
"""
Yandex.Metrica counter template tag.
Renders Javascript code to track page visits. You must supply
your website counter ID (as a string) in the
``YANDEX_METRICA_COUNTER_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise... | def yandex_metrica(parser, token):
"""
Yandex.Metrica counter template tag.
Renders Javascript code to track page visits. You must supply
your website counter ID (as a string) in the
``YANDEX_METRICA_COUNTER_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise... | [
"Yandex",
".",
"Metrica",
"counter",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/yandex_metrica.py#L47-L58 | [
"def",
"yandex_metrica",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | hubspot | HubSpot tracking template tag.
Renders Javascript code to track page visits. You must supply
your portal ID (as a string) in the ``HUBSPOT_PORTAL_ID`` setting. | analytical/templatetags/hubspot.py | def hubspot(parser, token):
"""
HubSpot tracking template tag.
Renders Javascript code to track page visits. You must supply
your portal ID (as a string) in the ``HUBSPOT_PORTAL_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes ... | def hubspot(parser, token):
"""
HubSpot tracking template tag.
Renders Javascript code to track page visits. You must supply
your portal ID (as a string) in the ``HUBSPOT_PORTAL_ID`` setting.
"""
bits = token.split_contents()
if len(bits) > 1:
raise TemplateSyntaxError("'%s' takes ... | [
"HubSpot",
"tracking",
"template",
"tag",
"."
] | jazzband/django-analytical | python | https://github.com/jazzband/django-analytical/blob/5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3/analytical/templatetags/hubspot.py#L32-L42 | [
"def",
"hubspot",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
">",
"1",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes no arguments\"",
"%",
"bits",
"[",
"0",
"]",
... | 5487fd677bd47bc63fc2cf39597a0adc5d6c9ab3 |
valid | status_printer | Manage the printing and in-place updating of a line of characters
.. note::
If the string is longer than a line, then in-place updating may not
work (it will print a new line at each refresh). | mutmut/__main__.py | def status_printer():
"""Manage the printing and in-place updating of a line of characters
.. note::
If the string is longer than a line, then in-place updating may not
work (it will print a new line at each refresh).
"""
last_len = [0]
def p(s):
s = next(spinner) + ' ' + s... | def status_printer():
"""Manage the printing and in-place updating of a line of characters
.. note::
If the string is longer than a line, then in-place updating may not
work (it will print a new line at each refresh).
"""
last_len = [0]
def p(s):
s = next(spinner) + ' ' + s... | [
"Manage",
"the",
"printing",
"and",
"in",
"-",
"place",
"updating",
"of",
"a",
"line",
"of",
"characters"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L80-L96 | [
"def",
"status_printer",
"(",
")",
":",
"last_len",
"=",
"[",
"0",
"]",
"def",
"p",
"(",
"s",
")",
":",
"s",
"=",
"next",
"(",
"spinner",
")",
"+",
"' '",
"+",
"s",
"len_s",
"=",
"len",
"(",
"s",
")",
"output",
"=",
"'\\r'",
"+",
"s",
"+",
... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | get_or_guess_paths_to_mutate | :type paths_to_mutate: str or None
:rtype: str | mutmut/__main__.py | def get_or_guess_paths_to_mutate(paths_to_mutate):
"""
:type paths_to_mutate: str or None
:rtype: str
"""
if paths_to_mutate is None:
# Guess path with code
this_dir = os.getcwd().split(os.sep)[-1]
if isdir('lib'):
return 'lib'
elif isdir('src'):
... | def get_or_guess_paths_to_mutate(paths_to_mutate):
"""
:type paths_to_mutate: str or None
:rtype: str
"""
if paths_to_mutate is None:
# Guess path with code
this_dir = os.getcwd().split(os.sep)[-1]
if isdir('lib'):
return 'lib'
elif isdir('src'):
... | [
":",
"type",
"paths_to_mutate",
":",
"str",
"or",
"None",
":",
"rtype",
":",
"str"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L102-L130 | [
"def",
"get_or_guess_paths_to_mutate",
"(",
"paths_to_mutate",
")",
":",
"if",
"paths_to_mutate",
"is",
"None",
":",
"# Guess path with code",
"this_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
".",
"split",
"(",
"os",
".",
"sep",
")",
"[",
"-",
"1",
"]",
"if... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | do_apply | Apply a specified mutant to the source code
:param mutation_pk: mutmut cache primary key of the mutant to apply
:type mutation_pk: str
:param dict_synonyms: list of synonym keywords for a python dictionary
:type dict_synonyms: list[str]
:param backup: if :obj:`True` create a backup of the source ... | mutmut/__main__.py | def do_apply(mutation_pk, dict_synonyms, backup):
"""Apply a specified mutant to the source code
:param mutation_pk: mutmut cache primary key of the mutant to apply
:type mutation_pk: str
:param dict_synonyms: list of synonym keywords for a python dictionary
:type dict_synonyms: list[str]
:pa... | def do_apply(mutation_pk, dict_synonyms, backup):
"""Apply a specified mutant to the source code
:param mutation_pk: mutmut cache primary key of the mutant to apply
:type mutation_pk: str
:param dict_synonyms: list of synonym keywords for a python dictionary
:type dict_synonyms: list[str]
:pa... | [
"Apply",
"a",
"specified",
"mutant",
"to",
"the",
"source",
"code"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L133-L160 | [
"def",
"do_apply",
"(",
"mutation_pk",
",",
"dict_synonyms",
",",
"backup",
")",
":",
"filename",
",",
"mutation_id",
"=",
"filename_and_mutation_id_from_pk",
"(",
"int",
"(",
"mutation_pk",
")",
")",
"update_line_numbers",
"(",
"filename",
")",
"context",
"=",
... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | climain | commands:\n
run [mutation id]\n
Runs mutmut. You probably want to start with just trying this. If you supply a mutation ID mutmut will check just this mutant.\n
results\n
Print the results.\n
apply [mutation id]\n
Apply a mutation on disk.\n
show [mutation id]\n
Show a mu... | mutmut/__main__.py | def climain(command, argument, argument2, paths_to_mutate, backup, runner, tests_dir,
test_time_multiplier, test_time_base,
swallow_output, use_coverage, dict_synonyms, cache_only, version,
suspicious_policy, untested_policy, pre_mutation, post_mutation,
use_patch_file):
... | def climain(command, argument, argument2, paths_to_mutate, backup, runner, tests_dir,
test_time_multiplier, test_time_base,
swallow_output, use_coverage, dict_synonyms, cache_only, version,
suspicious_policy, untested_policy, pre_mutation, post_mutation,
use_patch_file):
... | [
"commands",
":",
"\\",
"n",
"run",
"[",
"mutation",
"id",
"]",
"\\",
"n",
"Runs",
"mutmut",
".",
"You",
"probably",
"want",
"to",
"start",
"with",
"just",
"trying",
"this",
".",
"If",
"you",
"supply",
"a",
"mutation",
"ID",
"mutmut",
"will",
"check",
... | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L228-L254 | [
"def",
"climain",
"(",
"command",
",",
"argument",
",",
"argument2",
",",
"paths_to_mutate",
",",
"backup",
",",
"runner",
",",
"tests_dir",
",",
"test_time_multiplier",
",",
"test_time_base",
",",
"swallow_output",
",",
"use_coverage",
",",
"dict_synonyms",
",",
... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | main | return exit code, after performing an mutation test run.
:return: the exit code from executing the mutation tests
:rtype: int | mutmut/__main__.py | def main(command, argument, argument2, paths_to_mutate, backup, runner, tests_dir,
test_time_multiplier, test_time_base,
swallow_output, use_coverage, dict_synonyms, cache_only, version,
suspicious_policy, untested_policy, pre_mutation, post_mutation,
use_patch_file):
"""return e... | def main(command, argument, argument2, paths_to_mutate, backup, runner, tests_dir,
test_time_multiplier, test_time_base,
swallow_output, use_coverage, dict_synonyms, cache_only, version,
suspicious_policy, untested_policy, pre_mutation, post_mutation,
use_patch_file):
"""return e... | [
"return",
"exit",
"code",
"after",
"performing",
"an",
"mutation",
"test",
"run",
"."
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L257-L433 | [
"def",
"main",
"(",
"command",
",",
"argument",
",",
"argument2",
",",
"paths_to_mutate",
",",
"backup",
",",
"runner",
",",
"tests_dir",
",",
"test_time_multiplier",
",",
"test_time_base",
",",
"swallow_output",
",",
"use_coverage",
",",
"dict_synonyms",
",",
"... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | popen_streaming_output | Open a subprocess and stream its output without hard-blocking.
:param cmd: the command to execute within the subprocess
:type cmd: str
:param callback: function that intakes the subprocess' stdout line by line.
It is called for each line received from the subprocess' stdout stream.
:type callb... | mutmut/__main__.py | def popen_streaming_output(cmd, callback, timeout=None):
"""Open a subprocess and stream its output without hard-blocking.
:param cmd: the command to execute within the subprocess
:type cmd: str
:param callback: function that intakes the subprocess' stdout line by line.
It is called for each l... | def popen_streaming_output(cmd, callback, timeout=None):
"""Open a subprocess and stream its output without hard-blocking.
:param cmd: the command to execute within the subprocess
:type cmd: str
:param callback: function that intakes the subprocess' stdout line by line.
It is called for each l... | [
"Open",
"a",
"subprocess",
"and",
"stream",
"its",
"output",
"without",
"hard",
"-",
"blocking",
"."
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L436-L511 | [
"def",
"popen_streaming_output",
"(",
"cmd",
",",
"callback",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"# pragma: no cover",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"shlex",
".",
"split",
"(",
"cmd",
")"... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | run_mutation | :type config: Config
:type filename: str
:type mutation_id: MutationID
:return: (computed or cached) status of the tested mutant
:rtype: str | mutmut/__main__.py | def run_mutation(config, filename, mutation_id):
"""
:type config: Config
:type filename: str
:type mutation_id: MutationID
:return: (computed or cached) status of the tested mutant
:rtype: str
"""
context = Context(
mutation_id=mutation_id,
filename=filename,
exc... | def run_mutation(config, filename, mutation_id):
"""
:type config: Config
:type filename: str
:type mutation_id: MutationID
:return: (computed or cached) status of the tested mutant
:rtype: str
"""
context = Context(
mutation_id=mutation_id,
filename=filename,
exc... | [
":",
"type",
"config",
":",
"Config",
":",
"type",
"filename",
":",
"str",
":",
"type",
"mutation_id",
":",
"MutationID",
":",
"return",
":",
"(",
"computed",
"or",
"cached",
")",
"status",
"of",
"the",
"tested",
"mutant",
":",
"rtype",
":",
"str"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L532-L600 | [
"def",
"run_mutation",
"(",
"config",
",",
"filename",
",",
"mutation_id",
")",
":",
"context",
"=",
"Context",
"(",
"mutation_id",
"=",
"mutation_id",
",",
"filename",
"=",
"filename",
",",
"exclude",
"=",
"config",
".",
"exclude_callback",
",",
"dict_synonym... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | read_coverage_data | :rtype: CoverageData or None | mutmut/__main__.py | def read_coverage_data():
"""
:rtype: CoverageData or None
"""
print('Using coverage data from .coverage file')
# noinspection PyPackageRequirements,PyUnresolvedReferences
from coverage import Coverage
cov = Coverage('.coverage')
cov.load()
return cov.get_data() | def read_coverage_data():
"""
:rtype: CoverageData or None
"""
print('Using coverage data from .coverage file')
# noinspection PyPackageRequirements,PyUnresolvedReferences
from coverage import Coverage
cov = Coverage('.coverage')
cov.load()
return cov.get_data() | [
":",
"rtype",
":",
"CoverageData",
"or",
"None"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L627-L636 | [
"def",
"read_coverage_data",
"(",
")",
":",
"print",
"(",
"'Using coverage data from .coverage file'",
")",
"# noinspection PyPackageRequirements,PyUnresolvedReferences",
"from",
"coverage",
"import",
"Coverage",
"cov",
"=",
"Coverage",
"(",
"'.coverage'",
")",
"cov",
".",
... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | add_mutations_by_file | :type mutations_by_file: dict[str, list[MutationID]]
:type filename: str
:type exclude: Callable[[Context], bool]
:type dict_synonyms: list[str] | mutmut/__main__.py | def add_mutations_by_file(mutations_by_file, filename, exclude, dict_synonyms):
"""
:type mutations_by_file: dict[str, list[MutationID]]
:type filename: str
:type exclude: Callable[[Context], bool]
:type dict_synonyms: list[str]
"""
with open(filename) as f:
source = f.read()
con... | def add_mutations_by_file(mutations_by_file, filename, exclude, dict_synonyms):
"""
:type mutations_by_file: dict[str, list[MutationID]]
:type filename: str
:type exclude: Callable[[Context], bool]
:type dict_synonyms: list[str]
"""
with open(filename) as f:
source = f.read()
con... | [
":",
"type",
"mutations_by_file",
":",
"dict",
"[",
"str",
"list",
"[",
"MutationID",
"]]",
":",
"type",
"filename",
":",
"str",
":",
"type",
"exclude",
":",
"Callable",
"[[",
"Context",
"]",
"bool",
"]",
":",
"type",
"dict_synonyms",
":",
"list",
"[",
... | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L703-L723 | [
"def",
"add_mutations_by_file",
"(",
"mutations_by_file",
",",
"filename",
",",
"exclude",
",",
"dict_synonyms",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"source",
"=",
"f",
".",
"read",
"(",
")",
"context",
"=",
"Context",
"(",
"s... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | python_source_files | Attempt to guess where the python source files to mutate are and yield
their paths
:param path: path to a python source file or package directory
:type path: str
:param tests_dirs: list of directory paths containing test files
(we do not want to mutate these!)
:type tests_dirs: list[str]
... | mutmut/__main__.py | def python_source_files(path, tests_dirs):
"""Attempt to guess where the python source files to mutate are and yield
their paths
:param path: path to a python source file or package directory
:type path: str
:param tests_dirs: list of directory paths containing test files
(we do not want t... | def python_source_files(path, tests_dirs):
"""Attempt to guess where the python source files to mutate are and yield
their paths
:param path: path to a python source file or package directory
:type path: str
:param tests_dirs: list of directory paths containing test files
(we do not want t... | [
"Attempt",
"to",
"guess",
"where",
"the",
"python",
"source",
"files",
"to",
"mutate",
"are",
"and",
"yield",
"their",
"paths"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L726-L747 | [
"def",
"python_source_files",
"(",
"path",
",",
"tests_dirs",
")",
":",
"if",
"isdir",
"(",
"path",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"dirs",
"[",
":",
"]",
"=",
"[",
"d",
"for",
... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | compute_exit_code | Compute an exit code for mutmut mutation testing
The following exit codes are available for mutmut:
* 0 if all mutants were killed (OK_KILLED)
* 1 if a fatal error occurred
* 2 if one or more mutants survived (BAD_SURVIVED)
* 4 if one or more mutants timed out (BAD_TIMEOUT)
* 8 if one or m... | mutmut/__main__.py | def compute_exit_code(config, exception=None):
"""Compute an exit code for mutmut mutation testing
The following exit codes are available for mutmut:
* 0 if all mutants were killed (OK_KILLED)
* 1 if a fatal error occurred
* 2 if one or more mutants survived (BAD_SURVIVED)
* 4 if one or mor... | def compute_exit_code(config, exception=None):
"""Compute an exit code for mutmut mutation testing
The following exit codes are available for mutmut:
* 0 if all mutants were killed (OK_KILLED)
* 1 if a fatal error occurred
* 2 if one or more mutants survived (BAD_SURVIVED)
* 4 if one or mor... | [
"Compute",
"an",
"exit",
"code",
"for",
"mutmut",
"mutation",
"testing"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__main__.py#L750-L780 | [
"def",
"compute_exit_code",
"(",
"config",
",",
"exception",
"=",
"None",
")",
":",
"code",
"=",
"0",
"if",
"exception",
"is",
"not",
"None",
":",
"code",
"=",
"code",
"|",
"1",
"if",
"config",
".",
"surviving_mutants",
">",
"0",
":",
"code",
"=",
"c... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | argument_mutation | :type context: Context | mutmut/__init__.py | def argument_mutation(children, context, **_):
"""
:type context: Context
"""
if len(context.stack) >= 3 and context.stack[-3].type in ('power', 'atom_expr'):
stack_pos_of_power_node = -3
elif len(context.stack) >= 4 and context.stack[-4].type in ('power', 'atom_expr'):
stack_pos_of_... | def argument_mutation(children, context, **_):
"""
:type context: Context
"""
if len(context.stack) >= 3 and context.stack[-3].type in ('power', 'atom_expr'):
stack_pos_of_power_node = -3
elif len(context.stack) >= 4 and context.stack[-4].type in ('power', 'atom_expr'):
stack_pos_of_... | [
":",
"type",
"context",
":",
"Context"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__init__.py#L242-L260 | [
"def",
"argument_mutation",
"(",
"children",
",",
"context",
",",
"*",
"*",
"_",
")",
":",
"if",
"len",
"(",
"context",
".",
"stack",
")",
">=",
"3",
"and",
"context",
".",
"stack",
"[",
"-",
"3",
"]",
".",
"type",
"in",
"(",
"'power'",
",",
"'at... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | mutate | :type context: Context
:return: tuple: mutated source code, number of mutations performed
:rtype: tuple[str, int] | mutmut/__init__.py | def mutate(context):
"""
:type context: Context
:return: tuple: mutated source code, number of mutations performed
:rtype: tuple[str, int]
"""
try:
result = parse(context.source, error_recovery=False)
except Exception:
print('Failed to parse %s. Internal error from parso foll... | def mutate(context):
"""
:type context: Context
:return: tuple: mutated source code, number of mutations performed
:rtype: tuple[str, int]
"""
try:
result = parse(context.source, error_recovery=False)
except Exception:
print('Failed to parse %s. Internal error from parso foll... | [
":",
"type",
"context",
":",
"Context",
":",
"return",
":",
"tuple",
":",
"mutated",
"source",
"code",
"number",
"of",
"mutations",
"performed",
":",
"rtype",
":",
"tuple",
"[",
"str",
"int",
"]"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__init__.py#L488-L509 | [
"def",
"mutate",
"(",
"context",
")",
":",
"try",
":",
"result",
"=",
"parse",
"(",
"context",
".",
"source",
",",
"error_recovery",
"=",
"False",
")",
"except",
"Exception",
":",
"print",
"(",
"'Failed to parse %s. Internal error from parso follows.'",
"%",
"co... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
valid | mutate_node | :type context: Context | mutmut/__init__.py | def mutate_node(node, context):
"""
:type context: Context
"""
context.stack.append(node)
try:
if node.type in ('tfpdef', 'import_from', 'import_name'):
return
if node.start_pos[0] - 1 != context.current_line_index:
context.current_line_index = node.start_pos... | def mutate_node(node, context):
"""
:type context: Context
"""
context.stack.append(node)
try:
if node.type in ('tfpdef', 'import_from', 'import_name'):
return
if node.start_pos[0] - 1 != context.current_line_index:
context.current_line_index = node.start_pos... | [
":",
"type",
"context",
":",
"Context"
] | boxed/mutmut | python | https://github.com/boxed/mutmut/blob/dd3bbe9aba3168ed21b85fbfe0b654b150239697/mutmut/__init__.py#L512-L561 | [
"def",
"mutate_node",
"(",
"node",
",",
"context",
")",
":",
"context",
".",
"stack",
".",
"append",
"(",
"node",
")",
"try",
":",
"if",
"node",
".",
"type",
"in",
"(",
"'tfpdef'",
",",
"'import_from'",
",",
"'import_name'",
")",
":",
"return",
"if",
... | dd3bbe9aba3168ed21b85fbfe0b654b150239697 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.