lib/flex_station_data/sample.rb in flex-station-data-0.3.1 vs lib/flex_station_data/sample.rb in flex-station-data-0.3.2
- old
+ new
@@ -1,16 +1,29 @@
-require "flex_station_data/readings"
+require "matrix"
+require "flex_station_data/services/compute_mean"
+
module FlexStationData
class Sample
- attr_reader :label, :readings
+ attr_reader :label, :wells, :plate
- def initialize(label, readings)
+ delegate :wells, to: :plate, prefix: true
+
+ def initialize(label, wells, plate)
@label = label
- @readings = readings
+ @wells = wells
+ @plate = plate
end
+ def values
+ wells.map(&plate_wells.method(:values))
+ end
+
+ def readings
+ @readings ||= wells.zip(values).map { |well, v| Readings.new(well, v) }
+ end
+
def mean
- @mean ||= Readings.mean(*readings)
+ @mean ||= values.transpose.map(&ComputeMean)
end
end
end