Skip to content

Commit

Permalink
updated docstrings, typehints, gitignore, & readme
Browse files Browse the repository at this point in the history
  • Loading branch information
capsulecorplab committed Jan 21, 2019
1 parent fbfd43a commit cf2fbd2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

# vscode
.vscode/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

- `sysml/system.py` - module for creating a `Model` object, which serves as a central namespace for model elements (and relationships between elements).

- `sysml/element.py` - module for creating model elements (s.a., `Package`, `Block`, `ConstraintBlock`, `Activity`, `Interaction`, `StateMachine`, `Requirement`). These objects are intended to be subsumed by a `Model` object.
- `sysml/elements/` - modules for creating model elements, divided into 4 pillars: structure, behavior, requirements, and parametrics. These objects are intended to be subsumed by a `Model` object.

## Developer Notes

Expand Down
18 changes: 7 additions & 11 deletions sysml/elements/behavior.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"""
The `element.py` module contains all model elements that are valid for use by
the `model` class
---------
Model elements are the building blocks that make up SysML
Behavior of a system, in collaboration with its actors, can be described
by use cases, activities, interactions, and/or state machines.
"""

from sysml.elements.base import ModelElement
Expand All @@ -17,7 +13,7 @@
class StateMachine(ModelElement):
"""This class defines a state"""

def __init__(self):
def __init__(self, name: Optional[str] = ""):
super().__init__(name)

@property
Expand All @@ -28,7 +24,7 @@ def name(self):
class Activity(ModelElement):
"""This class defines a activity"""

def __init__(self):
def __init__(self, name: Optional[str] = ""):
super().__init__(name)

@property
Expand All @@ -41,9 +37,9 @@ class Interaction(ModelElement):

def __init__(
self,
name: Optional[str],
lifelines: Optional[List["Block"]],
messages: Optional["ModelElement"],
name: Optional[str] = "",
lifelines: Optional[List["Block"]] = None,
messages: Optional["ModelElement"] = None,
):
super().__init__(name)

Expand Down
6 changes: 2 additions & 4 deletions sysml/elements/parametrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ class ValueType(ModelElement):
<ValueType(39.138799173399406, 'light_year')>
"""

def __init__(self, units: Optional["ModelElement"]):
# TODO: Needs to be redesigned to inherit methods of a UnitRegistry
# object while also inheriting from ModelElement
def __init__(self, units: Optional[str] = ""):

super().__init__(self.name)

Expand All @@ -52,5 +50,5 @@ def name(self):
class ConstraintBlock(ModelElement):
"""This class defines a constraint"""

def __init__(self, name: str = ""):
def __init__(self, name: Optional[str] = ""):
super().__init__(name)
12 changes: 5 additions & 7 deletions sysml/elements/requirements.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"""
The `element.py` module contains all model elements that are valid for use by
the `model` class
---------
Model elements are the building blocks that make up SysML
Requirements display text-based requirements (and the requirements
specifications that contain them)
"""

from sysml.elements.base import ModelElement
Expand All @@ -14,7 +10,9 @@
class Requirement(ModelElement):
"""This class defines a requirement"""

def __init__(self, name="", txt="", id=""):
def __init__(
self, name: Optional[str] = "", txt: Optional[str] = "", id: Optional[str] = ""
):
super().__init__(name)

if type(txt) is str:
Expand Down
10 changes: 3 additions & 7 deletions sysml/elements/structure.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
"""
The `element.py` module contains all model elements that are valid for use by
the `model` class
---------
Model elements are the building blocks that make up SysML
Structural elements are commonly used to describe system hierarchies,
classifications, internal composition, or interfaces.
"""

from sysml.elements.base import *
from sysml.elements.parametrics import *
from sysml.elements.requirements import *
from sysml.elements.parametrics import *
from collections import OrderedDict as _OrderedDict
from typing import Dict, List, Optional, Union

Expand Down

0 comments on commit cf2fbd2

Please sign in to comment.