oemof/oemof-solph

View on GitHub
examples/storage_investment/v3_invest_optimize_only_storage_with_fossil_share.py

Summary

Maintainability
D
2 days
Test Coverage

Function main has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def main():
    # Read data file
    filename = os.path.join(os.getcwd(), "storage_investment.csv")
    try:
        data = pd.read_csv(filename)

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

        storage = solph.components.GenericStorage(
            label="storage",
            inputs={bel: solph.Flow(variable_costs=0.0001)},
            outputs={bel: solph.Flow()},
            loss_rate=0.00,
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 184..194
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 177..187
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 195..205

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 82.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        try:
            data = pd.read_csv(filename)
        except FileNotFoundError:
            msg = "Data file not found: {0}. Only one value used!"
            warnings.warn(msg.format(filename), UserWarning)
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 95..101
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 98..104
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 94..100

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 67.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

        my_results["res_share"] = (
            1
            - results[(pp_gas, bel)]["sequences"].sum()
            / results[(bel, demand)]["sequences"].sum()
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 237..240
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 225..228
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 252..255

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 61.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        gas_resource = solph.components.Source(
            label="rgas",
            outputs={
                bgas: solph.Flow(
                    nominal_value=fossil_share
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 145..153

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 57.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

        pp_gas = solph.components.Converter(
            label="pp_gas",
            inputs={bgas: solph.Flow()},
            outputs={bel: solph.Flow(nominal_value=10e10, variable_costs=0)},
            conversion_factors={bel: 0.58},
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 176..180
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 169..173
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 187..191

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 51.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

        wind = solph.components.Source(
            label="wind",
            outputs={bel: solph.Flow(fix=data["wind"], nominal_value=1000000)},
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 170..172
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 151..153
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 157..159
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 163..165
    examples/storage_investment/v3_invest_optimize_only_storage_with_fossil_share.py on lines 167..169
    examples/storage_investment/v3_invest_optimize_only_storage_with_fossil_share.py on lines 173..175
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 181..183

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 39.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

        demand = solph.components.Sink(
            label="demand",
            inputs={bel: solph.Flow(fix=data["demand_el"], nominal_value=1)},
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 170..172
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 151..153
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 157..159
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 163..165
    examples/storage_investment/v3_invest_optimize_only_storage_with_fossil_share.py on lines 161..163
    examples/storage_investment/v3_invest_optimize_only_storage_with_fossil_share.py on lines 167..169
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 181..183

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 39.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

        pv = solph.components.Source(
            label="pv",
            outputs={bel: solph.Flow(fix=data["pv"], nominal_value=600000)},
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 170..172
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 151..153
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 157..159
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 163..165
    examples/storage_investment/v3_invest_optimize_only_storage_with_fossil_share.py on lines 161..163
    examples/storage_investment/v3_invest_optimize_only_storage_with_fossil_share.py on lines 173..175
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 181..183

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 39.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 7 locations. Consider refactoring.
    Open

        my_results["storage_invest_GWh"] = (
            results[(storage, None)]["scalars"]["invest"] / 1e6
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 227..228
    examples/storage_investment/v1_invest_optimize_all_technologies.py on lines 232..233
    examples/storage_investment/v2_invest_optimize_only_gas_and_storage.py on lines 220..221
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 239..240
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 244..245
    examples/storage_investment/v4_invest_optimize_all_technologies_with_fossil_share.py on lines 249..249

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 38.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    There are no issues that match your filters.

    Category
    Status