tomopy/tomopy

View on GitHub
source/tomopy/recon/rotation.py

Summary

Maintainability
D
3 days
Test Coverage

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

    Function write_center has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def write_center(
            tomo, theta, dpath='tmp/center', cen_range=None, ind=None,
            mask=False, ratio=1., sinogram_order=False, algorithm='gridrec', filter_name='parzen'):
        """
        Save images reconstructed with a range of rotation centers.
    Severity: Minor
    Found in source/tomopy/recon/rotation.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

    Function write_center has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def write_center(
    Severity: Major
    Found in source/tomopy/recon/rotation.py - About 1 hr to fix

      Function find_center_vo has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def find_center_vo(tomo, ind=None, smin=-50, smax=50, srad=6, step=0.25,
      Severity: Major
      Found in source/tomopy/recon/rotation.py - About 1 hr to fix

        Function _find_center_cost has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def _find_center_cost(
        Severity: Major
        Found in source/tomopy/recon/rotation.py - About 1 hr to fix

          Function find_center has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def find_center(
          Severity: Major
          Found in source/tomopy/recon/rotation.py - About 1 hr to fix

            Function _search_fine has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def _search_fine(sino, srad, step, init_cen, ratio, drop, ncore=None):
            Severity: Major
            Found in source/tomopy/recon/rotation.py - About 50 mins to fix

              Function find_center_vo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def find_center_vo(tomo, ind=None, smin=-50, smax=50, srad=6, step=0.25,
                                 ratio=0.5, drop=20, ncore=None):
                  """
                  Find rotation axis location using Nghia Vo's method. :cite:`Vo:14`.
              
              
              Severity: Minor
              Found in source/tomopy/recon/rotation.py - About 45 mins 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 _search_coarse has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def _search_coarse(sino, smin, smax, ratio, drop, ncore=None):
              Severity: Minor
              Found in source/tomopy/recon/rotation.py - About 45 mins to fix

                Function _calculate_metric has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def _calculate_metric(shift_col, sino1, sino2, sino3, mask):
                    """
                    Metric calculation.
                    """
                    shift_col = 1.0 * np.squeeze(shift_col)
                Severity: Minor
                Found in source/tomopy/recon/rotation.py - About 45 mins 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 _calculate_metric has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def _calculate_metric(shift_col, sino1, sino2, sino3, mask):
                Severity: Minor
                Found in source/tomopy/recon/rotation.py - About 35 mins to fix

                  Function find_center has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def find_center(
                          tomo, theta, ind=None, init=None,
                          tol=0.5, mask=True, ratio=1., sinogram_order=False):
                      """
                      Find rotation axis location.
                  Severity: Minor
                  Found in source/tomopy/recon/rotation.py - About 25 mins 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

                  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

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

                      smax = np.int16(np.clip(smax + cen_fliplr, 0, ncol - 1) - cen_fliplr)
                  Severity: Minor
                  Found in source/tomopy/recon/rotation.py and 1 other location - About 55 mins to fix
                  source/tomopy/recon/rotation.py on lines 311..311

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

                      smin = np.int16(np.clip(smin + cen_fliplr, 0, ncol - 1) - cen_fliplr)
                  Severity: Minor
                  Found in source/tomopy/recon/rotation.py and 1 other location - About 55 mins to fix
                  source/tomopy/recon/rotation.py on lines 312..312

                  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

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

                      list_metric = distribute_jobs(np.float32(list_shift),
                                                    _calculate_metric, axis=0,
                                                    args=(sino, flip_sino, comp_sino, mask),
                  Severity: Minor
                  Found in source/tomopy/recon/rotation.py and 1 other location - About 40 mins to fix
                  source/tomopy/recon/rotation.py on lines 321..323

                  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

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

                      list_metric = distribute_jobs(np.float32(list_shift),
                                                    _calculate_metric, axis=0,
                                                    args=(sino, flip_sino, comp_sino, mask),
                  Severity: Minor
                  Found in source/tomopy/recon/rotation.py and 1 other location - About 40 mins to fix
                  source/tomopy/recon/rotation.py on lines 350..352

                  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