MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / test_sampler

Method test_sampler

tensorflow/python/eager/monitoring_test.py:83–101  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

81 self.assertTrue(gauge1.get_cell('foo').value())
82
83 def test_sampler(self):
84 buckets = monitoring.ExponentialBuckets(1.0, 2.0, 2)
85 sampler = monitoring.Sampler('test/sampler', buckets, 'test sampler')
86 sampler.get_cell().add(1.0)
87 sampler.get_cell().add(5.0)
88 histogram_proto = sampler.get_cell().value()
89 self.assertEqual(histogram_proto.min, 1.0)
90 self.assertEqual(histogram_proto.num, 2.0)
91 self.assertEqual(histogram_proto.sum, 6.0)
92
93 sampler1 = monitoring.Sampler('test/sampler1', buckets, 'test sampler',
94 'label1')
95 sampler1.get_cell('foo').add(2.0)
96 sampler1.get_cell('foo').add(4.0)
97 sampler1.get_cell('bar').add(8.0)
98 histogram_proto1 = sampler1.get_cell('foo').value()
99 self.assertEqual(histogram_proto1.max, 4.0)
100 self.assertEqual(histogram_proto1.num, 2.0)
101 self.assertEqual(histogram_proto1.sum, 6.0)
102
103
104if __name__ == '__main__':

Callers

nothing calls this directly

Calls 5

get_cellMethod · 0.95
ExponentialBucketsMethod · 0.80
SamplerMethod · 0.45
addMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected