diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bfdf23..95e8568 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,10 +17,10 @@ jobs: runs-on: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -30,7 +30,7 @@ jobs: python -m pip install pytest pytest-cov - name: Checkout NeuroML2 - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: NeuroML/NeuroML2 ref: development diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 8c21bb6..f97c3e4 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: nelonoel/branch-name@v1.0.1 # https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions @@ -21,7 +21,7 @@ jobs: id: extract_branch - name: Checkout jlems - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: LEMS/jLEMS ref: ${{ steps.extract_branch.outputs.branch }} diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 7d29880..734546a 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -18,9 +18,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies diff --git a/.readthedocs.yaml b/.readthedocs.yaml index ae78afd..87d3b7f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,10 @@ build: sphinx: configuration: doc/conf.py - python: install: - - requirements: doc/requirements.txt + - method: pip + path: . + extra_requirements: + - doc + diff --git a/doc/requirements.txt b/doc/requirements.txt deleted file mode 100644 index ef36add..0000000 --- a/doc/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -sphinxcontrib-bibtex diff --git a/lems/base/errors.py b/lems/base/errors.py index 50cc9f1..d7a7411 100644 --- a/lems/base/errors.py +++ b/lems/base/errors.py @@ -27,6 +27,7 @@ def __init__(self, message, *params, **key_params): self.message = None """ Error message + :type: string """ if params: diff --git a/lems/base/stack.py b/lems/base/stack.py index 95eb600..576d8f6 100644 --- a/lems/base/stack.py +++ b/lems/base/stack.py @@ -21,6 +21,7 @@ def __init__(self): self.stack = [] """ List used to store the stack contents. + :type: list """ def push(self, val): diff --git a/lems/model/component.py b/lems/model/component.py index 98858a4..1fbf735 100644 --- a/lems/model/component.py +++ b/lems/model/component.py @@ -30,30 +30,37 @@ def __init__(self, name, dimension, minval=None, maxval=None, description=""): self.name = name """ Name of the parameter. + :type: str """ self.dimension = dimension """ Physical dimension of the parameter. + :type: str """ self.fixed = False """ Whether the parameter has been fixed or not. + :type: bool """ self.fixed_value = None """ Value if fixed. + :type: str """ self.value = None """ Value of the parameter. + :type: str """ self.numeric_value = None """ Resolved numeric value. + :type: float """ self.description = description """ Description of this parameter. + :type: str """ self.minval = minval @@ -133,18 +140,22 @@ def __init__(self, name, dimension=None, default_value=None, description=""): self.name = name """ Name of the property. + :type: str """ self.dimension = dimension """ Physical dimensions of the property. + :type: str """ self.description = description """ Description of the property. + :type: str """ self.default_value = default_value """ Default value of the property. + :type: float """ def toxml(self): @@ -176,10 +187,12 @@ def __init__(self, name, description=""): self.name = name """ Name of the parameter. + :type: str """ self.description = description """ Description of this parameter. + :type: str """ def toxml(self): @@ -213,18 +226,22 @@ def __init__(self, name, value, dimension=None, description=""): self.name = name """ Name of the derived parameter. + :type: str """ self.dimension = dimension """ Physical dimensions of the derived parameter. + :type: str """ self.value = value """ Value of the derived parameter. + :type: str """ self.description = description """ Description of the derived parameter. + :type: str """ try: @@ -270,26 +287,32 @@ def __init__(self, name, value, dimension=None, symbol=None, description=""): self.name = name """ Name of the constant. + :type: str """ self.symbol = symbol """ Symbol of the constant. + :type: str """ self.value = value """ Value of the constant. + :type: str """ self.dimension = dimension """ Physical dimensions of the constant. + :type: str """ self.description = description """ Description of the constant. + :type: str """ self.numeric_value = None """ Numeric value of the constant. + :type: float """ def toxml(self): @@ -326,6 +349,7 @@ def __init__(self, name, dimension, minval=None, maxval=None, description=""): self.name = name """ Name of the exposure. + :type: str """ self.minval = minval @@ -338,10 +362,12 @@ def __init__(self, name, dimension, minval=None, maxval=None, description=""): self.dimension = dimension """ Physical dimension of the exposure. + :type: str """ self.description = description """ Description of this exposure. + :type: str """ def toxml(self): @@ -374,14 +400,17 @@ def __init__(self, name, dimension, description=""): self.name = name """ Name of the requirement. + :type: str """ self.dimension = dimension """ Physical dimension of the requirement. + :type: str """ self.description = description """ Description of this requirement. + :type: str """ def toxml(self): @@ -412,10 +441,12 @@ def __init__(self, name, description=""): self.name = name """ Name of the Component required. + :type: str """ self.description = description """ Description of this ComponentRequirement. + :type: str """ def toxml(self): @@ -447,14 +478,17 @@ def __init__(self, name, type, description=""): self.name = name """ Name of the instance requirement. + :type: str """ self.type = type """ Type of the instance required. + :type: str """ self.description = description """ Description of this InstanceRequirement. + :type: str """ def toxml(self): @@ -487,18 +521,22 @@ def __init__(self, name, type_, description="", multiple=False): self.name = name """ Name of the children. + :type: str """ self.type = type_ """ Component type of the children. + :type: str """ self.description = description """ Description of the children. + :type: str """ self.multiple = multiple """ Single child / multiple children. + :type: bool """ def toxml(self): @@ -528,14 +566,17 @@ def __init__(self, name, description=""): self.name = name """ Name of the text entry. + :type: str """ self.description = description """ Description of the text entry. + :type: str """ self.value = None """ Value of the text entry. + :type: str """ def toxml(self): @@ -582,18 +623,22 @@ def __init__(self, name, type_, description=""): self.name = name """ Name of the link entry. + :type: str """ self.type = type_ """ Type of the link. + :type: str """ self.description = description """ Description of the link. + :type: str """ self.value = None """ Value of the link. + :type: str """ def toxml(self): @@ -626,14 +671,17 @@ def __init__(self, name, description=""): self.name = name """ Name of the path entry. + :type: str """ self.description = description """ Description of the path entry. + :type: str """ self.value = None """ Value of the path entry. + :type: str """ def toxml(self): @@ -666,6 +714,7 @@ def __init__(self, name, direction, description=""): self.name = name """ Name of the event port. + :type: str """ d = direction.lower() @@ -676,10 +725,12 @@ def __init__(self, name, direction, description=""): self.direction = direction """ Direction - IN/OUT . + :type: str """ self.description = description """ Description of the event port. + :type: str """ def toxml(self): @@ -712,18 +763,22 @@ def __init__(self, name, type_, local=None): self.name = name """ Name of the component reference. + :type: str """ self.type = type_ """ Type of the component reference. + :type: str """ self.local = local """ ??? + :type: str """ self.referenced_component = None """ Component being referenced. + :type: FatComponent """ def toxml(self): @@ -752,14 +807,17 @@ def __init__(self, name, type_, description=""): self.name = name """ Name of the attachment collection. + :type: str """ self.type = type_ """ Type of attachment. + :type: str """ self.description = description """ Description about the attachment. + :type: str """ def toxml(self): @@ -792,82 +850,102 @@ def __init__(self): self.parameters = Map() """ Map of parameters in this component type. - :type: Map(str -> lems.model.component.Parameter) """ + + :type: Map(str, lems.model.component.Parameter) """ self.properties = Map() """ Map of properties in this component type. - :type: Map(str -> lems.model.component.Property) """ + + :type: Map(str, lems.model.component.Property) """ self.derived_parameters = Map() """ Map of derived_parameters in this component type. - :type: Map(str -> lems.model.component.Parameter) """ + + :type: Map(str, lems.model.component.Parameter) """ self.index_parameters = Map() """ Map of index_parameters in this component type. - :type: Map(str -> lems.model.component.IndexParameter) """ + + :type: Map(str, lems.model.component.IndexParameter) """ self.constants = Map() """ Map of constants in this component type. - :type: Map(str -> lems.model.component.Constant) """ + + :type: Map(str, lems.model.component.Constant) """ self.exposures = Map() """ Map of exposures in this component type. - :type: Map(str -> lems.model.component.Exposure) """ + + :type: Map(str, lems.model.component.Exposure) """ self.requirements = Map() """ Map of requirements. - :type: Map(str -> lems.model.component.Requirement) """ + + :type: Map(str, lems.model.component.Requirement) """ self.component_requirements = Map() """ Map of component requirements. - :type: Map(str -> lems.model.component.ComponentRequirement) """ + + :type: Map(str, lems.model.component.ComponentRequirement) """ self.instance_requirements = Map() """ Map of instance requirements. - :type: Map(str -> lems.model.component.InstanceRequirement) """ + + :type: Map(str, lems.model.component.InstanceRequirement) """ self.children = Map() """ Map of children. - :type: Map(str -> lems.model.component.Children) """ + + :type: Map(str, lems.model.component.Children) """ self.texts = Map() """ Map of text entries. - :type: Map(str -> lems.model.component.Text) """ + + :type: Map(str, lems.model.component.Text) """ self.links = Map() """ Map of links. - :type: Map(str -> lems.model.component.Link) """ + + :type: Map(str, lems.model.component.Link) """ self.paths = Map() """ Map of path entries. - :type: Map(str -> lems.model.component.Path) """ + + :type: Map(str, lems.model.component.Path) """ self.event_ports = Map() """ Map of event ports. - :type: Map(str -> lems.model.component.EventPort """ + + :type: Map(str, lems.model.component.EventPort """ self.component_references = Map() """ Map of component references. - :type: Map(str -> lems.model.component.ComponentReference) """ + + :type: Map(str, lems.model.component.ComponentReference) """ self.attachments = Map() """ Map of attachment type specifications. - :type: Map(str -> lems.model.component.Attachments) """ + + :type: Map(str, lems.model.component.Attachments) """ self.dynamics = Dynamics() """ Behavioural dynamics object. + :type: lems.model.dynamics.Dynamics """ self.structure = Structure() """ Structural properties object. + :type: lems.model.structure.Structure """ self.simulation = Simulation() """ Simulation attributes. + :type: lems.model.simulation.Simulation """ self.types = set() """ Set of compatible component types. + :type: set(str) """ def add_parameter(self, parameter): @@ -1089,14 +1167,17 @@ def __init__(self, name, description="", extends=None): self.name = name """ Name of the component type. + :type: str """ self.extends = extends """ Base component type. + :type: str """ self.description = description """ Description of this component type. + :type: str """ self.types.add(name) @@ -1204,24 +1285,30 @@ def __init__(self, id_, type_, **params): self.id = id_ """ ID of the component. + :type: str """ self.type = type_ """ Type of the component. + :type: str """ self.parameters = dict() """ Dictionary of parameter values. + :type: str """ + for key in params.keys(): self.parameters[key] = params[key] self.children = list() """ List of child components. + :type: list(lems.model.component.Component) """ self.parent_id = None """ Optional id of parent + :type: str """ def __str__(self): @@ -1314,18 +1401,22 @@ def __init__(self, id_, type_): self.id = id_ """ ID of the component. + :type: str """ self.type = type_ """ Type of the component. + :type: str """ self.child_components = list() """ List of child components. + :type: lems.model.component.FatComponent """ self.parent_id = None """ Optional id of parent + :type: str """ def __str__(self): diff --git a/lems/model/dynamics.py b/lems/model/dynamics.py index e74d3df..8a613fe 100644 --- a/lems/model/dynamics.py +++ b/lems/model/dynamics.py @@ -25,6 +25,7 @@ def __init__(self, name, dimension, minval=None, maxval=None, exposure=None): self.name = name """ Name of the state variable. + :type: str """ self.minval = minval @@ -37,10 +38,12 @@ def __init__(self, name, dimension, minval=None, maxval=None, exposure=None): self.dimension = dimension """ Dimension of the state variable. + :type: str """ self.exposure = exposure """ Exposure name for the state variable. + :type: str """ def __str__(self): @@ -76,34 +79,42 @@ def __init__(self, name, **params): self.name = name """ Name of the derived variable. + :type: str """ self.dimension = params["dimension"] if "dimension" in params else None """ Dimension of the derived variable or None if computed. + :type: str """ self.exposure = params["exposure"] if "exposure" in params else None """ Exposure name for the derived variable. + :type: str """ self.select = params["select"] if "select" in params else None """ Selection path/expression for the derived variable. + :type: str """ self.value = params["value"] if "value" in params else None """ Value of the derived variable. + :type: str """ self.reduce = params["reduce"] if "reduce" in params else None """ Reduce method for the derived variable. + :type: str """ self.required = params["required"] if "required" in params else None """ Requried or not. + :type: str """ self.expression_tree = None """ Parse tree for the time derivative expression. + :type: lems.parser.expr.ExprNode """ if self.value != None: @@ -146,18 +157,22 @@ def __init__(self, condition, value): self.condition = condition """ Condition for this case. + :type: str """ self.value = value """ Value if the condition is true. + :type: str """ self.condition_expression_tree = None """ Parse tree for the case condition expression. + :type: lems.parser.expr.ExprNode """ self.value_expression_tree = None """ Parse tree for the case condition expression. + :type: lems.parser.expr.ExprNode """ try: @@ -199,18 +214,22 @@ def __init__(self, name, dimension, exposure=None): self.name = name """ Name of the derived variable. + :type: str """ self.dimension = dimension """ Dimension of the state variable. + :type: str """ self.exposure = exposure """ Exposure name for the state variable. + :type: str """ self.cases = list() """ List of cases related to this conditional derived variable. + :type: list(lems.model.dynamics.Case) """ def add_case(self, case): @@ -273,14 +292,17 @@ def __init__(self, variable, value): self.variable = variable """ Name of the variable for which the time derivative is being specified. + :type: str """ self.value = value """ Derivative expression. + :type: str """ self.expression_tree = None """ Parse tree for the time derivative expression. + :type: lems.parser.expr.ExprNode """ try: @@ -327,14 +349,17 @@ def __init__(self, variable, value): self.variable = variable """ Name of the variable for which the time derivative is being specified. + :type: str """ self.value = value """ Derivative expression. + :type: str """ self.expression_tree = None """ Parse tree for the time derivative expression. + :type: lems.parser.expr.ExprNode """ try: @@ -374,6 +399,7 @@ def __init__(self, port): self.port = port """ Port on which the event comes in. + :type: str """ def toxml(self): @@ -400,6 +426,7 @@ def __init__(self, regime): self.regime = regime """ Regime to transition to. + :type: str """ def toxml(self): @@ -422,6 +449,7 @@ def __init__(self): self.actions = list() """ List of actions to be performed in response to this event. + :type: list(lems.model.dynamics.Action) """ def __str__(self): @@ -506,6 +534,7 @@ def __init__(self, test): self.test = test """ Condition to be tested for. + :type: str """ try: @@ -553,6 +582,7 @@ def __init__(self, port): self.port = port """ Port on which the event comes in. + :type: str """ def __str__(self): @@ -635,34 +665,42 @@ def __init__( self.name = name """ Name of the kinetic scheme. + :type: str """ self.nodes = nodes """ Nodes to be used for the kinetic scheme. + :type: str """ self.state_variable = state_variable """ State variable updated by the kinetic scheme. + :type: str """ self.edges = edges """ Edges to be used for the kinetic scheme. + :type: str """ self.edge_source = edge_source """ Attribute that defines the source of the transition. + :type: str """ self.edge_target = edge_target """ Attribute that defines the target of the transition. + :type: str """ self.forward_rate = forward_rate """ Name of the forward rate exposure. + :type: str """ self.reverse_rate = reverse_rate """ Name of the reverse rate exposure. + :type: str """ def toxml(self): @@ -706,31 +744,38 @@ def __init__(self): self.parent_behavioral = None """ Parent behavioral object. + :type: lems.model.dynamics.Behavioral """ self.state_variables = Map() """ Map of state variables in this behavior regime. - :type: dict(str -> lems.model.dynamics.StateVariable """ + + :type: dict(str, lems.model.dynamics.StateVariable """ self.derived_variables = Map() """ Map of derived variables in this behavior regime. - :type: dict(str -> lems.model.dynamics.DerivedVariable """ + + :type: dict(str, lems.model.dynamics.DerivedVariable """ self.conditional_derived_variables = Map() """ Map of conditional derived variables in this behavior regime. - :type: dict(str -> lems.model.dynamics.ConditionalDerivedVariable """ + + :type: dict(str, lems.model.dynamics.ConditionalDerivedVariable """ self.time_derivatives = Map() """ Map of time derivatives in this behavior regime. - :type: dict(str -> lems.model.dynamics.TimeDerivative) """ + + :type: dict(str, lems.model.dynamics.TimeDerivative) """ self.event_handlers = list() """ List of event handlers in this behavior regime. + :type: list(lems.model.dynamics.EventHandler) """ self.kinetic_schemes = Map() """ Map of kinetic schemes in this behavior regime. - :type: dict(str -> lems.model.dynamics.KineticScheme) """ + + :type: dict(str, lems.model.dynamics.KineticScheme) """ def has_content(self): if ( @@ -898,14 +943,17 @@ def __init__(self, name, parent_behavioral, initial=False): self.name = name """ Name of this behavior regime. + :type: str """ self.parent_behavioral = parent_behavioral """ Parent behavioral object. + :type: lems.model.dynamics.Behavioral """ self.initial = initial """ Initial behavior regime. + :type: bool """ @@ -923,7 +971,8 @@ def __init__(self): self.regimes = Map() """ Map of behavior regimes. - :type: Map(str -> lems.model.dynamics.Regime) """ + + :type: Map(str, lems.model.dynamics.Regime) """ def add_regime(self, regime): """ diff --git a/lems/model/fundamental.py b/lems/model/fundamental.py index c36362d..2792405 100644 --- a/lems/model/fundamental.py +++ b/lems/model/fundamental.py @@ -24,6 +24,7 @@ def __init__(self, filename): self.file = filename """ Name of the file. + :type: str """ def toxml(self): @@ -53,38 +54,47 @@ def __init__(self, name, description="", **params): self.name = name """ Name of the dimension. + :type: str """ self.m = params["m"] if "m" in params else 0 """ Power for the mass dimension. + :type: int """ self.l = params["l"] if "l" in params else 0 """ Power for the length dimension. + :type: int """ self.t = params["t"] if "t" in params else 0 """ Power for the time dimension. + :type: int """ self.i = params["i"] if "i" in params else 0 """ Power for the electic current dimension. + :type: int """ self.k = params["k"] if "k" in params else 0 """ Power for the temperature dimension. + :type: int """ self.n = params["n"] if "n" in params else 0 """ Power for the quantity dimension. + :type: int """ self.j = params["j"] if "j" in params else 0 """ Power for the luminous intensity dimension. + :type: int """ self.description = description """ Description of this dimension. + :type: str """ def toxml(self): @@ -121,30 +131,37 @@ def __init__( self.name = name """ Name of the unit. + :type: str """ self.symbol = symbol """ Symbol for the unit. + :type: str """ self.dimension = dimension """ Dimension for the unit. + :type: str """ self.power = power """ Scaling by power of 10. + :type: int """ self.scale = scale """ Scaling. + :type: float """ self.offset = offset """ Offset for non-zero units. + :type: float """ self.description = description """ Description of this unit. + :type: str """ def toxml(self): diff --git a/lems/model/model.py b/lems/model/model.py index cbe2d74..b080413 100644 --- a/lems/model/model.py +++ b/lems/model/model.py @@ -71,58 +71,72 @@ def __init__(self, include_includes=True, fail_on_missing_includes=True): self.targets = list() """ List of targets to be run on startup. + :type: list(str) """ self.includes = Map() """ Dictionary of includes defined in the model. - :type: dict(str -> lems.model.fundamental.Include """ + + :type: dict(str, lems.model.fundamental.Include """ self.dimensions = Map() """ Dictionary of dimensions defined in the model. - :type: dict(str -> lems.model.fundamental.Dimension """ + + :type: dict(str, lems.model.fundamental.Dimension """ self.units = Map() """ Map of units defined in the model. - :type: dict(str -> lems.model.fundamental.Unit """ + + :type: dict(str, lems.model.fundamental.Unit """ self.component_types = Map() """ Map of component types defined in the model. - :type: dict(str -> lems.model.component.ComponentType) """ + + :type: dict(str, lems.model.component.ComponentType) """ self.components = Map() """ Map of root components defined in the model. - :type: dict(str -> lems.model.component.Component) """ + + :type: dict(str, lems.model.component.Component) """ self.fat_components = Map() """ Map of root fattened components defined in the model. - :type: dict(str -> lems.model.component.FatComponent) """ + + :type: dict(str, lems.model.component.FatComponent) """ self.constants = Map() """ Map of constants in this component type. - :type: dict(str -> lems.model.component.Constant) """ + + :type: dict(str, lems.model.component.Constant) """ self.include_directories = [] """ List of include directories to search for included LEMS files. + :type: list(str) """ self.included_files = [] """ List of files already included. + :type: list(str) """ self.description = None """ Short description of contents of LEMS file + :type: str """ self.include_includes = include_includes """ Whether to include LEMS definitions in elements + :type: boolean """ self.fail_on_missing_includes = fail_on_missing_includes """ Whether to raise an Exception when a file in an element is not found + :type: boolean """ self.resolved_model = None """ A resolved version of the model, generated by self.resolve() + :type: None or Model""" self.comp_ref_map = None @@ -376,10 +390,10 @@ def export_to_file(self, filepath, level_prefix=" "): "\n", ) - f = open(filepath, "w") - f.write(xmlstr) - f.flush() - os.fsync(f.fileno()) + with open(filepath, "w") as f: + f.write(xmlstr) + f.flush() + os.fsync(f.fileno()) def resolve(self) -> lems.model.Model: @@ -1118,9 +1132,13 @@ def list_exposures(self, substring: str = "") -> dict[FatComponent, Map]: :returns: dictionary of components and their exposures The returned dictionary is of the form: - { - "component": ["exp1", "exp2"] - } + + + .. code-block:: python + + { + "component": ["exp1", "exp2"] + } """ exposures = {} diff --git a/lems/model/simulation.py b/lems/model/simulation.py index eece19f..78bbc6e 100644 --- a/lems/model/simulation.py +++ b/lems/model/simulation.py @@ -26,19 +26,23 @@ def __init__(self, component, variable, increment, total): self.component = component """ Name of the target component to be run according to the specification given for an independent state variable. + :type: str """ self.variable = variable """ The name of an independent state variable according to which the target component will be run. + :type: str """ self.increment = increment """ Increment of the state variable on each step. + :type: str """ self.total = total """ Final value of the state variable. + :type: str """ def toxml(self): @@ -67,22 +71,27 @@ def __init__(self, quantity, scale=None, color=None, id=None): self.id = "" """ Id of the quantity + :type: str """ self.quantity = quantity """ Path to the quantity to be recorded. + :type: str """ self.scale = scale """ Text parameter to be used for scaling the quantity before display. + :type: str """ self.color = color """ Text parameter to be used to specify the color for display. + :type: str """ self.id = id """ Text parameter to be used to specify an id for the record + :type: str """ def toxml(self): @@ -109,14 +118,17 @@ def __init__(self, quantity, eventPort): self.id = "" """ Id of the quantity + :type: str """ self.quantity = quantity """ Path to the quantity to be recorded. + :type: str """ self.eventPort = eventPort """ eventPort to be used for the event record + :type: str """ def toxml(self): @@ -158,14 +170,17 @@ def __init__(self, title, data_region): self.title = title """ Title for the display. + :type: string """ self.data_region = data_region """ Display position + :type: string """ self.time_scale = 1 """ Time scale + :type: Number """ def toxml(self): @@ -194,10 +209,12 @@ def __init__(self, path, file_name): self.path = path """ Path to the quantity to be saved to file. + :type: string """ self.file_name = file_name """ Text parameter to be used for the file name + :type: string """ def toxml(self): @@ -229,14 +246,17 @@ def __init__(self, path, file_name, format): self.path = path """ Path to the quantity to be saved to file. + :type: string """ self.file_name = file_name """ Text parameter to be used for the file name + :type: string """ self.format = format """ Text parameter to be used for the format + :type: string """ def toxml(self): @@ -266,27 +286,33 @@ def __init__(self): self.runs = Map() """ Map of runs in this dynamics regime. - :type: Map(string -> lems.model.simulation.Run) """ + + :type: Map(string, lems.model.simulation.Run) """ self.records = Map() """ Map of recorded variables in this dynamics regime. - :type: Map(string -> lems.model.simulation.Record """ + + :type: Map(string, lems.model.simulation.Record """ self.event_records = Map() """ Map of recorded events in this dynamics regime. - :type: Map(string -> lems.model.simulation.EventRecord """ + + :type: Map(string, lems.model.simulation.EventRecord """ self.data_displays = Map() """ Map of data displays mapping titles to regions. - :type: Map(string -> string) """ + + :type: Map(string, string) """ self.data_writers = Map() """ Map of recorded variables to data writers. - :type: Map(string -> lems.model.simulation.DataWriter """ + + :type: Map(string, lems.model.simulation.DataWriter """ self.event_writers = Map() """ Map of recorded variables to event writers. - :type: Map(string -> lems.model.simulation.EventWriter """ + + :type: Map(string, lems.model.simulation.EventWriter """ def add_run(self, run): """ diff --git a/lems/model/structure.py b/lems/model/structure.py index 0d3a51a..c3e5295 100644 --- a/lems/model/structure.py +++ b/lems/model/structure.py @@ -23,18 +23,22 @@ def __init__(self, instance, as_, list=None, index=None): self.instance = instance """ Instance to be referenced. + :type: str """ self.as_ = as_ """ Alternative name. + :type: str """ self.list = list """ list of components, e.g. population + :type: str """ self.index = index """ index in list to be referenced. + :type: str """ def toxml(self): @@ -64,22 +68,27 @@ def __init__(self, name, end_a, end_b, component_a, component_b): self.name = name """ name of Tunnel. + :type: str """ self.end_a = end_a """ 'A' end of Tunnel. + :type: str """ self.end_b = end_b """ 'B' end of Tunnel. + :type: str """ self.component_a = component_a """ Component to create at A. + :type: str """ self.component_b = component_b """ Component to create at B. + :type: str """ def toxml(self): @@ -113,26 +122,32 @@ def __init__( self.from_ = from_ """ Name of the source component for event. + :type: str """ self.to = to """ Name of the target component for the event. + :type: str """ self.source_port = source_port """ Source port name. + :type: str """ self.target_port = target_port """ Target port name. + :type: str """ self.receiver = receiver """ Proxy receiver component attached to the target component that actually receiving the event. + :type: Component """ self.receiver_container = receiver_container """ Name of the child component grouping to add the receiver to. + :type: str """ def __eq__(self, o): @@ -178,10 +193,12 @@ def __init__(self, component, referenced_component=None): self.component = component """ Name of the component reference to be used for instantiation. + :type: str """ self.referenced_component = referenced_component """ Target component being referenced after resolution. + :type: lems.model.component.FatComponent """ def __eq__(self, o): @@ -209,10 +226,12 @@ def __init__(self, property, value): self.property_ = property """ Name of the property reference to be used for instantiation. + :type: str """ self.value = value """ Value of the property. + :type: str""" def __eq__(self, o): @@ -245,19 +264,23 @@ def __init__(self, component=None, number=None, component_type=None): self.component = component """ Name of the component reference to be used for instantiation. + :type: str """ self.component_type = component_type """ Name of the component type reference to be used for instantiation. + :type: str """ self.number = number """ Name of the paramter specifying the number of times the component reference is to be instantiated. + :type: str""" self.assignments = [] """ List of assignments included in MultiInstantiate. + :type: list(Assign) """ def __eq__(self, o): @@ -322,10 +345,12 @@ def __init__(self, instances, as_): self.event_connections = list() """ List of event connections. + :type: list(lems.model.structure.EventConnection) """ self.for_eachs = list() """ List of for each specs. + :type: list(lems.model.structure.ForEach) """ def add_for_each(self, fe): @@ -377,26 +402,32 @@ def __init__(self): self.withs = Map() """ Map of With statements. - :type: Map(str -> lems.model.structure.With) """ + + :type: Map(str, lems.model.structure.With) """ self.tunnels = Map() """ Map of tunnel statements. - :type: Map(str -> lems.model.structure.Tunnel) """ + + :type: Map(str, lems.model.structure.Tunnel) """ self.event_connections = list() """ List of event connections. + :type: list(lems.model.structure.EventConnection) """ self.child_instances = list() """ List of child instantations. + :type: list(lems.model.structure.ChildInstance) """ self.multi_instantiates = list() """ List of child multi-instantiations. + :type: list(lems.model.structure.MultiInstantiate) """ self.for_eachs = list() """ List of for each specs. + :type: list(lems.model.structure.ForEach) """ def has_content(self): diff --git a/lems/parser/LEMS.py b/lems/parser/LEMS.py index 79d8400..022c73a 100644 --- a/lems/parser/LEMS.py +++ b/lems/parser/LEMS.py @@ -72,26 +72,32 @@ def __init__(self, model, include_dirs=[], include_includes=True): self.model = model """ Model instance to be populated from the parsed file. + :type: lems.model.model.Model """ self.include_dirs = include_dirs """ List of directories to search for included files. + :type: list(str) """ self.tag_parse_table = None """ Dictionary of xml tags to parse methods - :type: dict(string -> function) """ + + :type: dict(string, function) """ self.valid_children = None """ Dictionary mapping each tag to it's list of valid child tags. - :type: dict(string -> string) """ + + :type: dict(string, string) """ self.id_counter = None """ Counter generator for generating unique ids. + :type: generator(int) """ self.include_includes = include_includes """ Whether to include LEMS definitions in elements + :type: boolean """ self.init_parser() diff --git a/lems/parser/expr.py b/lems/parser/expr.py index ee9cebf..2442377 100644 --- a/lems/parser/expr.py +++ b/lems/parser/expr.py @@ -45,6 +45,7 @@ def __init__(self, type): self.type = type """ Node type. + :type: enum(ExprNode.OP, ExprNode.VALUE) """ @@ -64,6 +65,7 @@ def __init__(self, value): ExprNode.__init__(self, ExprNode.VALUE) self.value = value """ Value to be stored in this node. + :type: string """ def clean_up(self): @@ -112,14 +114,17 @@ def __init__(self, op, left, right): self.op = op """ Operation stored in this node. + :type: string """ self.left = left """ Left operand. + :type: lems.parser.expr.ExprNode """ self.right = right """ Right operand. + :type: lems.parser.expr.ExprNode """ def __str__(self): @@ -159,10 +164,12 @@ def __init__(self, func, param): self.func = func """ Funcion stored in this node. + :type: string """ self.param = param """ Parameter. + :type: lems.parser.expr.ExprNode """ def __str__(self): @@ -211,7 +218,8 @@ class ExprParser(LEMSBase): depth = 0 """ Dictionary mapping operators to their priorities. - :type: dict(string -> Integer) """ + + :type: dict(string, Integer) """ def __init__(self, parse_string): """ @@ -223,10 +231,12 @@ def __init__(self, parse_string): self.parse_string = parse_string """ Expression to be parsed. + :type: string """ self.token_list = None """ List of tokens from the expression to be parsed. + :type: list(string) """ def is_op(self, str): diff --git a/lems/sim/build.py b/lems/sim/build.py index 04ab3c6..d6d2304 100644 --- a/lems/sim/build.py +++ b/lems/sim/build.py @@ -33,10 +33,12 @@ def __init__(self, model): self.model = model """ Model to be used for constructing the simulation. + :type: lems.model.model.Model """ self.sim = None """ Simulation built from the model. + :type: lems.sim.sim.Simulation """ self.current_record_target = None diff --git a/lems/sim/sim.py b/lems/sim/sim.py index ac50f23..e3e3a22 100644 --- a/lems/sim/sim.py +++ b/lems/sim/sim.py @@ -25,14 +25,17 @@ def __init__(self): self.runnables = {} """ Dictionary of runnable components in this simulation. - :type: dict(string -> lems.sim.runnable.Runnable) """ + + :type: dict(string, lems.sim.runnable.Runnable) """ self.run_queue = [] """ Priority of pairs of (time-to-next run, runnable). + :type: list((Integer, lems.sim.runnable.Runnable)) """ self.event_queue = [] """ List of posted events. + :type: list(lems.sim.sim.Event) """ def add_runnable(self, runnable): @@ -159,8 +162,10 @@ class Event: def __init__(self, from_id, to_id): self.from_id = from_id """ ID of the source runnable for this event. + :type: Integer """ self.to_id = to_id """ ID of the destination runnable for this event. + :type: Integer """ diff --git a/setup.cfg b/setup.cfg index 6806b45..9cace79 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = PyLEMS -version = 0.6.6 +version = 0.6.7 author = PyLEMS authors and contributors author_email = gautham@lisphacker.org, p.gleeson@gmail.com maintainer_email = p.gleeson@gmail.com @@ -37,6 +37,10 @@ console_scripts = pylems = lems.run:main +[options.extras_require] +doc = + sphinxcontrib-bibtex + [flake8] # ignore: # spacing around operators, comment blocks, in argument lists