Showing 22 of 22 total issues
File simulator.py
has 564 lines of code (exceeds 250 allowed). Consider refactoring. Open
""" Discrete event simulator
:Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu>
:Date: 2016-06-01
:Copyright: 2016-2020, Karr Lab
File simulation_object.py
has 426 lines of code (exceeds 250 allowed). Consider refactoring. Open
""" Base class for simulation objects
:Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu>
:Date: 2016-06-01
:Copyright: 2016-2020, Karr Lab
Function render
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def render(self, sim_obj=None, as_list=False, separator='\t'):
""" Return the content of an :obj:`EventQueue`
Make a human-readable event queue, sorted by event time.
Events are sorted by the event order tuple provided by `Event._get_order_time`.
- 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 load_ipython_extension
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function load_ipython_extension() {
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '.codehighlighter { background: yellow; }';
Function validate_individual_fields
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def validate_individual_fields(self):
""" Validate constraints on individual fields in a :obj:`SimulationConfig` instance
Returns:
:obj:`None`: if no error is found
- 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 __handle_event_list
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def __handle_event_list(self, event_list):
""" Handle a list of simulation events, which may contain multiple concurrent events
This is a Python 'dunder' method which creates a class-private member,
reducing the chance that it will be accidentally called or overwritten.
- 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_sim_config
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_sim_config(max_time=None, sim_config=None, config_dict=None):
""" External simulate interface
Legal combinations of the three parameters:
- 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 __new__
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def __new__(cls, clsname, superclasses, namespace):
# Short circuit when EventMessage is defined
if clsname == 'EventMessage':
return super().__new__(cls, clsname, superclasses, namespace)
- 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 _values
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _values(self, to_str=False):
""" Provide the values in an :obj:`EventMessage`
Uninitialized attribute values are returned as `None`, or `str(None)` if `to_str` is set.
- 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 list_checkpoints
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def list_checkpoints(self, error_if_empty=True):
""" Get sorted list of times of saved checkpoints in checkpoint directory `dir_path`
To enhance performance the list of times is cached in attribute `all_checkpoints` and
refreshed from the contents of directory `dir_path` if it has been updated.
- 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 __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, name, s, i, N, beta, gamma, recording_period):
Function run
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def run(self, max_time=None, sim_config=None, config_dict=None, author_metadata=None):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, creation_time, event_time, sending_object, receiving_object, message):
Function simulate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def simulate(self, max_time=None, sim_config=None, config_dict=None, author_metadata=None):
Function schedule_event
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def schedule_event(self, send_time, receive_time, sending_object, receiving_object, event_message):
Function __new__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __new__(cls, clsname, superclasses, namespace):
"""
Args:
cls (:obj:`class`): this class
clsname (:obj:`str`): name of the :class:`BaseSimulationObject` subclass being created
- 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 simulate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def simulate(self, max_time=None, sim_config=None, config_dict=None, author_metadata=None):
""" Run a simulation
Exactly one of the arguments `max_time`, `sim_config`, and `config_dict` must be provided.
See `get_sim_config` for additional constraints on these arguments.
- 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 handle_simulation_event
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def handle_simulation_event(self, event):
""" Handle a simulation event """
del event # Avoid PyLint warning W0613, unused-argument
# schedule event
if random.random() < self.args.frac_self_events or self.args.num_phold_procs == 1:
- 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 too many return
statements within this function. Open
return True
Function send_event_absolute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def send_event_absolute(self, event_time, receiving_object, message, copy=False):
""" Schedule an event containing an event message with an absolute event time.
Args:
event_time (:obj:`float`): the absolute simulation time at which `receiving_object` will execute the event
- 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"