def test_perfect_prediction():
    cur_dir = os.path.dirname(os.path.abspath(__file__))
    iris_dir = os.path.join(cur_dir, '..', '..', 'genmod', 'tests', 'results')
    iris_dir = os.path.abspath(iris_dir)
    iris = np.genfromtxt(os.path.join(iris_dir, 'iris.csv'), delimiter=",",
                            skip_header=1)
    y = iris[:,-1]
    X = iris[:,:-1]
    X = X[y != 2]
    y = y[y != 2]
    X = sm.add_constant(X, prepend=True)
    mod = Logit(y,X)
    assert_raises(PerfectSeparationError, mod.fit, maxiter=1000)
    #turn off raise PerfectSeparationError
    mod.raise_on_perfect_prediction = False
    # this will raise if you set maxiter high enough with a singular matrix
    from pandas.util.testing import assert_produces_warning
    # this is not thread-safe
    with assert_produces_warning():
        mod.fit(disp=False, maxiter=50)  # should not raise but does warn
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/discrete/tests/test_discrete.py/test_perfect_prediction/original