File util.py
has 876 lines of code (exceeds 250 allowed). Consider refactoring. Open
""" Utilities for writing/reading a `wc_lang` model to/from SBML
* Higher level functions for creating, getting, and setting SBML objects
* Utilities for wrapping libSBML calls
Function get_authors_annotation
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def get_authors_annotation(cls, model, sbml_model, model_objs):
""" Import the SBML annotation of the authors of a model to a model
Args:
model (:obj:`wc_lang.core.Model`): model
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
LibSbmlInterface
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class LibSbmlInterface(object):
''' Methods for compactly using libSBML to create SBML objects.
The libSBML method calls provide narrow interfaces, typically exchanging one
value per call, which creates verbose code. The methods below aggregate multiple
Function call_libsbml
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def call_libsbml(cls, method, *args, returns_int=False, debug=False):
""" Call a libSBML method and handle any errors.
Unfortunately, libSBML methods that do not return data usually report errors via return codes,
instead of exceptions, and the generic return codes contain virtually no information.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function parse_annotations
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def parse_annotations(cls, sbml_obj):
""" Import annotations from a model object to an SBML object
Args:
sbml_obj (:obj:`libsbml.SBase`): SBML object
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function create_unit
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create_unit(cls, unit, sbml_model):
""" Add a unit definition to a SBML model
Args:
unit (:obj:`unit_registry.Unit`): unit
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_errors_warnings
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_errors_warnings(cls, sbml_doc):
""" Get libSBML errors and warnings
Args:
sbml_doc (:obj:`libsbml.SBMLDocument`): SBML document
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
for i_author in range(cls.call_libsbml(sbml_authors.getNumChildren, returns_int=True)):
sbml_au = cls.call_libsbml(sbml_authors.getChild, i_author)
au = model.authors.create()
for i_prop in range(cls.call_libsbml(sbml_au.getNumChildren, returns_int=True)):
sbml_prop = cls.call_libsbml(sbml_au.getChild, i_prop)
Function create_base_unit
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_base_unit(cls, unit_def_id, unit_def, kind, exponent=1, scale=0, multiplier=1.0):
Avoid deeply nested control flow statements. Open
if cls.call_libsbml(g_child.getName) == 'key':
attr_name = cls.call_libsbml(g_child.toXMLString)[12:-13]
elif cls.call_libsbml(g_child.getName) == 'value':
val = cls.call_libsbml(g_child.toXMLString)[14:-15]
Function get_annotations
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_annotations(cls, model_obj, nested_attr_paths, sbml_obj, model_objs=None):
""" Import annotations from a model object to an SBML object
Args:
model_obj (:obj:`obj_tables.Model`): model object
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function create_parameter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_parameter(cls, sbml_model, id, value, units, name=None, constant=True):
Function parse_units
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_units(cls, sbml_model):
""" Parse SBML units to Python
Args:
sbml_model (:obj:`libsbml.Model`): SBML model
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function normalize_unit_kind
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def normalize_unit_kind(cls, kind, to_sbml_base_units=True):
""" Normalize unit kind for SBML
Args:
kind (:obj:`str`): unit kind
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"