<s> """<STR_LIT>""" <EOL> __authors__ = [ '<STR_LIT>' ] <EOL> import logging <EOL> try : <EOL> import numpy <EOL> except ImportError : <EOL> numpy = None <EOL> import random <EOL> import unittest <EOL> from viewfinder . backend . base import statistics , testing <EOL> @ unittest . skipIf ( numpy is None , '<STR_LIT>' ) <EOL> class FormatStatsTestCase ( testing . BaseTestCase ) : <EOL> def _RandomList ( self ) : <EOL> """<STR_LIT>""" <EOL> l = [ ] <EOL> for i in range ( random . randint ( <NUM_LIT:10> , <NUM_LIT:20> ) ) : <EOL> l . append ( random . randint ( <NUM_LIT:0> , <NUM_LIT:20> ) ) <EOL> print '<STR_LIT>' % l <EOL> return l <EOL> def testEmpty ( self ) : <EOL> self . assertEqual ( statistics . FormatStats ( [ ] ) , '<STR_LIT>' ) <EOL> def testSimple ( self ) : <EOL> """<STR_LIT>""" <EOL> a = self . _RandomList ( ) <EOL> out_str = '<STR_LIT>' % ( numpy . mean ( a ) , numpy . median ( a ) , numpy . std ( a ) ) <EOL> self . assertEqual ( statistics . FormatStats ( a ) , out_str ) <EOL> def testIndent ( self ) : <EOL> """<STR_LIT>""" <EOL> a = self . _RandomList ( ) <EOL> out_str = '<STR_LIT>' % ( numpy . mean ( a ) , numpy . median ( a ) , numpy . std ( a ) ) <EOL> self . assertEqual ( statistics . FormatStats ( a , indent = <NUM_LIT:3> ) , out_str ) <EOL> def testPercentile ( self ) : <EOL> """<STR_LIT>""" <EOL> a = self . _RandomList ( ) <EOL> p = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> out_str = '<STR_LIT>' % ( numpy . mean ( a ) , numpy . median ( a ) , numpy . std ( a ) ) <EOL> out_str += '<STR_LIT>' % numpy . percentile ( a , p ) <EOL> self . assertEqual ( statistics . FormatStats ( a , percentiles = p , indent = <NUM_LIT:3> ) , out_str ) <EOL> @ unittest . skipIf ( numpy is None , '<STR_LIT>' ) <EOL> class HistogramTestCase ( testing . BaseTestCase ) : <EOL> def testEmpty ( self ) : <EOL> self . assertEqual ( statistics . HistogramToASCII ( [ ] ) , '<STR_LIT>' ) <EOL> def testSimple ( self ) : <EOL> a = [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:4> ] <EOL> out_str = '<STR_LIT>' <EOL> out_str += '<STR_LIT>' <EOL> out_str += '<STR_LIT>' <EOL> self . assertEqual ( statistics . HistogramToASCII ( a , bins = <NUM_LIT:3> , indent = <NUM_LIT:2> , line_width = <NUM_LIT> ) , out_str ) <EOL> def testRounding ( self ) : <EOL> """<STR_LIT>""" <EOL> a = [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:4> ] <EOL> out_str = '<STR_LIT>' <EOL> out_str += '<STR_LIT>' <EOL> out_str += '<STR_LIT>' <EOL> out_str += '<STR_LIT>' <EOL> out_str += '<STR_LIT>' <EOL> self . assertEqual ( statistics . HistogramToASCII ( a , bins = <NUM_LIT:5> , indent = <NUM_LIT:2> , line_width = <NUM_LIT> ) , out_str ) </s>
