oemof/oemof-solph

View on GitHub
examples/tuple_as_labels/tuple_as_label.py

Summary

Maintainability
F
3 days
Test Coverage

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

def main():
    # Read data file
    filename = os.path.join(os.getcwd(), "tuple_as_label.csv")
    try:
        data = pd.read_csv(filename)
Severity: Minor
Found in examples/tuple_as_labels/tuple_as_label.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/tuple_as_labels/tuple_as_label.py and 1 other location - About 4 hrs to fix
    examples/dual_variable_example/dual_variable_example.py on lines 278..282

    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/tuple_as_labels/tuple_as_label.py and 2 other locations - About 4 hrs to fix
    examples/dual_variable_example/dual_variable_example.py on lines 270..274
    examples/gradient_example/gradient_example.py on lines 193..197

    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] == bel
    Severity: Major
    Found in examples/tuple_as_labels/tuple_as_label.py and 5 other locations - About 4 hrs to fix
    examples/dual_variable_example/dual_variable_example.py on lines 255..259
    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 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_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] == bel
    Severity: Major
    Found in examples/tuple_as_labels/tuple_as_label.py and 5 other locations - About 4 hrs to fix
    examples/dual_variable_example/dual_variable_example.py on lines 255..259
    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

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

        energysystem.add(
            comp.Source(
                label=Label("ee_source", "electricity", "wind"),
                outputs={bel: flows.Flow(fix=data["wind"], nominal_value=2000)},
    Severity: Major
    Found in examples/tuple_as_labels/tuple_as_label.py and 1 other location - About 1 hr to fix
    examples/tuple_as_labels/tuple_as_label.py on lines 206..209

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

    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(
            comp.Source(
                label=Label("ee_source", "electricity", "pv"),
                outputs={bel: flows.Flow(fix=data["pv"], nominal_value=3000)},
    Severity: Major
    Found in examples/tuple_as_labels/tuple_as_label.py and 1 other location - About 1 hr to fix
    examples/tuple_as_labels/tuple_as_label.py on lines 198..201

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

    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(
            comp.Source(
                label=Label("commodity_source", "gas", "commodity"),
                outputs={bgas: flows.Flow()},
    Severity: Minor
    Found in examples/tuple_as_labels/tuple_as_label.py and 1 other location - About 40 mins to fix
    examples/tuple_as_labels/tuple_as_label.py on lines 182..185

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

    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(
            comp.Sink(
                label=Label("sink", "electricity", "excess"),
                inputs={bel: flows.Flow()},
    Severity: Minor
    Found in examples/tuple_as_labels/tuple_as_label.py and 1 other location - About 40 mins to fix
    examples/tuple_as_labels/tuple_as_label.py on lines 190..193

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

    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