tomopy/tomopy

View on GitHub

Showing 321 of 321 total issues

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

    while y.size * shift_y > proj_grid[1] - probe_grid[1] + shift_y:
        y = y[:-1]
Severity: Major
Found in source/tomopy/sim/propagate.py and 1 other location - About 2 hrs to fix
source/tomopy/sim/propagate.py on lines 153..154

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

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

    while x.size * shift_x > proj_grid[0] - probe_grid[0] + shift_x:
        x = x[:-1]
Severity: Major
Found in source/tomopy/sim/propagate.py and 1 other location - About 2 hrs to fix
source/tomopy/sim/propagate.py on lines 155..156

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

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

File benchmark.py has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

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

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

    def _adjust_hist_min(val):
        if val < 0:
            val = 2 * val
        elif val >= 0:
            val = 0.5 * val
    Severity: Major
    Found in source/tomopy/recon/rotation.py and 1 other location - About 2 hrs to fix
    source/tomopy/recon/rotation.py on lines 177..182

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

    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

    def _adjust_hist_max(val):
        if val < 0:
            val = 0.5 * val
        elif val >= 0:
            val = 2 * val
    Severity: Major
    Found in source/tomopy/recon/rotation.py and 1 other location - About 2 hrs to fix
    source/tomopy/recon/rotation.py on lines 169..174

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

    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 main has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def main(arg):
    
        import multiprocessing as mp
        default_ncores = mp.cpu_count()
        default_type = "partial"
    Severity: Minor
    Found in benchmarking/rec.py - About 2 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

    File phantom.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    """TomoPy script to reconstruct a built-in phantom."""
    
    
    Severity: Minor
    Found in benchmarking/phantom.py - About 2 hrs to fix

      Function c_vector3 has 16 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def c_vector3(tomo1, tomo2, tomo3, center1, center2, center3, recon1,
      Severity: Major
      Found in source/tomopy/util/extern/recon.py - About 2 hrs to fix

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

            flist = np.sum(
                np.asarray([factor * ru_list**i for i,
                            factor in enumerate(list_fact)]), axis=0)
        Severity: Major
        Found in source/tomopy/prep/alignment.py and 1 other location - About 1 hr to fix
        source/tomopy/prep/alignment.py on lines 974..976

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

        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

            fact_mat = np.sum(
                np.asarray([factor * ru_mat**i for i,
                            factor in enumerate(list_fact)]), axis=0)
        Severity: Major
        Found in source/tomopy/prep/alignment.py and 1 other location - About 1 hr to fix
        source/tomopy/prep/alignment.py on lines 1021..1023

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

        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

            print("Scaled Image size: {} x {} x {}".format(
                rec_n[0].shape[0],
                rec_n[0].shape[1],
                rec_n.shape[0]))
        Severity: Major
        Found in source/tomopy/misc/benchmark.py and 1 other location - About 1 hr to fix
        source/tomopy/misc/benchmark.py on lines 302..305

        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

            print("Image size: {} x {} x {}".format(
                rec[0].shape[0],
                rec[0].shape[1],
                rec.shape[0]))
        Severity: Major
        Found in source/tomopy/misc/benchmark.py and 1 other location - About 1 hr to fix
        source/tomopy/misc/benchmark.py on lines 307..310

        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

        Function align_seq has 13 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def align_seq(
        Severity: Major
        Found in source/tomopy/prep/alignment.py - About 1 hr to fix

          Function align_joint has 13 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def align_joint(
          Severity: Major
          Found in source/tomopy/prep/alignment.py - About 1 hr to fix

            Function vector3 has 13 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def vector3(tomo1, tomo2, tomo3, theta1, theta2, theta3, center1=None, center2=None, center3=None, num_iter=1, axis1=0, axis2=1, axis3=2):
            Severity: Major
            Found in source/tomopy/recon/vector.py - About 1 hr to fix

              Function run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def run(phantom, algorithm, args, get_recon=False):
                  """Run reconstruction benchmarks for phantoms.
              
                  Parameters
                  ----------
              Severity: Minor
              Found in benchmarking/phantom.py - About 1 hr to fix

                Function align_joint has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                def align_joint(
                        prj, ang, fdir='.', iters=10, pad=(0, 0),
                        blur=True, center=None, algorithm='sirt',
                        upsample_factor=10, rin=0.5, rout=0.8,
                        save=False, debug=True):
                Severity: Minor
                Found in source/tomopy/prep/alignment.py - About 1 hr 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

                    for o in default_options['lprec']:
                        if o not in kwargs:
                            opts[o] = default_options['lprec'][o]
                Severity: Major
                Found in source/tomopy/recon/wrappers.py and 1 other location - About 1 hr to fix
                source/tomopy/recon/wrappers.py on lines 143..145

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

                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

                    for o in default_options['astra']:
                        if o not in opts:
                            opts[o] = default_options['astra'][o]
                Severity: Major
                Found in source/tomopy/recon/wrappers.py and 1 other location - About 1 hr to fix
                source/tomopy/recon/wrappers.py on lines 387..389

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

                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 remove_ring has 12 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def remove_ring(rec,
                Severity: Major
                Found in source/tomopy/misc/corr.py - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language