dseuss/mpnum

View on GitHub

Showing 61 of 125 total issues

File mparray.py has 1490 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# encoding: utf-8
""" Core MPArray data structure & general purpose functions

  .. todo:: single site MPAs -- what is left?
  .. todo:: Local tensor ownership -- see MPArray class comment
Severity: Major
Found in mpnum/mparray.py - About 3 days to fix

    File mppovm.py has 1229 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # encoding: utf-8
    
    
    r'''Matrix-product representation of POVMs
    
    
    Severity: Major
    Found in mpnum/povm/mppovm.py - About 3 days to fix

      MPArray has 53 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class MPArray(object):
          r"""Efficient representation of a general N-partite array :math:`A` in
          matrix product form with open boundary conditions:
      
          .. math::
      Severity: Major
      Found in mpnum/mparray.py - About 7 hrs to fix

        File linalg.py has 454 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # encoding: utf-8
        
        """Linear algebra with matrix product arrays
        
        Currently, we support computing extremal eigenvalues and eigenvectors
        Severity: Minor
        Found in mpnum/linalg.py - About 6 hrs to fix

          MPPovm has 34 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class MPPovm(mp.MPArray):
              """MPArray representation of multipartite POVM
          
              There are two different ways to write down a POVM in matrix product form
          
          
          Severity: Minor
          Found in mpnum/povm/mppovm.py - About 4 hrs to fix

            File factory.py has 322 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # encoding: utf-8
            """Module to create random test instances of matrix product arrays"""
            
            from __future__ import division, print_function
            
            
            Severity: Minor
            Found in mpnum/factory.py - About 3 hrs to fix

              Function eig_sum has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              def eig_sum(mpas, num_sweeps, var_sites=2,
                          startvec=None, startvec_rank=None, randstate=None, eigs=None):
                  r"""Iterative search for eigenvalues of a sum of MPOs/MPSs
              
                  Try to compute the ground state of the sum of the objects in
              Severity: Minor
              Found in mpnum/linalg.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

              Function eig has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              def eig(mpo, num_sweeps, var_sites=2,
                      startvec=None, startvec_rank=None, randstate=None, eigs=None):
                  r"""Iterative search for MPO eigenvalues
              
                  .. note::
              Severity: Minor
              Found in mpnum/linalg.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

              File mpsmpo.py has 279 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # encoding: utf-8
              
              
              r"""Matrix Product State (MPS) and Operator (MPO) functions
              
              
              Severity: Minor
              Found in mpnum/mpsmpo.py - About 2 hrs to fix

                Function _adapt_to has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _adapt_to(self, target, num_sweeps, var_sites):
                        """Iteratively minimize the l2 distance between `self` and `target`.
                        This is especially important for variational compression, where `self`
                        is the initial guess and target the MPA to be compressed.
                
                
                Severity: Minor
                Found in mpnum/mparray.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 expectations has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def expectations(self, mpa, mode='auto'):
                        """Computes the exp. values of the POVM elements with given state
                
                        :param mpa: State given as MPDO, MPS, or PMPS
                        :param mode: In which form `mpa` is given. Possible values: 'mpdo',
                Severity: Minor
                Found in mpnum/povm/mppovm.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 _compress_svd has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _compress_svd(self, rank=None, relerr=None, direction=None,
                                      canonicalize=True, svdfunc=truncated_svd):
                        """Compress `self` using SVD [:ref:`Sch11 <Sch11>`, Sec. 4.5.1]
                
                        Parameters: See :func:`~compress()`.
                Severity: Minor
                Found in mpnum/mparray.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 sum has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def sum(self, axes=None):
                        """Element-wise sum over physical legs
                
                        :param axes: Physical legs to sum over
                
                
                Severity: Minor
                Found in mpnum/mparray.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 canonicalize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def canonicalize(self, left=None, right=None):
                        """Brings the MPA to canonical form in place
                        [:ref:`Sch11 <Sch11>`, Sec. 4.4]
                
                        Note that we do not support full left- or right-canonicalization. In
                Severity: Minor
                Found in mpnum/mparray.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 partialdot has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def partialdot(mpa1, mpa2, start_at, axes=(-1, 0)):
                    """Partial dot product of two MPAs of inequal length.
                
                    The shorter MPA will start on site ``start_at``. Local dot products
                    will be carried out on all sites of the shorter MPA. Other sites
                Severity: Minor
                Found in mpnum/mparray.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 inject has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                def inject(mpa, pos, num=None, inject_ten=None):
                    """Interleaved chain product of an MPA and a rank 1 MPA
                
                    Return the chain product between mpa and ``num`` copies of the local
                    tensor ``inject_ten``, but place the copies of ``inject_ten`` before
                Severity: Minor
                Found in mpnum/mparray.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 _eig_minimize_locally2 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                def _eig_minimize_locally2(local_op, eigvec_ltens, eigs):
                    """Implement the main part of :func:`_eig_minimize_locally`
                
                    See :func:`_eig_minimize_locally` for a description.
                
                
                Severity: Minor
                Found in mpnum/linalg.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 pmf_as_array has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def pmf_as_array(self, state, mode='auto', eps=1e-10, impl='auto'):
                        """Compute the POVM's PMF for `state` as full array
                
                        Parameters: See :func:`MPPovm.pmf`.
                
                
                Severity: Minor
                Found in mpnum/povm/mppovm.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 lfun has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def lfun(self, coeff, funs, state, mode='auto', eps=1e-10):
                        """Evaluate a linear combination of functions of POVM outcomes
                
                        :param np.ndarray coeff: A length `n_funs` array with the
                            coefficients of the linear combination. If `None`, return
                Severity: Minor
                Found in mpnum/povm/mppovm.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 match_elems has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def match_elems(self, other, exclude_dup=(), eps=1e-10):
                        """Find POVM elements in `other` which have information on `self`
                
                        We find all POVM sites in `self` which have only one possible
                        outcome. We discard these outputs in `other` and afterwards
                Severity: Minor
                Found in mpnum/povm/mppovm.py - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language