SciRuby/nmatrix

View on GitHub

Showing 196 of 196 total issues

Method slice_set has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def slice_set(dest, lengths, pdest, rank, v, v_size, v_offset)
Severity: Major
Found in lib/nmatrix/jruby/slice.rb - About 50 mins to fix

    Method rot! has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def rot!(x, y, c, s, incx = 1, incy = 1, n = nil)
    Severity: Major
    Found in lib/nmatrix/blas.rb - About 50 mins to fix

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

          def linspace(base, limit, shape = [100])
            
            # Convert shape to array format 
            shape = [shape] if shape.is_a? Integer 
            
      Severity: Minor
      Found in lib/nmatrix/shortcuts.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/shortcuts.rb on lines 644..658

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

      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 linspace(base, limit, shape = [100])
            
            # Convert shape to array format 
            shape = [shape] if shape.is_a? Integer 
            
      Severity: Minor
      Found in lib/nmatrix/shortcuts.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/shortcuts.rb on lines 744..758

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

      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 max(dimen=0)
          inject_rank(dimen) do |max, sub_mat|
            if max.is_a? NMatrix then
              max * (max >= sub_mat).cast(self.stype, self.dtype) + ((max)*0.0 + (max < sub_mat).cast(self.stype, self.dtype)) * sub_mat
            else
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/math.rb on lines 526..532

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

      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 min(dimen=0)
          inject_rank(dimen) do |min, sub_mat|
            if min.is_a? NMatrix then
              min * (min <= sub_mat).cast(self.stype, self.dtype) + ((min)*0.0 + (min > sub_mat).cast(self.stype, self.dtype)) * sub_mat
            else
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/math.rb on lines 545..551

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

      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 3 locations. Consider refactoring.
      Open

        def atan2(other, scalar=false)
          result = create_dummy_nmatrix
          if scalar
            result.s = ArrayRealVector.new MathHelper.atan2Scalar(other, @s.toArray)
          else
      Severity: Major
      Found in lib/nmatrix/jruby/operators.rb and 2 other locations - About 50 mins to fix
      lib/nmatrix/jruby/operators.rb on lines 95..106
      lib/nmatrix/jruby/operators.rb on lines 109..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 42.

      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("__dense_unary_#{meth}__") do
            return_dtype = dtype_for_floor_or_ceil
      
            if [:complex64, :complex128].include?(self.dtype)
              self.__dense_map__ { |l| Complex(l.real.send(meth), l.imag.send(meth)) }.cast(stype, return_dtype)
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/math.rb on lines 851..857

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

      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("__yale_unary_#{meth}__") do
            return_dtype = dtype_for_floor_or_ceil
      
            if [:complex64, :complex128].include?(self.dtype)
              self.__yale_map_stored__ { |l| Complex(l.real.send(meth), l.imag.send(meth)) }.cast(stype, return_dtype)
      Severity: Minor
      Found in lib/nmatrix/math.rb and 1 other location - About 50 mins to fix
      lib/nmatrix/math.rb on lines 861..867

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

      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 3 locations. Consider refactoring.
      Open

        def ldexp(other, scalar=false)
          result = create_dummy_nmatrix
          if scalar
            result.s = ArrayRealVector.new MathHelper.ldexpScalar(other, @s.toArray)
          else
      Severity: Major
      Found in lib/nmatrix/jruby/operators.rb and 2 other locations - About 50 mins to fix
      lib/nmatrix/jruby/operators.rb on lines 81..92
      lib/nmatrix/jruby/operators.rb on lines 109..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 42.

      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 3 locations. Consider refactoring.
      Open

        def hypot(other, scalar=false)
          result = create_dummy_nmatrix
          if scalar
            result.s = ArrayRealVector.new MathHelper.hypotScalar(other, @s.toArray)
          else
      Severity: Major
      Found in lib/nmatrix/jruby/operators.rb and 2 other locations - About 50 mins to fix
      lib/nmatrix/jruby/operators.rb on lines 81..92
      lib/nmatrix/jruby/operators.rb on lines 95..106

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

      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 slice_copy has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def slice_copy(src, dest,lengths, pdest, psrc,n)
      Severity: Minor
      Found in lib/nmatrix/jruby/slice.rb - About 45 mins to fix

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

          def binned_sorted_indices
            return method_missing(:sorted_indices) unless vector?
            ary = self.to_flat_array
            ary2 = []
            last_bin = ary.each_index.sort_by { |i| [ary[i]] }.inject([]) do |result, element|
        Severity: Minor
        Found in lib/nmatrix/nmatrix.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 inv_hilbert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def inv_hilbert(shape, opts={})
              opts = {:dtype => :float64}.merge(opts)
              m = NMatrix.new([shape,shape],opts)
              combination = NMatrix.new([2*shape,2*shape],opts)
              #combinations refers to the combination of n things taken k at a time
        Severity: Minor
        Found in lib/nmatrix/shortcuts.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

        Avoid deeply nested control flow statements.
        Open

                    if args[1].is_a?(Symbol)
                      hash = args[1]
                      @dtype = hash[:dtype]
                      @stype = hash[:stype]
                      elements = Array.new(shape*shape) unless shape.is_a? Array
        Severity: Major
        Found in lib/nmatrix/jruby/nmatrix_java.rb - About 45 mins to fix

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

            def solve(b, opts = {})
              raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
              raise(ShapeError, "number of rows of b must equal number of cols of self") if
                self.shape[1] != b.shape[0]
              raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
          Severity: Minor
          Found in lib/nmatrix/jruby/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

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

              def save(matrix, filename, options = {})
                options = {:pattern => false,
                  :symmetry => :general}.merge(options)
          
                mode = matrix.stype == :dense ? :array : :coordinate
          Severity: Minor
          Found in lib/nmatrix/io/market.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 factorize_qr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def factorize_qr
              raise(NotImplementedError, "only implemented for dense storage") unless self.stype == :dense
              raise(ShapeError, "Input must be a 2-dimensional matrix to have a QR decomposition") unless self.dim == 2
          
              rows, columns = self.shape
          Severity: Minor
          Found in lib/nmatrix/cruby/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

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

                def to_nm(dtype = nil)
                  # Hardest part is figuring out from_dtype, from_index_dtype, and dtype.
                  dtype   ||= guess_dtype_from_mdtype
                  from_dtype = MatReader::MDTYPE_TO_DTYPE[self.real_part.tag.data_type]
          
          
          Severity: Minor
          Found in lib/nmatrix/io/mat5_reader.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 each_stored_with_index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def each_stored_with_index(&block)
              raise(NotImplementedError, "only works for dim 2 vectors") unless self.dim <= 2
              return enum_for(:each_stored_with_index) unless block_given?
          
              self.each_stored_with_indices do |v, i, j|
          Severity: Minor
          Found in lib/nmatrix/enumerate.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

          Severity
          Category
          Status
          Source
          Language