Resolve "Add AbstractPort" and "Change Port ID to Port Index"
5 unresolved threads
5 unresolved threads
- Changes the port module by introducing a fully abstract "Port" interface and then an "AbstractPort" abstract class that implements the Port interface, which is in line with the class diagram.
- Renames many functions such as "connect_port" to "connect" and "connect_signal" to "add_signal" for better useability and to fit with the class diagram.
- Moves "AbstractGraphComponent" to the graph_component module.
- Also renames functions such as "connect_source" to "set_source" in signal.
- Refactors Port ID to Port Index as in #49 (closed)
- Move AbstractOperation implementation to the operation module.
- Mode BFS implementation from the utilites module to the operation module to solve cyclic imports.
Closes #48 (closed) Closes #49 (closed)
Edited by Angus Lothian
Merge request reports
Activity
added Needs review label
mentioned in issue #48 (closed)
- Resolved by Jacob Wahlman
- Resolved by Jacob Wahlman
- Resolved by Jacob Wahlman
I am just wondering why we have a separate module for AbstractOperation and not AbstractPort, does it have to do with cyclic imports or is there any other reason to not separate AbstractPort like AbstractOperation? Generally I think it looks good, just make sure to run pylint and fix some issues.
added 1 commit
- 10976d00 - Solve pull request comments and change so evaluate function in SFG uses the...
added 1 commit
- 62b19475 - Move abstract operation to operation module and move utilties implementation...
assigned to @arvwe160
88 91 If no neighbours are found this returns an empty list 89 92 """ 90 93 raise NotImplementedError 94 95 96 class AbstractOperation(Operation, AbstractGraphComponent): 97 """Generic abstract operation class which most implementations will derive from. 98 TODO: More info. 102 _output_ports: List["OutputPort"] 103 _parameters: Dict[str, Optional[Any]] 104 105 def __init__(self, name: Name = ""): 106 super().__init__(name) 107 self._input_ports = [] 108 self._output_ports = [] 109 self._parameters = {} 110 111 @abstractmethod 112 def evaluate(self, *inputs) -> Any: # pylint: disable=arguments-differ 113 """Evaluate the operation and generate a list of output values given a 114 list of input values.""" 115 raise NotImplementedError 116 117 def inputs(self) -> List["InputPort"]: 134 135 def params(self) -> Dict[str, Optional[Any]]: 136 return self._parameters.copy() 137 138 def param(self, name: str) -> Optional[Any]: 139 return self._parameters.get(name) 140 141 def set_param(self, name: str, value: Any) -> None: 142 assert name in self._parameters # TODO: Error message. 143 self._parameters[name] = value 144 145 def evaluate_outputs(self, state: SimulationState) -> List[Number]: 146 # TODO: Check implementation. 147 input_count: int = self.input_count() 148 output_count: int = self.output_count() 149 assert input_count == len(self._input_ports) # TODO: Error message. 135 def params(self) -> Dict[str, Optional[Any]]: 136 return self._parameters.copy() 137 138 def param(self, name: str) -> Optional[Any]: 139 return self._parameters.get(name) 140 141 def set_param(self, name: str, value: Any) -> None: 142 assert name in self._parameters # TODO: Error message. 143 self._parameters[name] = value 144 145 def evaluate_outputs(self, state: SimulationState) -> List[Number]: 146 # TODO: Check implementation. 147 input_count: int = self.input_count() 148 output_count: int = self.output_count() 149 assert input_count == len(self._input_ports) # TODO: Error message. 150 assert output_count == len(self._output_ports) # TODO: Error message. mentioned in commit 7c6cbe75
mentioned in issue #49 (closed)
Please register or sign in to reply