• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SPF-OST / pytrnsys_gui / 11662562960

29 Oct 2024 03:09PM UTC coverage: 67.508% (-0.08%) from 67.591%
11662562960

push

github

web-flow
Merge pull request #564 from SPF-OST/560-black-change-line-length-to-pep8-standard-of-79-and-check-ci-reaction

changed line length in black to 79

1054 of 1475 new or added lines in 174 files covered. (71.46%)

150 existing lines in 74 files now uncovered.

10399 of 15404 relevant lines covered (67.51%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.14
/trnsysGUI/massFlowSolver/networkModel.py
1
__all__ = [
1✔
2
    "NodeType",
3
    "PortItem",
4
    "OneNeighbourBase",
5
    "TerminalWithPrescribedFlow",
6
    "TerminalWithFreeFlow",
7
    "TwoNeighboursBase",
8
    "Pipe",
9
    "Pump",
10
    "ThreeNeighboursBase",
11
    "TeePiece",
12
    "Diverter",
13
]
14

15
import abc as _abc
1✔
16
import dataclasses as _dc
1✔
17
import enum as _enum
1✔
18
import typing as _tp
1✔
19

20

21
class NodeType(_enum.IntEnum):
1✔
22
    PIPE = 0
1✔
23
    PUMP = 8
1✔
24
    TEE_PIECE = 2
1✔
25
    DIVERTER = 3
1✔
26
    TERMINAL_WITH_PRESCRIBED_FLOW = 4
1✔
27
    TERMINAL_WITH_FREE_FLOW = 5
1✔
28
    TERMINAL_WITH_PRESCRIBED_POS_FLOW = 6
1✔
29
    TERMINAL_WITH_PRESCRIBED_NEG_FLOW = 7
1✔
30

31

32
@_dc.dataclass(eq=False)
1✔
33
class InputVariable:
1✔
34
    UNDEFINED_INPUT_VARIABLE_VALUE = "0,0"
1✔
35
    name: str
1✔
36

37

38
@_dc.dataclass(eq=False)
1✔
39
class OutputVariable:
1✔
40
    name: str
1✔
41

42

43
OutputVariableIndex = _tp.Literal[1, 2, 3]
1✔
44

45
MAX_N_OUTPUT_VARIABLES_PER_NODE = 3
1✔
46

47
OutputVariables = _tp.Tuple[
1✔
48
    _tp.Optional[OutputVariable],
49
    _tp.Optional[OutputVariable],
50
    _tp.Optional[OutputVariable],
51
]
52

53

54
class PortItemDirection(_enum.Enum):
1✔
55
    INPUT = "Input"
1✔
56
    OUTPUT = "Output"
1✔
57

58

59
class PortItemType(_enum.Enum):
1✔
60
    STANDARD = "standard"
1✔
61
    HOT = "hot"
1✔
62
    COLD = "cold"
1✔
63

64
    def isCompatibleWith(self, otherType) -> bool:
1✔
65
        return self in (self.STANDARD, otherType)
1✔
66

67

68
@_dc.dataclass(eq=False, repr=False)
1✔
69
class PortItem:
1✔
70
    name: str
1✔
71
    direction: PortItemDirection
1✔
72
    type: PortItemType = PortItemType.STANDARD
1✔
73

74
    def canOverlapWith(self, other: "PortItem") -> bool:
1✔
75
        """Can this model port item overlap with `other` under a graphical port item?"""
76
        return self.type.isCompatibleWith(other.type)
1✔
77

78

79
class Node(_abc.ABC):
1✔
80
    def __init__(self, name: _tp.Optional[str]) -> None:
1✔
81
        self.name = name
1✔
82

83
    @_abc.abstractmethod
84
    def getPortItems(self) -> _tp.Sequence["PortItem"]:
85
        raise NotImplementedError()
86

87
    @_abc.abstractmethod
88
    def getNodeType(self) -> NodeType:
89
        raise NotImplementedError()
90

91
    def hasInput(self) -> bool:
1✔
92
        return False
1✔
93

94
    def getInputVariablePrefix(self) -> str:
1✔
NEW
95
        raise ValueError(
×
96
            f"`{type(self).__name__}` doesn't have an input variable prefix."
97
        )
98

99

100
class OneNeighbourBase(Node, _abc.ABC):
1✔
101
    def __init__(
1✔
102
        self, portItem: PortItem, name: _tp.Optional[str] = None
103
    ) -> None:
104
        super().__init__(name)
1✔
105
        self.portItem = portItem
1✔
106

107
    def getPortItems(self) -> _tp.Sequence[PortItem]:
1✔
108
        return [self.portItem]
1✔
109

110

111
class TerminalWithPrescribedFlowBase(OneNeighbourBase, _abc.ABC):
1✔
112
    def hasInput(self) -> bool:
1✔
113
        return True
1✔
114

115
    def getInputVariablePrefix(self) -> str:
1✔
116
        return "Mfr"
1✔
117

118

119
class TerminalWithPrescribedFlow(TerminalWithPrescribedFlowBase):
1✔
120
    def getNodeType(self) -> NodeType:
1✔
121
        return NodeType.TERMINAL_WITH_PRESCRIBED_FLOW
×
122

123

124
class TerminalWithPrescribedPosFlow(TerminalWithPrescribedFlowBase):
1✔
125
    def getNodeType(self) -> NodeType:
1✔
126
        return NodeType.TERMINAL_WITH_PRESCRIBED_POS_FLOW
1✔
127

128

129
class TerminalWithPrescribedNegFlow(TerminalWithPrescribedFlowBase):
1✔
130
    def getNodeType(self) -> NodeType:
1✔
131
        return NodeType.TERMINAL_WITH_PRESCRIBED_NEG_FLOW
1✔
132

133

134
class TerminalWithFreeFlow(OneNeighbourBase):
1✔
135
    def getNodeType(self) -> NodeType:
1✔
136
        return NodeType.TERMINAL_WITH_FREE_FLOW
×
137

138

139
class TwoNeighboursBase(Node, _abc.ABC):
1✔
140
    def __init__(
1✔
141
        self,
142
        fromPort: PortItem,
143
        toPort: PortItem,
144
        name: _tp.Optional[str] = None,
145
    ) -> None:
146
        super().__init__(name)
1✔
147
        self.fromPort = fromPort
1✔
148
        self.toPort = toPort
1✔
149

150
    def getPortItems(self) -> _tp.Sequence[PortItem]:
1✔
151
        return [self.fromPort, self.toPort]
1✔
152

153

154
class Pipe(TwoNeighboursBase):
1✔
155
    def getNodeType(self) -> NodeType:
1✔
156
        return NodeType.PIPE
1✔
157

158

159
class Pump(TwoNeighboursBase):
1✔
160
    def getNodeType(self) -> NodeType:
1✔
161
        return NodeType.PUMP
1✔
162

163
    def hasInput(self) -> bool:
1✔
164
        return True
1✔
165

166
    def getInputVariablePrefix(self) -> str:
1✔
167
        return "Mfr"
1✔
168

169

170
class ThreeNeighboursBase(Node, _abc.ABC):
1✔
171
    def __init__(
1✔
172
        self,
173
        inputPort: PortItem,
174
        output1Port: PortItem,
175
        output2Port: PortItem,
176
        name: _tp.Optional[str] = None,
177
    ) -> None:
178
        super().__init__(name)
1✔
179
        self.input = inputPort
1✔
180
        self.output1 = output1Port
1✔
181
        self.output2 = output2Port
1✔
182

183
    def getPortItems(self) -> _tp.Sequence[PortItem]:
1✔
184
        return [self.input, self.output1, self.output2]
1✔
185

186

187
class Diverter(ThreeNeighboursBase):
1✔
188
    def getNodeType(self) -> NodeType:
1✔
189
        return NodeType.DIVERTER
1✔
190

191
    def hasInput(self) -> bool:
1✔
192
        return True
1✔
193

194
    def getInputVariablePrefix(self) -> str:
1✔
195
        return "xFrac"
1✔
196

197

198
class TeePiece(ThreeNeighboursBase):
1✔
199
    def getNodeType(self) -> NodeType:
1✔
200
        return NodeType.TEE_PIECE
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc