CellProfiler/centrosome

View on GitHub
centrosome/bg_compensate.py

Summary

Maintainability
D
2 days
Test Coverage

File bg_compensate.py has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import absolute_import
from __future__ import print_function
import warnings

import numpy as np
Severity: Minor
Found in centrosome/bg_compensate.py - About 4 hrs to fix

    Function backgr has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def backgr(
        img,
        mask=None,
        mode=MODE_AUTO,
        thresh=2,
    Severity: Minor
    Found in centrosome/bg_compensate.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

    Function prcntiles has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def prcntiles(x, percents):
        """Equivalent to matlab prctile(x,p), uses linear interpolation."""
        x = np.array(x).flatten()
        listx = np.sort(x)
        xpcts = []
    Severity: Minor
    Found in centrosome/bg_compensate.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 automode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def automode(data):
        """Tries to guess if the image contains dark objects on a bright background (1)
    or if the image contains bright objects on a dark background (-1),
    or if it contains both dark and bright objects on a gray background (0)."""
    
    
    Severity: Minor
    Found in centrosome/bg_compensate.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 backgr has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def backgr(
    Severity: Major
    Found in centrosome/bg_compensate.py - About 1 hr to fix

      Function bg_compensate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def bg_compensate(img, sigma, splinepoints, scale):
          """Reads file, subtracts background. Returns [compensated image, background]."""
      
          from PIL import Image
          import pylab
      Severity: Minor
      Found in centrosome/bg_compensate.py - About 55 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 splinefit2d has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def splinefit2d(x, y, z, px, py, mask=None):
      Severity: Minor
      Found in centrosome/bg_compensate.py - About 45 mins to fix

        Function splineimage has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def splineimage(Z, points, mask=None, x=None, y=None):
        Severity: Minor
        Found in centrosome/bg_compensate.py - About 35 mins to fix

          Function evalspline2d has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def evalspline2d(x, y, px, py, pz):
          Severity: Minor
          Found in centrosome/bg_compensate.py - About 35 mins to fix

            Function spline_matrix2d has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def spline_matrix2d(x, y, px, py, mask=None):
            Severity: Minor
            Found in centrosome/bg_compensate.py - About 35 mins to fix

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

                  i, j = np.mgrid[0 : img.shape[0], 0 : img.shape[1]]
              Severity: Major
              Found in centrosome/bg_compensate.py and 7 other locations - About 1 hr to fix
              centrosome/cpmorphology.py on lines 2312..2312
              centrosome/cpmorphology.py on lines 4188..4188
              centrosome/cpmorphology.py on lines 4259..4259
              centrosome/cpmorphology.py on lines 5176..5176
              centrosome/filter.py on lines 1626..1626
              centrosome/filter.py on lines 1976..1976
              centrosome/smooth.py on lines 89..89

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

              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

                  rstep = (y[-1] - y[0]) / (points - 3.0)
              Severity: Minor
              Found in centrosome/bg_compensate.py and 1 other location - About 45 mins to fix
              centrosome/bg_compensate.py on lines 246..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 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

                  px = linspace(x[0] - cstep, x[-1] + cstep, points)
              Severity: Minor
              Found in centrosome/bg_compensate.py and 1 other location - About 45 mins to fix
              centrosome/bg_compensate.py on lines 249..249

              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

                  cstep = (x[-1] - x[0]) / (points - 3.0)
              Severity: Minor
              Found in centrosome/bg_compensate.py and 1 other location - About 45 mins to fix
              centrosome/bg_compensate.py on lines 248..248

              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

                  py = linspace(y[0] - rstep, y[-1] + rstep, points)
              Severity: Minor
              Found in centrosome/bg_compensate.py and 1 other location - About 45 mins to fix
              centrosome/bg_compensate.py on lines 247..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 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

                  i_pick, i_val = np.mgrid[0 : len(picklist), 0 : len(val)]
              Severity: Minor
              Found in centrosome/bg_compensate.py and 1 other location - About 35 mins to fix
              centrosome/cpmorphology.py on lines 1795..1795

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

              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