Skip to content

Commit

Permalink
chore: cleanup rubocop and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jozefvaclavik committed Feb 19, 2024
1 parent 1b4eb3f commit 1a8eb69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/trifle/stats/transponder/standard_deviation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ def transpond(series:, path:) # rubocop:disable Metrics/AbcSize, Metrics/MethodL
dcount = data.dig(*keys, count)
dsquare = data.dig(*keys, square)
dsum = data.dig(*keys, sum)
# sd = Math.sqrt((dcount * dsquare - dsum * dsum) / (dcount * (dcount - 1)))
signal = {
"#{path}.sd" => Math.sqrt(
(dcount * dsquare - dsum * dsum) / (dcount * (dcount - 1))
(dcount * dsquare - dsum * dsum) / (dcount * (dcount - 1)) # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
)
}
self.class.deep_merge(data, self.class.unpack(hash: signal))
Expand Down
13 changes: 13 additions & 0 deletions spec/stats/mixins/packer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,17 @@ class PackerWrapper
expect(PackerWrapper.unpack(hash: hash_nested)).to eq({'a' => 1, 'b' => {'c' => 22, 'd' => 33, 'e' => {'f' => 444}, 'g' => 55}, 'h' => 6})
end
end

describe 'Normalize' do
let(:symbol_hash) { {a: 1, b: 2, c: 3} }
let(:string_hash) { {'a' => 1, 'b' => 2, 'c' => 3} }

it 'normalize symbol hash' do
expect(PackerWrapper.normalize(symbol_hash)).to eq({'a' => 1, 'b' => 2, 'c' => 3})
end

it 'normalize string hash' do
expect(PackerWrapper.normalize(string_hash)).to eq({'a' => 1, 'b' => 2, 'c' => 3})
end
end
end

0 comments on commit 1a8eb69

Please sign in to comment.