Sha256: b3371db10ee9a658f6ffe27b0edd4173806256d3f2cff22d3d15b99b02410bb6
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
require "flex_station_data/presenters/sample_csv" require "flex_station_data/presenters/linear_regression/sample_regression_hash" module FlexStationData module Presenters module LinearRegression class SampleHash include Concerns::Presenter attr_reader :times, :sample, :quality_control, :options def initialize(times, sample, quality_control: SampleQuality, **options) @times = times @sample = sample @quality_control = quality_control @options = options end def errors @errors ||= quality_control.call(sample, **options).reject(&:good?) end def errors? errors.present? end def errors_hash { "error" => errors.first&.to_s } end def wells_hash { "wells" => sample.readings.map(&:label).join(", ") } end def regression_hash return SampleRegressionHash.headers.zip([]).to_h if errors? SampleRegressionHash.present(times, sample.mean.values, **options).transform_values(&:first) end def present { "sample" => sample.label }.merge(wells_hash).merge(errors_hash).merge(regression_hash) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flex-station-data-0.3.1 | lib/flex_station_data/presenters/linear_regression/sample_hash.rb |
flex-station-data-0.3.0 | lib/flex_station_data/presenters/linear_regression/sample_hash.rb |