File nmatrix.rb
has 547 lines of code (exceeds 250 allowed). Consider refactoring. Open
def jruby?
/java/ === RUBY_PLATFORM
end
if jruby?
Class NMatrix
has 56 methods (exceeds 20 allowed). Consider refactoring. Open
class NMatrix
# Read and write extensions for NMatrix.
module IO
extend AutoloadPatch
Method meshgrid
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def meshgrid(vectors, options = {})
raise(ArgumentError, 'Expected at least 2 arrays.') if vectors.size < 2
options[:indexing] ||= :xy
raise(ArgumentError, 'Indexing must be :xy of :ij') unless [:ij, :xy].include? options[:indexing]
mats = vectors.map { |arr| arr.respond_to?(:flatten) ? arr.flatten : arr.to_flat_array }
- Read upRead up
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 pretty_print
has a Cognitive Complexity of 18 (exceeds 5 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)
- Read upRead up
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 cast
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def cast(*params)
if (params.size > 0 && params[0].is_a?(Hash))
opts = {
:stype => self.stype,
:dtype => self.dtype,
- Read upRead up
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_hash
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def to_hash
if stype == :yale
h = {}
each_stored_with_indices do |val,i,j|
next if val == 0 # Don't bother storing the diagonal zero values -- only non-zeros.
- Read upRead up
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 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)
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
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
- Read upRead up
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 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)
Method concat
has a Cognitive Complexity of 10 (exceeds 5 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)
- Read upRead up
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 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|
- Read upRead up
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 rank
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def rank(shape_idx, rank_idx, meth = :copy)
if shape_idx > (self.dim-1)
raise(RangeError, "#rank call was out of bounds")
end
- Read upRead up
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"