Code Duplication    Length = 12-13 lines in 2 locations

src/oemof/solph/flows/_investment_flow_block.py 2 locations

@@ 1012-1024 (lines=13) @@
1009
                    period_investment_costs[p] += investment_costs_increment
1010
1011
            for i, o in self.INVESTFLOWS:
1012
                if valid_sequence(
1013
                    m.flows[i, o].investment.fixed_costs, len(m.PERIODS)
1014
                ):
1015
                    lifetime = m.flows[i, o].investment.lifetime
1016
                    for p in m.PERIODS:
1017
                        range_limit = min(
1018
                            m.es.end_year_of_optimization,
1019
                            m.es.periods_years[p] + lifetime,
1020
                        )
1021
                        fixed_costs += sum(
1022
                            self.invest[i, o, p]
1023
                            * m.flows[i, o].investment.fixed_costs[pp]
1024
                            for pp in range(m.es.periods_years[p], range_limit)
1025
                        )
1026
1027
            for i, o in self.EXISTING_INVESTFLOWS:
@@ 1028-1039 (lines=12) @@
1025
                        )
1026
1027
            for i, o in self.EXISTING_INVESTFLOWS:
1028
                if valid_sequence(
1029
                    m.flows[i, o].investment.fixed_costs, len(m.PERIODS)
1030
                ):
1031
                    lifetime = m.flows[i, o].investment.lifetime
1032
                    age = m.flows[i, o].investment.age
1033
                    range_limit = min(
1034
                        m.es.end_year_of_optimization, lifetime - age
1035
                    )
1036
                    fixed_costs += sum(
1037
                        m.flows[i, o].investment.existing
1038
                        * m.flows[i, o].investment.fixed_costs[pp]
1039
                        for pp in range(range_limit)
1040
                    )
1041
1042
        self.investment_costs = Expression(expr=investment_costs)