Class: DTW::Sample
- Inherits:
-
Data
- Object
- Data
- DTW::Sample
- Defined in:
- lib/dtwrb/sample.rb,
sig/dtwrb.rbs
Instance Attribute Summary collapse
-
#dimension ⇒ Object
readonly
Returns the value of attribute dimension.
-
#scalar ⇒ Object
readonly
Returns the value of attribute scalar.
-
#sequences ⇒ Object
readonly
Returns the value of attribute sequences.
Class Method Summary collapse
Instance Method Summary collapse
- #count ⇒ ::Integer
- #mean_length ⇒ ::Integer
- #scalar? ⇒ Boolean
- #to_h ⇒ ::Hash[::Symbol, untyped]
- #with ⇒ Sample
Instance Attribute Details
#dimension ⇒ Object (readonly)
Returns the value of attribute dimension
4 5 6 |
# File 'lib/dtwrb/sample.rb', line 4 def dimension @dimension end |
#scalar ⇒ Object (readonly)
Returns the value of attribute scalar
4 5 6 |
# File 'lib/dtwrb/sample.rb', line 4 def scalar @scalar end |
#sequences ⇒ Object (readonly)
Returns the value of attribute sequences
4 5 6 |
# File 'lib/dtwrb/sample.rb', line 4 def sequences @sequences end |
Class Method Details
.new ⇒ Sample
65 |
# File 'sig/dtwrb.rbs', line 65
def self.new: (sequences: ::Array[frames], dimension: ::Integer, scalar: bool) -> Sample
|
.of(sequences) ⇒ Sample
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dtwrb/sample.rb', line 5 def self.of(sequences) usable = Sequence.compact(sequences) collection = usable.map { |sequence| Sequence.vectorize(sequence) } new( sequences: collection, dimension: Sequence.assert_uniform_dimension!(collection), scalar: usable.all? { |sequence| Sequence.scalar?(sequence) } ) end |
Instance Method Details
#count ⇒ ::Integer
16 |
# File 'lib/dtwrb/sample.rb', line 16 def count = sequences.length |
#mean_length ⇒ ::Integer
20 |
# File 'lib/dtwrb/sample.rb', line 20 def mean_length = [(sequences.sum(&:length).to_f / count).round, 1].max |
#scalar? ⇒ Boolean
18 |
# File 'lib/dtwrb/sample.rb', line 18 def scalar? = scalar |
#to_h ⇒ ::Hash[::Symbol, untyped]
70 |
# File 'sig/dtwrb.rbs', line 70
def to_h: () -> ::Hash[::Symbol, untyped]
|