<s> from __future__ import division , absolute_import <EOL> from unittest2 import TestCase <EOL> from yunomi . compat import xrange <EOL> from yunomi . core . histogram import Histogram <EOL> class HistogramTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . histogram_b = Histogram . get_biased ( ) <EOL> self . histogram_u = Histogram . get_uniform ( ) <EOL> def test_unique_biased_histogram ( self ) : <EOL> new_histogram = Histogram . get_biased ( ) <EOL> self . assertIsNot ( new_histogram . sample , self . histogram_b . sample ) <EOL> def test_unique_uniform_histogram ( self ) : <EOL> new_histogram = Histogram . get_uniform ( ) <EOL> self . assertIsNot ( new_histogram . sample , self . histogram_u . sample ) <EOL> def test_empty_histogram ( self ) : <EOL> for histogram in self . histogram_b , self . histogram_u : <EOL> histogram . clear ( ) <EOL> self . assertEqual ( histogram . get_count ( ) , <NUM_LIT:0> ) <EOL> self . assertAlmostEqual ( histogram . get_max ( ) , <NUM_LIT:0> ) <EOL> self . assertAlmostEqual ( histogram . get_min ( ) , <NUM_LIT:0> ) <EOL> self . assertAlmostEqual ( histogram . get_mean ( ) , <NUM_LIT:0> ) <EOL> self . assertAlmostEqual ( histogram . get_std_dev ( ) , <NUM_LIT:0> ) <EOL> self . assertAlmostEqual ( histogram . get_sum ( ) , <NUM_LIT:0> ) <EOL> snapshot = histogram . get_snapshot ( ) <EOL> self . assertAlmostEqual ( snapshot . get_median ( ) , <NUM_LIT:0> ) <EOL> self . assertAlmostEqual ( snapshot . get_75th_percentile ( ) , <NUM_LIT:0> ) <EOL> self . assertAlmostEqual ( snapshot . get_99th_percentile ( ) , <NUM_LIT:0> ) <EOL> self . assertAlmostEqual ( snapshot . size ( ) , <NUM_LIT:0> ) <EOL> def test_histogram_with_1000_elements ( self ) : <EOL> for histogram in self . histogram_b , self . histogram_u : <EOL> histogram . clear ( ) <EOL> for i in xrange ( <NUM_LIT:1> , <NUM_LIT> ) : <EOL> histogram . update ( i ) <EOL> self . assertEqual ( histogram . get_count ( ) , <NUM_LIT:1000> ) <EOL> self . assertAlmostEqual ( histogram . get_max ( ) , <NUM_LIT:1000> ) <EOL> self . assertAlmostEqual ( histogram . get_min ( ) , <NUM_LIT:1> ) <EOL> self . assertAlmostEqual ( histogram . get_mean ( ) , <NUM_LIT> ) <EOL> self . assertAlmostEqual ( histogram . get_std_dev ( ) , <NUM_LIT> , places = <NUM_LIT:3> ) <EOL> self . assertAlmostEqual ( histogram . get_sum ( ) , <NUM_LIT> ) <EOL> snapshot = histogram . get_snapshot ( ) <EOL> self . assertAlmostEqual ( snapshot . get_median ( ) , <NUM_LIT> ) <EOL> self . assertAlmostEqual ( snapshot . get_75th_percentile ( ) , <NUM_LIT> ) <EOL> self . assertAlmostEqual ( snapshot . get_99th_percentile ( ) , <NUM_LIT> ) <EOL> self . assertAlmostEqual ( snapshot . size ( ) , <NUM_LIT:1000> ) </s>
