<s> """<STR_LIT>""" <EOL> import copy <EOL> import numpy as np <EOL> from numpy . testing import ( assert_almost_equal , assert_allclose , assert_raises , <EOL> assert_equal , assert_warns ) <EOL> import statsmodels . stats . power as smp <EOL> import warnings <EOL> from statsmodels . stats . tests . test_weightstats import Holder <EOL> import nose <EOL> from numpy . testing import dec <EOL> try : <EOL> import matplotlib . pyplot as plt <EOL> have_matplotlib = True <EOL> except ImportError : <EOL> have_matplotlib = False <EOL> class CheckPowerMixin ( object ) : <EOL> def test_power ( self ) : <EOL> kwds = copy . copy ( self . kwds ) <EOL> del kwds [ '<STR_LIT>' ] <EOL> kwds . update ( self . kwds_extra ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> decimal = self . decimal <EOL> else : <EOL> decimal = <NUM_LIT:6> <EOL> res1 = self . cls ( ) <EOL> assert_almost_equal ( res1 . power ( ** kwds ) , self . res2 . power , decimal = decimal ) <EOL> def test_positional ( self ) : <EOL> res1 = self . cls ( ) <EOL> kwds = copy . copy ( self . kwds ) <EOL> del kwds [ '<STR_LIT>' ] <EOL> kwds . update ( self . kwds_extra ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> args_names = self . args_names <EOL> else : <EOL> nobs_ = '<STR_LIT>' if '<STR_LIT>' in kwds else '<STR_LIT>' <EOL> args_names = [ '<STR_LIT>' , nobs_ , '<STR_LIT>' ] <EOL> args = [ kwds . pop ( arg ) for arg in args_names ] <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> decimal = self . decimal <EOL> else : <EOL> decimal = <NUM_LIT:6> <EOL> res = res1 . power ( * args , ** kwds ) <EOL> assert_almost_equal ( res , self . res2 . power , decimal = decimal ) <EOL> def test_roots ( self ) : <EOL> kwds = copy . copy ( self . kwds ) <EOL> kwds . update ( self . kwds_extra ) <EOL> for key in self . kwds : <EOL> value = kwds [ key ] <EOL> kwds [ key ] = None <EOL> result = self . cls ( ) . solve_power ( ** kwds ) <EOL> assert_allclose ( result , value , rtol = <NUM_LIT> , err_msg = key + '<STR_LIT>' ) <EOL> kwds [ key ] = value <EOL> @ dec . skipif ( not have_matplotlib ) <EOL> def test_power_plot ( self ) : <EOL> if self . cls == smp . FTestPower : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> fig = plt . figure ( ) <EOL> ax = fig . add_subplot ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> fig = self . cls ( ) . plot_power ( dep_var = '<STR_LIT>' , <EOL> nobs = np . arange ( <NUM_LIT:2> , <NUM_LIT:100> ) , <EOL> effect_size = np . array ( [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT:1> ] ) , <EOL> ax = ax , title = '<STR_LIT>' , <EOL> ** self . kwds_extra ) <EOL> ax = fig . add_subplot ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> fig = self . cls ( ) . plot_power ( dep_var = '<STR_LIT>' , <EOL> nobs = np . array ( [ <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> , <NUM_LIT:50> , <NUM_LIT> , <NUM_LIT:100> ] ) , <EOL> effect_size = np . linspace ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT> ) , <EOL> ax = ax , title = '<STR_LIT>' , <EOL> ** self . kwds_extra ) <EOL> plt . close ( '<STR_LIT:all>' ) <EOL> class TestTTPowerOneS1 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:30> <EOL> res2 . d = <NUM_LIT:1> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { } <EOL> self . cls = smp . TTestPower <EOL> class TestTTPowerOneS2 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:20> <EOL> res2 . d = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '''<STR_LIT>''' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { } <EOL> self . cls = smp . TTestPower <EOL> class TestTTPowerOneS3 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:30> <EOL> res2 . d = <NUM_LIT:1> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . TTestPower <EOL> class TestTTPowerOneS4 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:20> <EOL> res2 . d = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '''<STR_LIT>''' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . TTestPower <EOL> class TestTTPowerOneS5 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:20> <EOL> res2 . d = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '''<STR_LIT>''' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . TTestPower <EOL> class TestTTPowerOneS6 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:20> <EOL> res2 . d = - <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '''<STR_LIT>''' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . TTestPower <EOL> class TestTTPowerTwoS1 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:30> <EOL> res2 . d = <NUM_LIT:1> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power , '<STR_LIT>' : <NUM_LIT:1> } <EOL> self . kwds_extra = { } <EOL> self . cls = smp . TTestIndPower <EOL> class TestTTPowerTwoS2 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:20> <EOL> res2 . d = <NUM_LIT:0.1> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power , '<STR_LIT>' : <NUM_LIT:1> } <EOL> self . kwds_extra = { } <EOL> self . cls = smp . TTestIndPower <EOL> class TestTTPowerTwoS3 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:30> <EOL> res2 . d = <NUM_LIT:1> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power , '<STR_LIT>' : <NUM_LIT:1> } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . TTestIndPower <EOL> class TestTTPowerTwoS4 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT:30> <EOL> res2 . d = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . TTestIndPower <EOL> class TestTTPowerTwoS5 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n1 = <NUM_LIT:20> <EOL> res2 . n2 = <NUM_LIT:30> <EOL> res2 . d = <NUM_LIT:0.1> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n1 , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power , '<STR_LIT>' : <NUM_LIT> } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . TTestIndPower <EOL> class TestTTPowerTwoS6 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n1 = <NUM_LIT:20> <EOL> res2 . n2 = <NUM_LIT:30> <EOL> res2 . d = <NUM_LIT:0.1> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n1 , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power , '<STR_LIT>' : <NUM_LIT> } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . TTestIndPower <EOL> def test_normal_power_explicit ( ) : <EOL> sigma = <NUM_LIT:1> <EOL> d = <NUM_LIT> <EOL> nobs = <NUM_LIT> <EOL> alpha = <NUM_LIT> <EOL> res1 = smp . normal_power ( d , nobs / <NUM_LIT> , <NUM_LIT> ) <EOL> res2 = smp . NormalIndPower ( ) . power ( d , nobs , <NUM_LIT> ) <EOL> res3 = smp . NormalIndPower ( ) . solve_power ( effect_size = <NUM_LIT> , nobs1 = <NUM_LIT> , alpha = <NUM_LIT> , power = None ) <EOL> res_R = <NUM_LIT> <EOL> assert_almost_equal ( res1 , res_R , decimal = <NUM_LIT> ) <EOL> assert_almost_equal ( res2 , res_R , decimal = <NUM_LIT> ) <EOL> assert_almost_equal ( res3 , res_R , decimal = <NUM_LIT> ) <EOL> norm_pow = smp . normal_power ( - <NUM_LIT> , nobs / <NUM_LIT> , <NUM_LIT> ) <EOL> norm_pow_R = <NUM_LIT> <EOL> assert_almost_equal ( norm_pow , norm_pow_R , decimal = <NUM_LIT:11> ) <EOL> norm_pow = smp . NormalIndPower ( ) . power ( <NUM_LIT> , nobs , <NUM_LIT> , <EOL> alternative = "<STR_LIT>" ) <EOL> norm_pow_R = <NUM_LIT> <EOL> assert_almost_equal ( norm_pow , norm_pow_R , decimal = <NUM_LIT:11> ) <EOL> norm_pow = smp . NormalIndPower ( ) . power ( - <NUM_LIT> , nobs , <NUM_LIT> , <EOL> alternative = "<STR_LIT>" ) <EOL> norm_pow_R = <NUM_LIT> <EOL> assert_almost_equal ( norm_pow , norm_pow_R , decimal = <NUM_LIT:11> ) <EOL> class TestNormalIndPower1 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT> <EOL> res2 . d = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power , '<STR_LIT>' : <NUM_LIT:1> } <EOL> self . kwds_extra = { } <EOL> self . cls = smp . NormalIndPower <EOL> class TestNormalIndPower2 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . h = <NUM_LIT> <EOL> res2 . n = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . method = ( '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> res2 . note = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . h , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power , '<STR_LIT>' : <NUM_LIT:1> } <EOL> self . kwds_extra = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . NormalIndPower <EOL> class TestNormalIndPower_onesamp1 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . n = <NUM_LIT> <EOL> res2 . d = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : <NUM_LIT:0> } <EOL> self . cls = smp . NormalIndPower <EOL> class TestNormalIndPower_onesamp2 ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . d = <NUM_LIT> <EOL> res2 . n = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . alternative = '<STR_LIT>' <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . d , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : '<STR_LIT>' } <EOL> self . cls = smp . NormalIndPower <EOL> class TestChisquarePower ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . w = <NUM_LIT:0.1> <EOL> res2 . N = <NUM_LIT:5> <EOL> res2 . df = <NUM_LIT:4> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . method = '<STR_LIT>' <EOL> res2 . note = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . w , '<STR_LIT>' : res2 . N , <EOL> '<STR_LIT>' : res2 . sig_level , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : res2 . df + <NUM_LIT:1> } <EOL> self . cls = smp . GofChisquarePower <EOL> def _test_positional ( self ) : <EOL> res1 = self . cls ( ) <EOL> args_names = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> kwds = copy . copy ( self . kwds ) <EOL> del kwds [ '<STR_LIT>' ] <EOL> kwds . update ( self . kwds_extra ) <EOL> args = [ kwds [ arg ] for arg in args_names ] <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> decimal = self . decimal <EOL> else : <EOL> decimal = <NUM_LIT:6> <EOL> assert_almost_equal ( res1 . power ( * args ) , self . res2 . power , decimal = decimal ) <EOL> def test_ftest_power ( ) : <EOL> for alpha in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] : <EOL> res0 = smp . ttest_power ( <NUM_LIT> , <NUM_LIT:200> , alpha ) <EOL> res1 = smp . ftest_power ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , alpha = alpha , ncc = <NUM_LIT:0> ) <EOL> assert_almost_equal ( res1 , res0 , decimal = <NUM_LIT:6> ) <EOL> res1 = smp . ftest_anova_power ( <NUM_LIT> , <NUM_LIT:200> , <NUM_LIT> , k_groups = <NUM_LIT:10> ) <EOL> res0 = <NUM_LIT> <EOL> assert_almost_equal ( res1 , res0 , decimal = <NUM_LIT:4> ) <EOL> res2 = Holder ( ) <EOL> res2 . u = <NUM_LIT:5> <EOL> res2 . v = <NUM_LIT> <EOL> res2 . f2 = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . method = '<STR_LIT>' <EOL> res1 = smp . ftest_power ( np . sqrt ( res2 . f2 ) , res2 . v , res2 . u , <EOL> alpha = res2 . sig_level , ncc = <NUM_LIT:1> ) <EOL> assert_almost_equal ( res1 , res2 . power , decimal = <NUM_LIT:5> ) <EOL> res2 = Holder ( ) <EOL> res2 . u = <NUM_LIT:5> <EOL> res2 . v = <NUM_LIT> <EOL> res2 . f2 = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . method = '<STR_LIT>' <EOL> res1 = smp . ftest_power ( np . sqrt ( res2 . f2 ) , res2 . v , res2 . u , <EOL> alpha = res2 . sig_level , ncc = <NUM_LIT:1> ) <EOL> assert_almost_equal ( res1 , res2 . power , decimal = <NUM_LIT:5> ) <EOL> res2 = Holder ( ) <EOL> res2 . u = <NUM_LIT:5> <EOL> res2 . v = <NUM_LIT> <EOL> res2 . f2 = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT:0.1> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . method = '<STR_LIT>' <EOL> res1 = smp . ftest_power ( np . sqrt ( res2 . f2 ) , res2 . v , res2 . u , <EOL> alpha = res2 . sig_level , ncc = <NUM_LIT:1> ) <EOL> assert_almost_equal ( res1 , res2 . power , decimal = <NUM_LIT:5> ) <EOL> class TestFtestAnovaPower ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . f = <NUM_LIT> <EOL> res2 . n = <NUM_LIT:200> <EOL> res2 . k = <NUM_LIT:10> <EOL> res2 . alpha = <NUM_LIT> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : res2 . f , '<STR_LIT>' : res2 . n , <EOL> '<STR_LIT>' : res2 . alpha , '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { '<STR_LIT>' : res2 . k } <EOL> self . cls = smp . FTestAnovaPower <EOL> self . decimal = <NUM_LIT:4> <EOL> class TestFtestPower ( CheckPowerMixin ) : <EOL> def __init__ ( self ) : <EOL> res2 = Holder ( ) <EOL> res2 . u = <NUM_LIT:5> <EOL> res2 . v = <NUM_LIT> <EOL> res2 . f2 = <NUM_LIT> <EOL> res2 . sig_level = <NUM_LIT:0.1> <EOL> res2 . power = <NUM_LIT> <EOL> res2 . method = '<STR_LIT>' <EOL> self . res2 = res2 <EOL> self . kwds = { '<STR_LIT>' : np . sqrt ( res2 . f2 ) , '<STR_LIT>' : res2 . v , <EOL> '<STR_LIT>' : res2 . u , '<STR_LIT>' : res2 . sig_level , <EOL> '<STR_LIT>' : res2 . power } <EOL> self . kwds_extra = { } <EOL> self . args_names = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . cls = smp . FTestPower <EOL> self . decimal = <NUM_LIT:5> <EOL> def test_power_solver ( ) : <EOL> nip = smp . NormalIndPower ( ) <EOL> es0 = <NUM_LIT:0.1> <EOL> pow_ = nip . solve_power ( es0 , nobs1 = <NUM_LIT> , alpha = <NUM_LIT> , power = None , ratio = <NUM_LIT:1> , <EOL> alternative = '<STR_LIT>' ) <EOL> assert_almost_equal ( pow_ , <NUM_LIT> , decimal = <NUM_LIT:5> ) <EOL> es = nip . solve_power ( None , nobs1 = <NUM_LIT> , alpha = <NUM_LIT> , power = pow_ , ratio = <NUM_LIT:1> , <EOL> alternative = '<STR_LIT>' ) <EOL> assert_almost_equal ( es , es0 , decimal = <NUM_LIT:4> ) <EOL> assert_equal ( nip . cache_fit_res [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> assert_equal ( len ( nip . cache_fit_res ) , <NUM_LIT:2> ) <EOL> nip . start_bqexp [ '<STR_LIT>' ] = { '<STR_LIT>' : - <NUM_LIT:10> , '<STR_LIT>' : - <NUM_LIT:20> } <EOL> nip . start_ttp [ '<STR_LIT>' ] = <NUM_LIT> <EOL> es = nip . solve_power ( None , nobs1 = <NUM_LIT> , alpha = <NUM_LIT> , power = pow_ , ratio = <NUM_LIT:1> , <EOL> alternative = '<STR_LIT>' ) <EOL> assert_almost_equal ( es , es0 , decimal = <NUM_LIT:4> ) <EOL> assert_equal ( nip . cache_fit_res [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> assert_equal ( len ( nip . cache_fit_res ) , <NUM_LIT:3> , err_msg = repr ( nip . cache_fit_res ) ) <EOL> nip . start_ttp [ '<STR_LIT>' ] = np . nan <EOL> es = nip . solve_power ( None , nobs1 = <NUM_LIT> , alpha = <NUM_LIT> , power = pow_ , ratio = <NUM_LIT:1> , <EOL> alternative = '<STR_LIT>' ) <EOL> assert_almost_equal ( es , es0 , decimal = <NUM_LIT:4> ) <EOL> assert_equal ( nip . cache_fit_res [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> assert_equal ( len ( nip . cache_fit_res ) , <NUM_LIT:4> ) <EOL> assert_raises ( ValueError , nip . solve_power , None , nobs1 = <NUM_LIT> , alpha = <NUM_LIT> , <EOL> power = <NUM_LIT> , ratio = <NUM_LIT:1> , alternative = '<STR_LIT>' ) <EOL> def test_power_solver_warn ( ) : <EOL> pow_ = <NUM_LIT> <EOL> nip = smp . NormalIndPower ( ) <EOL> nip . start_bqexp [ '<STR_LIT>' ] = { '<STR_LIT>' : <NUM_LIT:50> , '<STR_LIT>' : - <NUM_LIT:20> } <EOL> val = nip . solve_power ( <NUM_LIT:0.1> , nobs1 = None , alpha = <NUM_LIT> , power = pow_ , ratio = <NUM_LIT:1> , <EOL> alternative = '<STR_LIT>' ) <EOL> import scipy <EOL> if scipy . __version__ < '<STR_LIT>' : <EOL> assert_almost_equal ( val , <NUM_LIT> , decimal = <NUM_LIT:4> ) <EOL> assert_equal ( nip . cache_fit_res [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> assert_equal ( len ( nip . cache_fit_res ) , <NUM_LIT:3> ) <EOL> nip . start_ttp [ '<STR_LIT>' ] = np . nan <EOL> from statsmodels . tools . sm_exceptions import ConvergenceWarning <EOL> assert_warns ( ConvergenceWarning , nip . solve_power , <NUM_LIT:0.1> , nobs1 = None , <EOL> alpha = <NUM_LIT> , power = pow_ , ratio = <NUM_LIT:1> , alternative = '<STR_LIT>' ) <EOL> with warnings . catch_warnings ( ) : <EOL> warnings . simplefilter ( "<STR_LIT:ignore>" ) <EOL> val = nip . solve_power ( <NUM_LIT:0.1> , nobs1 = None , alpha = <NUM_LIT> , power = pow_ , ratio = <NUM_LIT:1> , <EOL> alternative = '<STR_LIT>' ) <EOL> assert_equal ( nip . cache_fit_res [ <NUM_LIT:0> ] , <NUM_LIT:0> ) <EOL> assert_equal ( len ( nip . cache_fit_res ) , <NUM_LIT:3> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_normal_power_explicit ( ) <EOL> nt = TestNormalIndPower1 ( ) <EOL> nt . test_power ( ) <EOL> nt . test_roots ( ) <EOL> nt = TestNormalIndPower_onesamp1 ( ) <EOL> nt . test_power ( ) <EOL> nt . test_roots ( ) </s>
