SciRuby/nmatrix

View on GitHub

Showing 196 of 196 total issues

Method unmqr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def unmqr(tau, side=:left, transpose=false, c=nil)
    raise(StorageTypeError, "ATLAS functions only work on dense matrices") unless self.dense?
    raise(TypeError, "Works only on complex matrices, use ormqr for normal floating point matrices") unless self.complex_dtype?
    raise(TypeError, "c must have the same dtype as the calling NMatrix") if c and c.dtype != self.dtype

Severity: Minor
Found in lib/nmatrix/lapacke.rb - About 45 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

Method svd_rank has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def svd_rank(tolerence="default")
    raise(ShapeError, "rank calculated only for 2-D matrices") unless
      self.dim == 2 

    sigmas = self.gesvd[1].to_a.flatten
Severity: Minor
Found in lib/nmatrix/math.rb - About 45 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

  def potrf!(which)
    raise(StorageTypeError, "LAPACK functions only work on dense matrices") unless self.dense?
    raise(ShapeError, "Cholesky decomposition only valid for square matrices") unless self.dim == 2 && self.shape[0] == self.shape[1]

    NMatrix::LAPACK::lapacke_potrf(:row, which, self.shape[0], self, self.shape[1])
Severity: Minor
Found in lib/nmatrix/lapacke.rb and 1 other location - About 45 mins to fix
lib/nmatrix/atlas.rb on lines 236..242

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

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 potrf!(which)
    raise(StorageTypeError, "ATLAS functions only work on dense matrices") \
     unless self.dense?
    raise(ShapeError, "Cholesky decomposition only valid for square matrices") \
     unless self.dim == 2 && self.shape[0] == self.shape[1]
Severity: Minor
Found in lib/nmatrix/atlas.rb and 1 other location - About 45 mins to fix
lib/nmatrix/lapacke.rb on lines 191..195

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

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

    def logspace(base, limit, shape = [50], exponent_base: 10)

      #Calculate limit for [10 ^ base ... Math::PI] if limit = :pi
      limit = Math.log(Math::PI, exponent_base = 10) if limit == :pi 
      shape = [shape] if shape.is_a? Integer
Severity: Minor
Found in lib/nmatrix/shortcuts.rb and 1 other location - About 40 mins to fix
lib/nmatrix/shortcuts.rb on lines 798..806

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

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

    def logspace(base, limit, shape = [50], exponent_base: 10)

      #Calculate limit for [10 ^ base ... Math::PI] if limit = :pi
      limit = Math.log(Math::PI, exponent_base = 10) if limit == :pi 
      shape = [shape] if shape.is_a? Integer
Severity: Minor
Found in lib/nmatrix/shortcuts.rb and 1 other location - About 40 mins to fix
lib/nmatrix/shortcuts.rb on lines 698..706

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

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

Consider simplifying this complex logical expression.
Open

    if (right_v.is_a?(NMatrix) && self.stype == :dense && right_v.stype == :dense &&
        self.dim == 2 && right_v.dim == 2 && self.shape[1] == right_v.shape[0])

      result_dtype = NMatrix.upcast(self.dtype,right_v.dtype)
      left = self.dtype == result_dtype ? self : self.cast(dtype: result_dtype)
Severity: Major
Found in lib/nmatrix/lapack_ext_common.rb - About 40 mins to fix

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

        define_method("__yale_elementwise_#{ewop}__") do |rhs, order|
          if order then
            self.__yale_map_merged_stored__(rhs, nil) { |r,l| Math.send(ewop,l,r) }
          else
            self.__yale_map_merged_stored__(rhs, nil) { |l,r| Math.send(ewop,l,r) }
    Severity: Minor
    Found in lib/nmatrix/math.rb and 1 other location - About 40 mins to fix
    lib/nmatrix/math.rb on lines 876..881

    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

        define_method("__list_elementwise_#{ewop}__") do |rhs,order|
          if order then
            self.__list_map_merged_stored__(rhs, nil) { |r,l| Math.send(ewop,l,r) }
          else
            self.__list_map_merged_stored__(rhs, nil) { |l,r| Math.send(ewop,l,r) }
    Severity: Minor
    Found in lib/nmatrix/math.rb and 1 other location - About 40 mins to fix
    lib/nmatrix/math.rb on lines 892..897

    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

    Method clapack_potrf has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def clapack_potrf(order, uplo, n, a, lda)
    Severity: Minor
    Found in lib/nmatrix/lapack_core.rb - About 35 mins to fix

      Method clapack_getri has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def clapack_getri(order, n, a, lda, ipiv)
      Severity: Minor
      Found in lib/nmatrix/lapack_core.rb - About 35 mins to fix

        Method dense_storage_coords has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def dense_storage_coords(s, slice_pos, coords_out, stride, offset)  #array, int, array
        Severity: Minor
        Found in lib/nmatrix/jruby/slice.rb - About 35 mins to fix

          Method load_array has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def load_array file, converter, dtype, entry_type, symmetry
          Severity: Minor
          Found in lib/nmatrix/io/market.rb - About 35 mins to fix

            Method clapack_potri has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def clapack_potri(order, uplo, n, a, lda)
            Severity: Minor
            Found in lib/nmatrix/lapack_core.rb - About 35 mins to fix

              Method load_coordinate has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def load_coordinate file, converter, dtype, entry_type, symmetry
              Severity: Minor
              Found in lib/nmatrix/io/market.rb - About 35 mins to fix

                Method ormqr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def ormqr(tau, side=:left, transpose=false, c=nil)
                    raise(StorageTypeError, "LAPACK functions only work on dense matrices") unless self.dense?
                    raise(TypeError, "Works only on floating point matrices, use unmqr for complex types") if self.complex_dtype?
                    raise(TypeError, "c must have the same dtype as the calling NMatrix") if c and c.dtype != self.dtype
                
                
                Severity: Minor
                Found in lib/nmatrix/lapacke.rb - About 35 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

                Method matrix_norm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def matrix_norm type = 2
                    raise(NotImplementedError, "norm can be calculated only for 2D matrices") unless self.dim == 2
                    raise(NotImplementedError, "norm only implemented for dense storage") unless self.stype == :dense
                    raise(ArgumentError, "norm not defined for byte dtype")if self.dtype == :byte
                    case type
                Severity: Minor
                Found in lib/nmatrix/math.rb - About 35 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

                Method / has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def /(other)
                    result = create_dummy_nmatrix
                    if (other.is_a?(NMatrix))
                      #check dimension
                      raise(ShapeError, "Cannot divide matrices with different dimension") if (@dim != other.dim)
                Severity: Minor
                Found in lib/nmatrix/jruby/operators.rb - About 35 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

                Method set_input has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def set_input ip
                        raise ArgumentError, "stype must be dense." if ip.stype != :dense
                        raise ArgumentError, "size of input (#{ip.size}) cannot be greater than planned input size #{@size}" if
                          ip.size != @size
                        
                Severity: Minor
                Found in lib/nmatrix/fftw.rb - About 35 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

                Method load_array has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def load_array file, converter, dtype, entry_type, symmetry
                      mat = nil
                
                      line = file.gets
                      line.chomp!
                Severity: Minor
                Found in lib/nmatrix/io/market.rb - About 35 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

                Severity
                Category
                Status
                Source
                Language