Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed broken documentation generation. #562

Merged
merged 5 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gillespy2/core/assignmentrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ class AssignmentRule(SortableObject, Jsonify):
"""
An AssignmentRule is used to express equations that set the values of
variables. This would correspond to a function in the form of x = f(V)

:param name: Name of the Rule
:type name: str

:param variable: Target Species/Parameter to be modified by rule
:type variable: str

:param formula: String representation of formula to be evaluated
:type formula: str
"""
Expand Down
32 changes: 16 additions & 16 deletions gillespy2/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class EventAssignment(Jsonify):
depending on how the Event to which it is assigned is configured.

:param variable: Target model component to be modified by the EventAssignment
expression. Valid target variables include gillespy2 Species,
Parameters, and Compartments.
expression. Valid target variables include gillespy2 Species,
Parameters, and Compartments.
:type variable: gillespy2.Species, gillespy2.Parameter

:param expression: String to be evaluated when the event is fired. This expression must
be evaluable within the model namespace, and the results of it's
evaluation will be assigned to the EventAssignment variable.
be evaluable within the model namespace, and the results of it's
evaluation will be assigned to the EventAssignment variable.
:type expression: str

"""
Expand Down Expand Up @@ -57,7 +57,7 @@ class EventTrigger(Jsonify):
the delay evaluation will be initialized.

:param expression: String for a function calculating EventTrigger values. Should be evaluable
in namespace of Model.
in namespace of Model.
:type expression: str

:param value: Value of EventTrigger at simulation start, with time t=0
Expand Down Expand Up @@ -97,7 +97,6 @@ def sanitized_expression(self, species_mappings, parameter_mappings):


class Event(Jsonify):

"""
An Event can be given as an assignment_expression (function) or directly
as a value (scalar). If given an assignment_expression, it should be
Expand All @@ -110,22 +109,22 @@ class Event(Jsonify):
:type assignments: str

:param trigger: contains math expression which can be evaluated to
a boolean result. Upon the transition from 'False' to 'True',
event assignments may be executed immediately, or after a
designated delay.
a boolean result. Upon the transition from 'False' to 'True',
event assignments may be executed immediately, or after a
designated delay.
:type trigger: EventTrigger

:param delay: contains math expression evaluable within model namespace.
This expression designates a delay between the trigger of
an event and the execution of its assignments.
This expression designates a delay between the trigger of
an event and the execution of its assignments.
:type delay: str

:param priority: Contains math expression evaluable within model namespace.
:type priority: str

:param use_values_from_trigger_time
:type use_values_from_trigger_time: bool
"""

def __eq__(self, other):
return str(self) == str(other)

Expand Down Expand Up @@ -219,11 +218,12 @@ def __str__(self):

def add_assignment(self, assignment):
"""
Adds an eventAssignment or a list of eventAssignments.
:param assignment: EventAssignment or a list of EventAssignments
The event or list of events to be added to this event.
:type assignment: EventAssignment or list of EventAssignments
Adds an EventAssignment or a list of EventAssignment.

:param assignment: The event or list of events to be added to this event.
:type assignment: EventAssignment or list[EventAssignment]
"""

if hasattr(assignment, 'variable'):
self.assignments.append(assignment)
elif isinstance(assignment, list):
Expand Down
4 changes: 3 additions & 1 deletion gillespy2/core/functiondefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ class FunctionDefinition(SortableObject, Jsonify):

:param name: Name of the function to be made and called
:type name: str

:param function: Defined function body of operation to be performed.
:type function: str

:param variables: String names of Variables to be used as arguments to function.
:type variables: list of strings
:type variables: list[str]
"""

def __init__(self, name="", function=None, args=[]):
Expand Down
55 changes: 28 additions & 27 deletions gillespy2/core/gillespySolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,40 @@


class GillesPySolver:
name = "GillesPySolver"
"""
Abstract class for a solver. This is generally called from within a
gillespy Model through the Model.run function. Returns simulation
trajectories.

:param model: The model on which the solver will operate.
:type model: gillespy.Model

:param t: The end time of the solver
:type t: int

:param number_of_trajectories: The number of times to sample the chemical master equation. Each
trajectory will be returned at the end of the simulation.
:type number_of_trajectories: int

:param increment: The time step of the solution
:type increment: float

:param seed: The random seed for the simulation. Defaults to None.
:type seed: int

:param debug: Set to True to provide additional debug information about the
simulation.
:type debug: bool

:param show_labels: Use names of species as index of result object rather than position numbers.
:type show_labels: bool
Abstract class for a solver.
"""

name = "GillesPySolver"

def run(self, model, t=20, number_of_trajectories=1, increment=0.05, seed=None,
debug=False, profile=False, show_labels=None, **kwargs):
"""
Call out and run the solver. Collect the results.

:param model: The model on which the solver will operate.
:type model: gillespy.Model

:param t: The end time of the solver
:type t: int

:param number_of_trajectories: The number of times to sample the chemical master equation. Each
trajectory will be returned at the end of the simulation.
:type number_of_trajectories: int

:param increment: The time step of the solution
:type increment: float

:param seed: The random seed for the simulation. Defaults to None.
:type seed: int

:param debug: Set to True to provide additional debug information about the simulation.
:type debug: bool

:param show_labels: Use names of species as index of result object rather than position numbers.
:type show_labels: bool

:returns: Simulation trajectories.
"""
raise SimulationError("This abstract solver class cannot be used directly.")

Expand Down
46 changes: 45 additions & 1 deletion gillespy2/core/jsonify.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def to_json(self, encode_private=True) -> str:
Convert self into a json string.

:param encode_private: If True all private (prefixed of '_') will be encoded. None if False.
:type encode_private: bool

:returns: The JSON representation of self.
"""

Expand All @@ -35,6 +37,9 @@ def from_json(cls, json_str: str) -> object:
return a new instance of the type.

:param json_str: A json str to be converted into a new type instance.
:type json_str: str

:returns: A decoded object.
"""

# If the json_str is actually a dict, it means we've decoded as much as possible.
Expand Down Expand Up @@ -62,7 +67,10 @@ def from_dict(cls, src_dict: dict) -> object:
Convert some dict into a new instance of a python type.
This function will return a __new__ instance of the type.

:param dict: The dictionary to apply onto the new instance.
:param src_dict: The dictionary to apply onto the new instance.
:type src_dict: dict

:returns: A new object with its backing __dict__ set to a copy of src_dict.
"""

new = cls.__new__(cls)
Expand Down Expand Up @@ -117,6 +125,14 @@ def get_json_hash(self, ignore_whitespace=True, hash_private_vals=False) -> str:
"""
Get the hash of the json representation of self.

:param ignore_whitespace: If set to True all whitespace will be stripped from the JSON
prior to being hashed.
:type ignore_whitespace: bool

:param hash_private_vals: If set to True all private and non-private variables will
be included in the hash.
:type hash_private_vals: bool

:returns: An MD5 hash of the object's sorted JSON representation.
"""

Expand All @@ -133,12 +149,25 @@ def __eq__(self, o: "Jsonify"):
"""
Overload to compare the json of two objects that derive from Jsonify.
This method will not do any additional translation.

:param o: The Jsonify object to compare against.
:type o: Jsonify

:returns: True if equal, False if not.
"""
return self.get_json_hash() == o.get_json_hash()

class ComplexJsonCoder(JSONEncoder):
"""
This class delegates the encoding and decoding of objects to one or more implementees.

:param translation_table: A TranslationTable instance that will be used to
translate objects.
:type translation_table: TranslationTable

:param encode_private: If set to True then all private and public variables will
be converted to JSON. If False, only public.
:type encode_private: bool
"""

def __init__(self, translation_table=None, encode_private=True, **kwargs):
Expand Down Expand Up @@ -195,6 +224,8 @@ def decode(self, json_dict: dict):
Decode the JSON dictionary into a valid Python object.

:param json_dict: The JSON dictionary to decode.
:type json_dict: dict

:returns: The decoded form of the JSON dictionary.
"""

Expand All @@ -219,6 +250,10 @@ class TranslationTable(Jsonify):
"""
This class contains functions to enable arbitrary object trees to be "translated" to anonymous
and named objects. This behavior is defined by a map of 'named' and 'anon' key values.

:param to_anon: A mapping of 'named' to 'anonymous' strings to be used when converting
user-defined names to anon.
:type to_anon: dict[str, str]
"""

def __init__(self, to_anon: "dict[str, str]"):
Expand All @@ -229,6 +264,9 @@ def obj_to_anon(self, obj: object):
"""
Recursively anonymise all named properties on the object.

:param obj: The object to anonymize.
:type obj: object

:returns: An anonymized instance of self.
"""

Expand All @@ -238,6 +276,9 @@ def obj_to_named(self, obj):
"""
Recursively identify all anonymous properties on the object.

:param obj: The object that will be converted to named.
:type obj: object

:returns: A named instance of self.
"""

Expand All @@ -249,7 +290,10 @@ def recursive_translate(self, obj: object, translation_table: "dict[str, str]"):
translation table. If a match is found, substitute.

:param obj: The object that will be translated.
:type obj: object

:param translation_table: The mapping to translate by.
:type translation_table: TranslationTable
"""

# If a translation table exists on the object, remove and save it.
Expand Down
Loading