

def test_formula_missing_exposure():
    import statsmodels.formula.api as smf
    import pandas as pd
    d = {
        'Foo': [1, 2, 10, 149],
        'Bar': [1, 2, 3, np.nan],
        'constant': ([1] * 4),
        'exposure': np.random.uniform(size=4),
        'x': [1, 3, 2, 1.5],
    }
    df = pd.DataFrame(d)
    mod1 = smf.poisson('Foo ~ Bar', data=df, exposure=df['exposure'])
    assert_((type(mod1.exposure) is np.ndarray), msg='Exposure is not ndarray')
    exposure = pd.Series(np.random.randn(5))
    assert_raises(ValueError, sm.Poisson, df.Foo, df[['constant', 'Bar']], exposure=exposure)

dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/discrete/tests/test_discrete.py test_formula_missing_exposure/original