Exemple #1
0
def test_webuse():
    # test copied and adjusted from iolib/tests/test_foreign
    from statsmodels.iolib.tests.results.macrodata import macrodata_result as res2
    base_gh = "http://github.com/statsmodels/statsmodels/raw/master/statsmodels/datasets/macrodata/"
    internet_available = check_internet(base_gh)
    if not internet_available:
        raise SkipTest('Unable to retrieve file - skipping test')
    res1 = webuse('macrodata', baseurl=base_gh, as_df=False)
    assert_array_equal(res1, res2)
Exemple #2
0
def test_get_rdataset():
    # smoke test
    test_url = "https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/cars.csv"
    internet_available = check_internet(test_url)
    if not internet_available:
        raise SkipTest('Unable to retrieve file - skipping test')
    duncan = get_rdataset("Duncan", "car", cache=cur_dir)
    assert_(isinstance(duncan, utils.Dataset))
    assert_(duncan.from_cache)
Exemple #3
0
def test_get_rdataset():
    # smoke test
    test_url = "https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/cars.csv"
    internet_available = check_internet(test_url)
    if not internet_available:
        raise SkipTest('Unable to retrieve file - skipping test')
    duncan = get_rdataset("Duncan", "car", cache=cur_dir)
    assert_(isinstance(duncan, utils.Dataset))
    assert_(duncan.from_cache)
Exemple #4
0
def test_webuse_pandas():
    # test copied and adjusted from iolib/tests/test_foreign
    from pandas.util.testing import assert_frame_equal
    from statsmodels.datasets import macrodata
    dta = macrodata.load_pandas().data
    base_gh = "http://github.com/statsmodels/statsmodels/raw/master/statsmodels/datasets/macrodata/"
    internet_available = check_internet(base_gh)
    if not internet_available:
        raise SkipTest('Unable to retrieve file - skipping test')
    res1 = webuse('macrodata', baseurl=base_gh)
    res1 = res1.astype(float)
    assert_frame_equal(res1, dta)
def test_get_rdataset():
    test_url = "https://raw.githubusercontent.com/vincentarelbundock/" \
               "Rdatasets/master/csv/datasets/cars.csv"
    internet_available = check_internet(test_url)
    if not internet_available:
        pytest.skip('Unable to retrieve file - skipping test')
    try:
        duncan = get_rdataset("Duncan", "carData", cache=cur_dir)
    except IGNORED_EXCEPTIONS:
        pytest.skip('Failed with HTTPError or URLError, these are random')
    assert_(isinstance(duncan, utils.Dataset))
    duncan = get_rdataset("Duncan", "carData", cache=cur_dir)
    assert_(duncan.from_cache)
Exemple #6
0
def test_get_rdataset():
    test_url = "https://raw.githubusercontent.com/vincentarelbundock/" \
               "Rdatasets/master/csv/datasets/cars.csv"
    internet_available = check_internet(test_url)
    if not internet_available:
        pytest.skip('Unable to retrieve file - skipping test')
    try:
        duncan = get_rdataset("Duncan", "carData", cache=cur_dir)
    except (HTTPError, URLError, SSLError, timeout):
        pytest.skip('Failed with HTTPError or URLError, these are random')
    assert_(isinstance(duncan, utils.Dataset))
    duncan = get_rdataset("Duncan", "carData", cache=cur_dir)
    assert_(duncan.from_cache)
def test_webuse():
    # test copied and adjusted from iolib/tests/test_foreign
    from statsmodels.iolib.tests.results.macrodata import macrodata_result
    res2 = np.array([list(row) for row in macrodata_result])
    base_gh = "https://github.com/statsmodels/statsmodels/raw/master/" \
              "statsmodels/datasets/macrodata/"
    internet_available = check_internet(base_gh)
    if not internet_available:
        pytest.skip('Unable to retrieve file - skipping test')
    try:
        res1 = webuse('macrodata', baseurl=base_gh, as_df=False)
    except IGNORED_EXCEPTIONS:
        pytest.skip('Failed with HTTPError or URLError, these are random')
    assert_array_equal(res1, res2)
Exemple #8
0
def test_get_rdataset():
    # smoke test
    test_url = "https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/cars.csv"
    internet_available = check_internet(test_url)
    if not internet_available:
        raise SkipTest('Unable to retrieve file - skipping test')
    duncan = get_rdataset("Duncan", "car", cache=cur_dir)
    assert_(isinstance(duncan, utils.Dataset))
    if not PY3:
        #NOTE: there's no way to test both since the cached files were
        #created with Python 2.x, they're strings, but Python 3 expects
        #bytes and the index file path is hard-coded so both can't live
        #side by side
        assert_(duncan.from_cache)
Exemple #9
0
def test_webuse():
    # test copied and adjusted from iolib/tests/test_foreign
    from statsmodels.iolib.tests.results.macrodata import macrodata_result
    res2 = np.array([list(row) for row in macrodata_result])
    base_gh = "https://github.com/statsmodels/statsmodels/raw/master/" \
              "statsmodels/datasets/macrodata/"
    internet_available = check_internet(base_gh)
    if not internet_available:
        pytest.skip('Unable to retrieve file - skipping test')
    try:
        res1 = webuse('macrodata', baseurl=base_gh, as_df=False)
    except (HTTPError, URLError, SSLError, timeout):
        pytest.skip('Failed with HTTPError or URLError, these are random')
    assert_array_equal(res1, res2)
Exemple #10
0
def test_get_rdataset():
    # smoke test
    test_url = "https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/cars.csv"
    internet_available = check_internet(test_url)
    if not internet_available:
        raise SkipTest('Unable to retrieve file - skipping test')
    duncan = get_rdataset("Duncan", "car", cache=cur_dir)
    assert_(isinstance(duncan, utils.Dataset))
    if not PY3:
        #NOTE: there's no way to test both since the cached files were
        #created with Python 2.x, they're strings, but Python 3 expects
        #bytes and the index file path is hard-coded so both can't live
        #side by side
        assert_(duncan.from_cache)
def test_webuse_pandas():
    # test copied and adjusted from iolib/tests/test_foreign
    from pandas.util.testing import assert_frame_equal
    from statsmodels.datasets import macrodata
    dta = macrodata.load_pandas().data
    base_gh = "https://github.com/statsmodels/statsmodels/raw/master/" \
              "statsmodels/datasets/macrodata/"
    internet_available = check_internet(base_gh)
    if not internet_available:
        pytest.skip('Unable to retrieve file - skipping test')
    try:
        res1 = webuse('macrodata', baseurl=base_gh)
    except IGNORED_EXCEPTIONS:
        pytest.skip('Failed with HTTP Error, these are random')
    res1 = res1.astype(float)
    assert_frame_equal(res1, dta.astype(float))
Exemple #12
0
def test_webuse_pandas():
    # test copied and adjusted from iolib/tests/test_foreign
    from pandas.util.testing import assert_frame_equal
    from statsmodels.datasets import macrodata
    dta = macrodata.load_pandas().data
    base_gh = "https://github.com/statsmodels/statsmodels/raw/master/" \
              "statsmodels/datasets/macrodata/"
    internet_available = check_internet(base_gh)
    if not internet_available:
        pytest.skip('Unable to retrieve file - skipping test')
    try:
        res1 = webuse('macrodata', baseurl=base_gh)
    except (HTTPError, URLError, SSLError, timeout):
        pytest.skip('Failed with HTTP Error, these are random')
    res1 = res1.astype(float)
    assert_frame_equal(res1, dta.astype(float))
Exemple #13
0
def test_get_rdataset():
    # smoke test
    test_url = "https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/cars.csv"
    internet_available = check_internet(test_url)
    if not internet_available:
        raise SkipTest('Unable to retrieve file - skipping test')
    duncan = get_rdataset("Duncan", "car", cache=cur_dir)
    assert_(isinstance(duncan, utils.Dataset))
    assert_(duncan.from_cache)

    # test writing and reading cache
    guerry = get_rdataset("Guerry", "HistData", cache=cur_dir)
    assert_(guerry.from_cache is False)
    guerry2 = get_rdataset("Guerry", "HistData", cache=cur_dir)
    assert_(guerry2.from_cache is True)
    fn = "raw.github.com,vincentarelbundock,Rdatasets,master,csv,HistData,Guerry.csv.zip"
    os.remove(os.path.join(cur_dir, fn))
    fn = "raw.github.com,vincentarelbundock,Rdatasets,master,doc,HistData,rst,Guerry.rst.zip"
    os.remove(os.path.join(cur_dir, fn))