dseuss/mpnum

View on GitHub

Showing 125 of 125 total issues

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

def reductions_mpo(mpa, width=None, startsites=None, stopsites=None):
    """Iterate over MPO partial traces of an MPO

    The support of the i-th result is :code:`range(startsites[i],
    stopsites[i])`.
Severity: Minor
Found in mpnum/mpsmpo.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

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

        rvecs = [None] * (nr_sites - var_sites) + [np.array(1, ndmin=2)]
Severity: Minor
Found in mpnum/mparray.py and 1 other location - About 55 mins to fix
mpnum/linalg.py on lines 498..498

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

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

def approx_range_finder(A, sketch_size, n_iter, piter_normalizer='auto',
                        randstate=np.random):
    """Computes an orthonormal matrix whose range approximates the range of A.

    Parameters
Severity: Minor
Found in mpnum/utils/extmath.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

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

    rightvecs = [None] * (nr_sites - var_sites) + [np.array(1, ndmin=3)]
Severity: Minor
Found in mpnum/linalg.py and 1 other location - About 55 mins to fix
mpnum/mparray.py on lines 1059..1059

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

        lvecs = [np.array(1, ndmin=2)] + [None] * (nr_sites - var_sites)
Severity: Minor
Found in mpnum/mparray.py and 1 other location - About 55 mins to fix
mpnum/linalg.py on lines 497..497

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

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

    def _sample_cond(self, rng, state, mode, n_samples, n_group, out, eps):
Severity: Major
Found in mpnum/povm/mppovm.py - About 50 mins to fix

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

    def _eig_sum_minimize_locally(
    Severity: Major
    Found in mpnum/linalg.py - About 50 mins to fix

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

      def randomized_svd(M, n_components, n_oversamples=10, n_iter='auto',
      Severity: Major
      Found in mpnum/utils/extmath.py - About 50 mins to fix

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

        def eig_sum(mpas, num_sweeps, var_sites=2,
        Severity: Major
        Found in mpnum/linalg.py - About 50 mins to fix

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

          def eig(mpo, num_sweeps, var_sites=2,
          Severity: Major
          Found in mpnum/linalg.py - About 50 mins to fix

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

            def random_mpa(sites, ldim, rank, randstate=None, normalized=False,
            Severity: Major
            Found in mpnum/factory.py - About 50 mins to fix

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

              def random_mpo(sites, ldim, rank, randstate=None, hermitian=False,
              Severity: Major
              Found in mpnum/factory.py - About 50 mins to fix

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

                            self._lt.update(slice(site - 1, site + 1), newtens,
                                            canonicalization=(None, 'right'))
                Severity: Minor
                Found in mpnum/mparray.py and 1 other location - About 50 mins to fix
                mpnum/mparray.py on lines 928..929

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

                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

                            self._lt.update(slice(site - 1, site + 1), newtens,
                                            canonicalization=(None, 'right'))
                Severity: Minor
                Found in mpnum/mparray.py and 1 other location - About 50 mins to fix
                mpnum/mparray.py on lines 710..711

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

                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

                    order = tuple(it.chain(
                        range(left_skip), order, range(array.ndim - right_skip, array.ndim)))
                Severity: Minor
                Found in mpnum/utils/array_transforms.py and 1 other location - About 50 mins to fix
                mpnum/utils/array_transforms.py on lines 79..80

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

                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

                    @property
                    def outdims(self):
                        """Outcome dimensions"""
                        # First physical leg dimension
                        return tuple(lt.shape[1] for lt in self._lt)
                Severity: Minor
                Found in mpnum/povm/mppovm.py and 1 other location - About 50 mins to fix
                mpnum/povm/mppovm.py on lines 212..216

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

                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

                    order = tuple(it.chain(
                        range(left_skip), order, range(array.ndim - right_skip, array.ndim)))
                Severity: Minor
                Found in mpnum/utils/array_transforms.py and 1 other location - About 50 mins to fix
                mpnum/utils/array_transforms.py on lines 44..45

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

                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

                    @property
                    def hdims(self):
                        """Local Hilbert space dimensions"""
                        # Second physical leg dimension (equals third physical leg dimension)
                        return tuple(lt.shape[2] for lt in self._lt)
                Severity: Minor
                Found in mpnum/povm/mppovm.py and 1 other location - About 50 mins to fix
                mpnum/povm/mppovm.py on lines 196..200

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

                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

                Function _eig_sum_leftvec_add has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def _eig_sum_leftvec_add(
                Severity: Minor
                Found in mpnum/linalg.py - About 45 mins to fix

                  Function _eig_sum_rightvec_add has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def _eig_sum_rightvec_add(
                  Severity: Minor
                  Found in mpnum/linalg.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language