tomopy/tomopy

View on GitHub

Showing 354 of 354 total issues

File rotation.py has 469 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# #########################################################################
# Copyright (c) 2015-2019, UChicago Argonne, LLC. All rights reserved.    #
Severity: Minor
Found in source/tomopy/recon/rotation.py - About 7 hrs to fix

    File recon.py has 462 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    # #########################################################################
    # Copyright (c) 2015-2019, UChicago Argonne, LLC. All rights reserved.    #
    Severity: Minor
    Found in source/tomopy/util/extern/recon.py - About 7 hrs to fix

      File project.py has 434 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python
      # -*- coding: utf-8 -*-
      
      # #########################################################################
      # Copyright (c) 2015-2019, UChicago Argonne, LLC. All rights reserved.    #
      Severity: Minor
      Found in source/tomopy/sim/project.py - About 6 hrs to fix

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

        def barbara(size=512, dtype='float32'):
            """
            Load test Barbara image array.
        
            Parameters
        Severity: Major
        Found in source/tomopy/misc/phantom.py and 5 other locations - About 5 hrs to fix
        source/tomopy/misc/phantom.py on lines 145..168
        source/tomopy/misc/phantom.py on lines 171..194
        source/tomopy/misc/phantom.py on lines 197..220
        source/tomopy/misc/phantom.py on lines 223..246
        source/tomopy/misc/phantom.py on lines 249..272

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

        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

        def cameraman(size=512, dtype='float32'):
            """
            Load test cameraman image array.
        
            Parameters
        Severity: Major
        Found in source/tomopy/misc/phantom.py and 5 other locations - About 5 hrs to fix
        source/tomopy/misc/phantom.py on lines 119..142
        source/tomopy/misc/phantom.py on lines 171..194
        source/tomopy/misc/phantom.py on lines 197..220
        source/tomopy/misc/phantom.py on lines 223..246
        source/tomopy/misc/phantom.py on lines 249..272

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

        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

        def checkerboard(size=512, dtype='float32'):
            """
            Load test checkerboard image array.
        
            Parameters
        Severity: Major
        Found in source/tomopy/misc/phantom.py and 5 other locations - About 5 hrs to fix
        source/tomopy/misc/phantom.py on lines 119..142
        source/tomopy/misc/phantom.py on lines 145..168
        source/tomopy/misc/phantom.py on lines 197..220
        source/tomopy/misc/phantom.py on lines 223..246
        source/tomopy/misc/phantom.py on lines 249..272

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

        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

        def shepp2d(size=512, dtype='float32'):
            """
            Load test Shepp-Logan image array.
        
            Parameters
        Severity: Major
        Found in source/tomopy/misc/phantom.py and 5 other locations - About 5 hrs to fix
        source/tomopy/misc/phantom.py on lines 119..142
        source/tomopy/misc/phantom.py on lines 145..168
        source/tomopy/misc/phantom.py on lines 171..194
        source/tomopy/misc/phantom.py on lines 197..220
        source/tomopy/misc/phantom.py on lines 223..246

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

        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

        def lena(size=512, dtype='float32'):
            """
            Load test Lena image array.
        
            Parameters
        Severity: Major
        Found in source/tomopy/misc/phantom.py and 5 other locations - About 5 hrs to fix
        source/tomopy/misc/phantom.py on lines 119..142
        source/tomopy/misc/phantom.py on lines 145..168
        source/tomopy/misc/phantom.py on lines 171..194
        source/tomopy/misc/phantom.py on lines 223..246
        source/tomopy/misc/phantom.py on lines 249..272

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

        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

        def peppers(size=512, dtype='float32'):
            """
            Load test peppers image array.
        
            Parameters
        Severity: Major
        Found in source/tomopy/misc/phantom.py and 5 other locations - About 5 hrs to fix
        source/tomopy/misc/phantom.py on lines 119..142
        source/tomopy/misc/phantom.py on lines 145..168
        source/tomopy/misc/phantom.py on lines 171..194
        source/tomopy/misc/phantom.py on lines 197..220
        source/tomopy/misc/phantom.py on lines 249..272

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

        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

        Function recon has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
        Open

        def recon(tomo,
                  theta,
                  center=None,
                  sinogram_order=False,
                  algorithm=None,
        Severity: Minor
        Found in source/tomopy/recon/algorithm.py - About 5 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        def c_median_filt3d_float32(
            input,
            output,
            kernel_half_size,
            absdif,
        Severity: Major
        Found in source/tomopy/util/extern/misc.py and 3 other locations - About 5 hrs to fix
        source/tomopy/util/extern/misc.py on lines 69..90
        source/tomopy/util/extern/misc.py on lines 139..160
        source/tomopy/util/extern/prep.py on lines 102..123

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

        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

        def c_sample(
            mode,
            arr,
            dx,
            dy,
        Severity: Major
        Found in source/tomopy/util/extern/misc.py and 3 other locations - About 5 hrs to fix
        source/tomopy/util/extern/misc.py on lines 115..136
        source/tomopy/util/extern/misc.py on lines 139..160
        source/tomopy/util/extern/prep.py on lines 102..123

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

        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

        def c_stripes_detect3d(
            input,
            output,
            size,
            radius,
        Severity: Major
        Found in source/tomopy/util/extern/prep.py and 3 other locations - About 5 hrs to fix
        source/tomopy/util/extern/misc.py on lines 69..90
        source/tomopy/util/extern/misc.py on lines 115..136
        source/tomopy/util/extern/misc.py on lines 139..160

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

        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

        def c_median_filt3d_uint16(
            input,
            output,
            kernel_half_size,
            absdif,
        Severity: Major
        Found in source/tomopy/util/extern/misc.py and 3 other locations - About 5 hrs to fix
        source/tomopy/util/extern/misc.py on lines 69..90
        source/tomopy/util/extern/misc.py on lines 115..136
        source/tomopy/util/extern/prep.py on lines 102..123

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

        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

        Function inpainter_morph has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        def inpainter_morph(
            arr,
            mask,
            size=5,
            iterations=2,
        Severity: Minor
        Found in source/tomopy/misc/corr.py - About 5 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function distribute_jobs has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

        def distribute_jobs(arr,
                            func,
                            axis,
                            args=None,
                            kwargs=None,
        Severity: Minor
        Found in source/tomopy/util/mproc.py - About 5 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _dist_recon has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

        def _dist_recon(tomo, center, recon, algorithm, args, kwargs, ncore, nchunk):
            axis_size = recon.shape[0]
            ncore, slcs = mproc.get_ncore_slices(axis_size, ncore, nchunk)
        
            if len(slcs) < ncore:
        Severity: Minor
        Found in source/tomopy/recon/algorithm.py - About 4 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

            LIB_TOMOPY_PREP.stripesmask3d_main_float(
                dtype.as_c_float_p(input),
                dtype.as_c_bool_p(output),
                dtype.as_c_float(threshold_val),
                dtype.as_c_int(min_stripe_length),
        Severity: Major
        Found in source/tomopy/util/extern/prep.py and 1 other location - About 4 hrs to fix
        source/tomopy/util/extern/recon.py on lines 140..151

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

        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

            LIB_TOMOPY_RECON.project2(
                dtype.as_c_float_p(objx),
                dtype.as_c_float_p(objy),
                dtype.as_c_int(oy),
                dtype.as_c_int(ox),
        Severity: Major
        Found in source/tomopy/util/extern/recon.py and 1 other location - About 4 hrs to fix
        source/tomopy/util/extern/prep.py on lines 139..150

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

        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

            def test_bart(self):
                rng = default_rng(0)
                ind_block = np.arange(len(self.ang))
                rng.shuffle(ind_block)
                assert_allclose(
        Severity: Major
        Found in test/test_tomopy/test_recon/test_algorithm.py and 3 other locations - About 4 hrs to fix
        test/test_tomopy/test_recon/test_algorithm.py on lines 198..211
        test/test_tomopy/test_recon/test_algorithm.py on lines 216..229
        test/test_tomopy/test_recon/test_algorithm.py on lines 234..247

        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

        Severity
        Category
        Status
        Source
        Language