Class: Charty::VectorAdapters::NMatrixAdapter

Inherits:
BaseAdapter
  • Object
show all
Extended by:
Forwardable
Includes:
IndexSupport, NameSupport, Enumerable
Defined in:
lib/charty/vector_adapters/nmatrix_adapter.rb

Instance Attribute Summary

Attributes included from IndexSupport

#index

Attributes included from NameSupport

#name

Attributes inherited from BaseAdapter

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IndexSupport

#[], #[]=

Methods inherited from BaseAdapter

#==, adapter_name, #inverse_log_scale, #log_scale, #mean, #percentile, #stdev, #values_at, #where_in_array

Constructor Details

#initialize(data) ⇒ NMatrixAdapter

Returns a new instance of NMatrixAdapter.


13
14
15
16
# File 'lib/charty/vector_adapters/nmatrix_adapter.rb', line 13

def initialize(data)
  @data = check_data(data)
  self.index = index || RangeIndex.new(0 ... length)
end

Class Method Details

.supported?(data) ⇒ Boolean

Returns:

  • (Boolean)

9
10
11
# File 'lib/charty/vector_adapters/nmatrix_adapter.rb', line 9

def self.supported?(data)
  defined?(NMatrix) && data.is_a?(NMatrix)
end

Instance Method Details

#compare_data_equality(other) ⇒ Object


18
19
20
21
22
23
24
25
# File 'lib/charty/vector_adapters/nmatrix_adapter.rb', line 18

def compare_data_equality(other)
  case other
  when NMatrixAdapter
    data == other.data
  else
    data.to_a == other.data.to_a
  end
end