Showing 49 of 316 total issues

Function file_data_store has a Cognitive Complexity of 73 (exceeds 20 allowed). Consider refactoring.
Open

def file_data_store(filename, data, numtype="complex", numformat="decimal",
                    sep=","):
    """Stores a matrix of data to a file to be read by an external program.

    Parameters
Severity: Minor
Found in qutip/fileio.py - About 1 day 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 hinton has a Cognitive Complexity of 68 (exceeds 20 allowed). Consider refactoring.
Open

def hinton(rho, x_basis=None, y_basis=None, color_style="scaled",
           label_top=True, *, cmap=None, colorbar=True, fig=None, ax=None):
    """Draws a Hinton diagram to visualize a density matrix or superoperator.

    Parameters
Severity: Minor
Found in qutip/visualization.py - About 1 day 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 _eigs_csr has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
Open

def _eigs_csr(data, isherm, vecs, eigvals, num_large, num_small, tol, maxiter):
    """
    Internal functions for computing eigenvalues and eigenstates for a sparse
    matrix.
    """
Severity: Minor
Found in qutip/core/data/eigen.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

Function file_data_read has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
Open

def file_data_read(filename, sep=None):
    """Retrieves an array of data from the requested file.

    Parameters
    ----------
Severity: Minor
Found in qutip/fileio.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

Function _generic_pmap has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

def _generic_pmap(task, values, task_args, task_kwargs, reduce_func,
                  timeout, fail_fast, num_workers,
                  progress_bar, progress_bar_kwargs,
                  setup_executor, extract_result, shutdown_executor):
    """
Severity: Minor
Found in qutip/solver/parallel.py - About 3 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

Qobj has 78 functions (exceeds 75 allowed). Consider refactoring.
Open

class Qobj:
    """
    A class for representing quantum objects, such as quantum operators and
    states.

Severity: Major
Found in qutip/core/qobj.py - About 2 hrs to fix

    Function _wigner_laguerre has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
    Open

    def _wigner_laguerre(rho, xvec, yvec, g, parallel):
        r"""
        Using Laguerre polynomials from scipy to evaluate the Wigner function for
        the density matrices :math:`|m><n|`, :math:`W_{mn}`. The total Wigner
        function is calculated as :math:`W = \sum_{mn} \rho_{mn} W_{mn}`.
    Severity: Minor
    Found in qutip/wigner.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 smesolve has 15 arguments (exceeds 10 allowed). Consider refactoring.
    Open

    def smesolve(
    Severity: Major
    Found in qutip/solver/stochastic.py - About 1 hr to fix

      Function simdiag has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
      Open

      def simdiag(ops, evals: bool = True, *,
                  tol: float = 1e-14, safe_mode: bool = True):
          """Simultaneous diagonalization of commuting Hermitian matrices.
      
          Parameters
      Severity: Minor
      Found in qutip/simdiag.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 ssesolve has 14 arguments (exceeds 10 allowed). Consider refactoring.
      Open

      def ssesolve(
      Severity: Major
      Found in qutip/solver/stochastic.py - About 1 hr to fix

        Function tensor has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
        Open

        def tensor(*args):
            """Calculates the tensor product of input operators.
        
            Parameters
            ----------
        Severity: Minor
        Found in qutip/core/tensor.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 _eigs_dense has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
        Open

        def _eigs_dense(data, isherm, vecs, eigvals, num_large, num_small):
            """
            Internal functions for computing eigenvalues and eigenstates for a dense
            matrix.
            """
        Severity: Minor
        Found in qutip/core/data/eigen.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 _generic_pmap has 13 arguments (exceeds 10 allowed). Consider refactoring.
        Open

        def _generic_pmap(task, values, task_args, task_kwargs, reduce_func,
        Severity: Major
        Found in qutip/solver/parallel.py - About 50 mins to fix

          Function matrix_histogram has 13 arguments (exceeds 10 allowed). Consider refactoring.
          Open

          def matrix_histogram(M, x_basis=None, y_basis=None, limits=None,
          Severity: Major
          Found in qutip/visualization.py - About 50 mins to fix

            Function mcsolve has 13 arguments (exceeds 10 allowed). Consider refactoring.
            Open

            def mcsolve(H, state, tlist, c_ops=(), e_ops=None, ntraj=500, *,
            Severity: Major
            Found in qutip/solver/mcsolve.py - About 50 mins to fix

              Function plot_wigner has 13 arguments (exceeds 10 allowed). Consider refactoring.
              Open

              def plot_wigner(rho, xvec=None, yvec=None, method='clenshaw', projection='2d',
              Severity: Major
              Found in qutip/visualization.py - About 50 mins to fix

                Function anim_matrix_histogram has 13 arguments (exceeds 10 allowed). Consider refactoring.
                Open

                def anim_matrix_histogram(Ms, x_basis=None, y_basis=None, limits=None,
                Severity: Major
                Found in qutip/animation.py - About 50 mins to fix

                  Function anim_wigner has 13 arguments (exceeds 10 allowed). Consider refactoring.
                  Open

                  def anim_wigner(rhos, xvec=None, yvec=None, method='clenshaw', projection='2d',
                  Severity: Major
                  Found in qutip/animation.py - About 50 mins to fix

                    Function nm_mcsolve has 12 arguments (exceeds 10 allowed). Consider refactoring.
                    Open

                    def nm_mcsolve(H, state, tlist, ops_and_rates=(), e_ops=None, ntraj=500, *,
                    Severity: Major
                    Found in qutip/solver/nm_mcsolve.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if n != N - 1:
                                              f.write(sep)
                                      f.write("\n")
                      Severity: Major
                      Found in qutip/fileio.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language