oemof/oemof-solph

View on GitHub
examples/dual_variable_example/dual_variable_example.py

Summary

Maintainability
F
3 days
Test Coverage

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

def main():
    # *************************************************************************
    # ********** PART 1 - Define and optimise the energy system ***************
    # *************************************************************************

Severity: Minor
Found in examples/dual_variable_example/dual_variable_example.py - About 1 hr to fix

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

        duals = pd.DataFrame(
            {
                str(k[0].label): v["sequences"]["duals"]
                for k, v in results.items()
                if k[1] is None and isinstance(k[0], buses.Bus)
    Severity: Major
    Found in examples/dual_variable_example/dual_variable_example.py and 1 other location - About 4 hrs to fix
    examples/tuple_as_labels/tuple_as_label.py on lines 304..308

    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 84.

    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 3 locations. Consider refactoring.
    Open

        storage = pd.DataFrame(
            {
                str(k[0].label): v["sequences"]["storage_content"]
                for k, v in results.items()
                if k[1] is None and k[0] == storage
    Severity: Major
    Found in examples/dual_variable_example/dual_variable_example.py and 2 other locations - About 4 hrs to fix
    examples/gradient_example/gradient_example.py on lines 193..197
    examples/tuple_as_labels/tuple_as_label.py on lines 296..300

    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 83.

    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 6 locations. Consider refactoring.
    Open

        flows_from_bus = pd.DataFrame(
            {
                str(k[1].label): v["sequences"]["flow"]
                for k, v in results.items()
                if k[1] is not None and k[0] == bus_elec
    Severity: Major
    Found in examples/dual_variable_example/dual_variable_example.py and 5 other locations - About 4 hrs to fix
    examples/dual_variable_example/dual_variable_example.py on lines 255..259
    examples/gradient_example/gradient_example.py on lines 178..182
    examples/gradient_example/gradient_example.py on lines 185..189
    examples/tuple_as_labels/tuple_as_label.py on lines 281..285
    examples/tuple_as_labels/tuple_as_label.py on lines 288..292

    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 83.

    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 6 locations. Consider refactoring.
    Open

        flows_to_bus = pd.DataFrame(
            {
                str(k[0].label): v["sequences"]["flow"]
                for k, v in results.items()
                if k[1] is not None and k[1] == bus_elec
    Severity: Major
    Found in examples/dual_variable_example/dual_variable_example.py and 5 other locations - About 4 hrs to fix
    examples/dual_variable_example/dual_variable_example.py on lines 262..266
    examples/gradient_example/gradient_example.py on lines 178..182
    examples/gradient_example/gradient_example.py on lines 185..189
    examples/tuple_as_labels/tuple_as_label.py on lines 281..285
    examples/tuple_as_labels/tuple_as_label.py on lines 288..292

    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 83.

    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 3 locations. Consider refactoring.
    Open

        pv = [
            0.18,
            0.11,
            0.05,
            0.05,
    Severity: Major
    Found in examples/dual_variable_example/dual_variable_example.py and 2 other locations - About 2 hrs to fix
    examples/dual_variable_example/dual_variable_example.py on lines 70..118
    examples/gradient_example/gradient_example.py on lines 59..107

    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 54.

    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 3 locations. Consider refactoring.
    Open

        demand = [
            209,
            207,
            200,
            191,
    Severity: Major
    Found in examples/dual_variable_example/dual_variable_example.py and 2 other locations - About 2 hrs to fix
    examples/dual_variable_example/dual_variable_example.py on lines 120..168
    examples/gradient_example/gradient_example.py on lines 59..107

    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 54.

    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 2 locations. Consider refactoring.
    Open

            cmp.Converter(
                label="pp_gas",
                inputs={bus_gas: flows.Flow()},
                outputs={bus_elec: flows.Flow(nominal_value=400)},
                conversion_factors={bus_elec: 0.5},
    Severity: Minor
    Found in examples/dual_variable_example/dual_variable_example.py and 1 other location - About 55 mins to fix
    examples/emission_constraint/emission_constraint.py on lines 95..99

    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 37.

    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 3 locations. Consider refactoring.
    Open

        energysystem.add(
            cmp.Sink(
                label="demand",
                inputs={bus_elec: flows.Flow(fix=demand, nominal_value=1)},
    Severity: Major
    Found in examples/dual_variable_example/dual_variable_example.py and 2 other locations - About 45 mins to fix
    examples/dual_variable_example/dual_variable_example.py on lines 198..201
    examples/gradient_example/gradient_example.py on lines 131..134

    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 35.

    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 3 locations. Consider refactoring.
    Open

        energysystem.add(
            cmp.Source(
                label="pv",
                outputs={bus_elec: flows.Flow(fix=pv, nominal_value=700)},
    Severity: Major
    Found in examples/dual_variable_example/dual_variable_example.py and 2 other locations - About 45 mins to fix
    examples/dual_variable_example/dual_variable_example.py on lines 206..209
    examples/gradient_example/gradient_example.py on lines 131..134

    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 35.

    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 2 locations. Consider refactoring.
    Open

        energysystem.add(
            cmp.Source(
                label="rgas",
                outputs={bus_gas: flows.Flow(variable_costs=38)},
    Severity: Minor
    Found in examples/dual_variable_example/dual_variable_example.py and 1 other location - About 30 mins to fix
    examples/gradient_example/gradient_example.py on lines 123..126

    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 32.

    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