#NEWLINE# def check_moment( distfn , arg , m , v , msg ) : #NEWLINE# #INDENT# m1 = distfn . moment ( 1 , * arg ) #NEWLINE# m2 = distfn . moment ( 2 , * arg ) #NEWLINE# if ( not np . isinf ( m ) ) : #NEWLINE# #INDENT# npt . assert_almost_equal ( m1 , m , decimal = 10 , err_msg = ( msg + ' - 1st moment' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# npt . assert_ ( np . isinf ( m1 ) , ( msg + ( ' - 1st moment -infinite, m1=%s' % str ( m1 ) ) ) ) #NEWLINE# #UNINDENT# if ( not np . isinf ( v ) ) : #NEWLINE# #INDENT# npt . assert_almost_equal ( ( m2 - ( m1 * m1 ) ) , v , decimal = 10 , err_msg = ( msg + ' - 2ndt moment' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# npt . assert_ ( np . isinf ( m2 ) , ( msg + ( ' - 2nd moment -infinite, m2=%s' % str ( m2 ) ) ) )