SciRuby/nmatrix

View on GitHub

Showing 130 of 196 total issues

Method read_packed has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def read_packed(packedio, options)
        flags_class, self.nonzero_max = packedio.read([Element, options]).data

        self.matlab_class   = MatReader::MCLASSES[flags_class % 16]

Severity: Minor
Found in lib/nmatrix/io/mat5_reader.rb - About 1 hr to fix

    Method to_nm has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def to_nm(shape = nil, dtype = nil, stype = :dense)
        elements = self.dup
    
        guess_dtype = ->(type) {
          case type
    Severity: Minor
    Found in lib/nmatrix/monkeys.rb - About 1 hr to fix

      Method pretty_print has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def pretty_print(q) #:nodoc:
          if self.shape.size > 1 and self.shape[1] > 100
            self.inspect.pretty_print(q)
          elsif self.dim > 3 || self.dim == 1
            self.to_a.pretty_print(q)
      Severity: Minor
      Found in lib/nmatrix/nmatrix.rb - About 1 hr to fix

        Method transpose has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def transpose(permute = nil)
            if permute.nil?
              if self.dim == 1
                return self.clone
              elsif self.dim == 2
        Severity: Minor
        Found in lib/nmatrix/nmatrix.rb - About 1 hr to fix

          Method doubly_even_magic has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def doubly_even_magic(nm, shape)
                  mini_square_num = shape / 4
                  count = 1     
                  inv_count = shape * shape
                  shape.times do |row|
          Severity: Minor
          Found in lib/nmatrix/shortcuts.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method dense_storage_set has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def dense_storage_set(slice, right)
              stride = get_stride(self)
              v_size = 1
          
              if right.is_a?(NMatrix)
          Severity: Minor
          Found in lib/nmatrix/jruby/slice.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method solve has a Cognitive Complexity of 12 (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/lapacke.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method transpose has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def transpose(permute = nil)
              if permute.nil?
                if self.dim == 1
                  return self.clone
                elsif self.dim == 2
          Severity: Minor
          Found in lib/nmatrix/nmatrix.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method solve has a Cognitive Complexity of 12 (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/cruby/math.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method pow has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def pow n
              raise ShapeError, "Only works with 2D square matrices." if
                shape[0] != shape[1] or shape.size != 2
              raise TypeError, "Only works with integer powers" unless n.is_a?(Integer)
          
          
          Severity: Minor
          Found in lib/nmatrix/math.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method singly_even_magic has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def singly_even_magic(nm, shape)
                  half_shape = shape / 2
                  complementary_pair = (shape - 2) / 4
                  swap_col = NMatrix.new([shape])
                  index = 0 
          Severity: Minor
          Found in lib/nmatrix/shortcuts.rb - About 1 hr to fix

            Method cblas_syrk has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def cblas_syrk(order, uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
            Severity: Major
            Found in lib/nmatrix/blas.rb - About 1 hr to fix

              Method lapack_gesdd has 11 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def lapack_gesdd(jobz, m, n, a, lda, s, u, ldu, vt, ldvt, lwork)
              Severity: Major
              Found in lib/nmatrix/lapack_core.rb - About 1 hr to fix

                Method gemv has 11 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def gemv(a, x, y = nil, alpha = 1.0, beta = 0.0,
                             transpose_a = false, m = nil, n = nil, lda = nil,
                             incx = nil, incy = nil)
                Severity: Major
                Found in lib/nmatrix/blas.rb - About 1 hr to fix

                  Method cblas_herk has 11 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def cblas_herk(order, uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
                  Severity: Major
                  Found in lib/nmatrix/blas.rb - About 1 hr to fix

                    Method solve has 34 lines of code (exceeds 25 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/cruby/math.rb - About 1 hr to fix

                      Method gemm has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def gemm(a, b, c = nil, alpha = 1.0, beta = 0.0,
                                   transpose_a = false, transpose_b = false, m = nil,
                                   n = nil, k = nil, lda = nil, ldb = nil, ldc = nil)
                      
                            raise(ArgumentError, 'Expected dense NMatrices as first two arguments.') \
                      Severity: Minor
                      Found in lib/nmatrix/blas.rb - About 1 hr to fix

                        Method solve has 33 lines of code (exceeds 25 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/lapacke.rb - About 1 hr to fix

                          Method load_coordinate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def load_coordinate file, converter, dtype, entry_type, symmetry
                          
                                mat = nil
                          
                                # Read until we get the dimensions and nonzeros
                          Severity: Minor
                          Found in lib/nmatrix/io/market.rb - About 1 hr to fix

                            Method concat has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def concat(*matrices)
                                rank = nil
                                rank = matrices.pop unless matrices.last.is_a?(NMatrix)
                            
                                # Find the first matching dimension and concatenate along that (unless rank is specified)
                            Severity: Minor
                            Found in lib/nmatrix/nmatrix.rb - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language