dseuss/mpnum

View on GitHub

Showing 125 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

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

      def _adapt_to_add_l(leftvec, compr_lten, tgt_lten):
          """Add one column to the left vector.
      
          :param leftvec: existing left vector
              It has two indices: `compr_mps_bond` and `tgt_mps_bond`
      Severity: Major
      Found in mpnum/mparray.py and 1 other location - About 1 day to fix
      mpnum/mparray.py on lines 1965..2001

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

      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 _adapt_to_add_r(rightvec, compr_lten, tgt_lten):
          """Add one column to the right vector.
      
          :param rightvec: existing right vector
              It has two indices: `compr_mps_bond` and `tgt_mps_bond`
      Severity: Major
      Found in mpnum/mparray.py and 1 other location - About 1 day to fix
      mpnum/mparray.py on lines 1927..1962

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

      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

                  if relerr is None:
                      u, sv, v = svdfunc(ltens.reshape(matshape), rank)
                      rank_t = len(sv)
                  else:
                      u, sv, v = svd(ltens.reshape(matshape))
      Severity: Major
      Found in mpnum/mparray.py and 1 other location - About 1 day to fix
      mpnum/mparray.py on lines 915..922

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

      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

                  if relerr is None:
                      u, sv, v = svdfunc(ltens.reshape(matshape), rank)
                      rank_t = len(sv)
                  else:
                      u, sv, v = svd(ltens.reshape(matshape))
      Severity: Major
      Found in mpnum/mparray.py and 1 other location - About 1 day to fix
      mpnum/mparray.py on lines 946..953

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

      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

      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

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

            if isinstance(axes[0], Sequence):
                axes = tuple(tuple(ax + 1 if ax >= 0 else ax - 1 for ax in axes2)
                             for axes2 in axes)
            else:
                axes = tuple(ax + 1 if ax >= 0 else ax - 1 for ax in axes)
        Severity: Major
        Found in mpnum/mparray.py and 1 other location - About 7 hrs to fix
        mpnum/mparray.py on lines 1143..1147

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

        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

            if isinstance(axes[0], Sequence):
                axes = tuple(tuple(ax + 1 if ax >= 0 else ax - 1 for ax in axes2)
                             for axes2 in axes)
            else:
                axes = tuple(ax + 1 if ax >= 0 else ax - 1 for ax in axes)
        Severity: Major
        Found in mpnum/mparray.py and 1 other location - About 7 hrs to fix
        mpnum/mparray.py on lines 1209..1213

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

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

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

              for i, mpa, ndims, lv in zip(it.count(), mpas, mpas_ndims, leftvec):
                  if ndims == 2:
                      leftvec_out[i] = _eig_leftvec_add(lv, mpa.lt[pos], mps_lten)
                  elif ndims == 1:
                      leftvec_out[i] = _eig_leftvec_add_mps(lv, mpa.lt[pos], mps_lten)
          Severity: Major
          Found in mpnum/linalg.py and 1 other location - About 6 hrs to fix
          mpnum/linalg.py on lines 169..175

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

          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 i, mpa, ndims, rv in zip(it.count(), mpas, mpas_ndims, rightvec):
                  if ndims == 2:
                      rightvec_out[i] = _eig_rightvec_add(rv, mpa.lt[pos], mps_lten)
                  elif ndims == 1:
                      rightvec_out[i] = _eig_rightvec_add_mps(rv, mpa.lt[pos], mps_lten)
          Severity: Major
          Found in mpnum/linalg.py and 1 other location - About 6 hrs to fix
          mpnum/linalg.py on lines 157..163

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

          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 i in range(dim - 1):
                  for j in range(i + 1, dim):
                      vectors[k, i], vectors[k, j] = 1.0, 1.0
                      k += 1
                      vectors[k, i], vectors[k, j] = 1.0, -1.0
          Severity: Major
          Found in mpnum/povm/localpovm.py and 1 other location - About 6 hrs to fix
          mpnum/povm/localpovm.py on lines 115..120

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

          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 i in range(dim - 1):
                  for j in range(i + 1, dim):
                      vectors[k, i], vectors[k, j] = 1.0, 1.0j
                      k += 1
                      vectors[k, i], vectors[k, j] = 1.0, -1.0j
          Severity: Major
          Found in mpnum/povm/localpovm.py and 1 other location - About 6 hrs to fix
          mpnum/povm/localpovm.py on lines 96..101

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

          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

                      if pos > 0:
                          eigvec.canonicalize(left=pos)
                          rightvecs[pos - 1] = None
                          leftvecs[pos] = _eig_leftvec_add(
                              leftvecs[pos - 1], mpo.lt[pos - 1], eigvec.lt[pos - 1])
          Severity: Major
          Found in mpnum/linalg.py and 1 other location - About 5 hrs to fix
          mpnum/mparray.py on lines 1082..1086

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

          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

                          if pos > 0:
                              self.canonicalize(left=pos)
                              rvecs[pos - 1] = None
                              lvecs[pos] = _adapt_to_add_l(lvecs[pos - 1], self._lt[pos - 1],
                                                           target.lt[pos - 1])
          Severity: Major
          Found in mpnum/mparray.py and 1 other location - About 5 hrs to fix
          mpnum/linalg.py on lines 514..518

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

          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

                      if pos < nr_sites - var_sites:
                          # We always do this, because we don't do the last site again.
                          eigvec.canonicalize(right=pos_end)
                          leftvecs[pos + 1] = None
                          rightvecs[pos] = _eig_rightvec_add(
          Severity: Major
          Found in mpnum/linalg.py and 1 other location - About 5 hrs to fix
          mpnum/mparray.py on lines 1096..1101

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

          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

                          if pos < nr_sites - var_sites:
                              # We always do this, because we don't do the last site again.
                              self.canonicalize(right=pos_end)
                              lvecs[pos + 1] = None
                              rvecs[pos] = _adapt_to_add_r(rvecs[pos + 1], self._lt[pos_end],
          Severity: Major
          Found in mpnum/mparray.py and 1 other location - About 5 hrs to fix
          mpnum/linalg.py on lines 528..533

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

          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

          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
              Severity
              Category
              Status
              Source
              Language