def test_power_solver_warn():
    # messing up the solver to trigger warning
    # I wrote this with scipy 0.9,
    # convergence behavior of scipy 0.11 is different,
    # fails at a different case, but is successful where it failed before

    pow_ = 0.69219411243824214 # from previous function
    nip = smp.NormalIndPower()
    # using nobs, has one backup (fsolve)
    nip.start_bqexp['nobs1'] = {'upp': 50, 'low': -20}
    val = nip.solve_power(0.1, nobs1=None, alpha=0.01, power=pow_, ratio=1,
                          alternative='larger')
    import scipy
    if scipy.__version__ < '0.10':
        assert_almost_equal(val, 1600, decimal=4)
        assert_equal(nip.cache_fit_res[0], 1)
        assert_equal(len(nip.cache_fit_res), 3)

        # case that has convergence failure, and should warn
        nip.start_ttp['nobs1'] = np.nan

        from statsmodels.tools.sm_exceptions import ConvergenceWarning
        assert_warns(ConvergenceWarning, nip.solve_power, 0.1, nobs1=None,
                      alpha=0.01, power=pow_, ratio=1, alternative='larger')
        # this converges with scipy 0.11  ???
        # nip.solve_power(0.1, nobs1=None, alpha=0.01, power=pow_, ratio=1, alternative='larger')

        with warnings.catch_warnings():  # python >= 2.6
            warnings.simplefilter("ignore")
            val = nip.solve_power(0.1, nobs1=None, alpha=0.01, power=pow_, ratio=1,
                                  alternative='larger')
            assert_equal(nip.cache_fit_res[0], 0)
            assert_equal(len(nip.cache_fit_res), 3)
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/stats/tests/test_power.py/test_power_solver_warn/original