Passed
Pull Request — dev (#1193)
by Uwe
01:50
created

solph._facades   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 17
dl 0
loc 43
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A Facade.__init__() 0 4 1
A Facade.define_subnetwork() 0 2 1
A Facade.add_subnetwork() 0 3 1
A Facade.sub_component_labelling() 0 5 1
A Facade.sub_label_error() 0 7 1
1
# -*- coding: utf-8 -*-
2
3
"""
4
Solph Facade based on oemof.network.SubNetwork
5
6
SPDX-FileCopyrightText: Uwe Krien <[email protected]>
7
SPDX-FileCopyrightText: Pierre-François Duc
8
9
SPDX-License-Identifier: MIT
10
11
"""
12
13
from oemof.network import SubNetwork
14
15
16
class Facade(SubNetwork):
17
    # attributes
18
    def __init__(self, label, facade_type, *args, **kwargs):
19
        super().__init__(label=label)
20
        self.facade_type = facade_type
21
        self.define_subnetwork()
22
23
    def define_subnetwork(self):
24
        pass
25
26
    def add_subnetwork(self):
27
        """Instanciate and add Node instance to the sub network"""
28
        pass
29
30
    def sub_component_labelling(self, sub_label):
31
        """
32
        Method to always keep the Facade instance label in its subcomponents
33
        """
34
        return f"{self.label}_{sub_label}"
35
36
    def sub_label_error(self, sub_component):
37
        msg = (
38
            f"Sublabel ERROR in Facade instance:\n{self.label}, "
39
            f"{self.facade_type}, {sub_component}, "
40
            f"{sub_component.custom_properties}"
41
        )
42
        raise AttributeError(msg)
43