Class: Pest::DataSet::NArray::VectorEnumerable
- Inherits:
-
Object
- Object
- Pest::DataSet::NArray::VectorEnumerable
- Includes:
- Enumerable
- Defined in:
- lib/pest/data_set/narray.rb
Instance Method Summary collapse
- #[](i) ⇒ Object
- #each ⇒ Object
-
#initialize(data_set, variables = true) ⇒ VectorEnumerable
constructor
A new instance of VectorEnumerable.
Constructor Details
#initialize(data_set, variables = true) ⇒ VectorEnumerable
Returns a new instance of VectorEnumerable.
80 81 82 83 84 85 86 |
# File 'lib/pest/data_set/narray.rb', line 80 def initialize(data_set, variables = true) @data_set = data_set @variables = variables if @variables.kind_of?(Enumerable) @variables = variables.map {|v| @data_set.variable_array.index(v)} end end |
Instance Method Details
#[](i) ⇒ Object
88 89 90 |
# File 'lib/pest/data_set/narray.rb', line 88 def [](i) @data_set[i,@variables].transpose end |
#each ⇒ Object
92 93 94 95 96 |
# File 'lib/pest/data_set/narray.rb', line 92 def each (0..@data_set.shape[0]-1).each do |i| yield Array(self[i]).first end end |