Example #1
0
def test_corr1d(data1, data2):
    gs1 = Series(data1)
    gs2 = Series(data2)

    ps1 = gs1.to_pandas()
    ps2 = gs2.to_pandas()

    got = gs1.corr(gs2)
    expected = ps1.corr(ps2)
    np.testing.assert_approx_equal(got, expected, significant=8)
Example #2
0
def test_series_nlargest_nelem(nelem):
    np.random.seed(0)
    elems = np.random.random(nelem)
    gds = Series(elems).nlargest(nelem)
    pds = pd.Series(elems).nlargest(nelem)

    assert (pds == gds.to_pandas()).all().all()
Example #3
0
def test_series_sort_values_ignore_index(ignore_index):
    gsr = Series([1, 3, 5, 2, 4])
    psr = gsr.to_pandas()

    expect = psr.sort_values(ignore_index=ignore_index)
    got = gsr.sort_values(ignore_index=ignore_index)
    assert_eq(expect, got)
Example #4
0
def test_series_std(ddof):
    np.random.seed(0)
    arr = np.random.random(100) - 0.5
    sr = Series(arr)
    pd = sr.to_pandas()
    got = sr.std(ddof=ddof)
    expect = pd.std(ddof=ddof)
    np.testing.assert_approx_equal(expect, got)
Example #5
0
def test_operator_func_between_series_logical(dtype, func, scalar_a, scalar_b,
                                              fill_value):
    gdf_series_a = Series([scalar_a]).astype(dtype)
    gdf_series_b = Series([scalar_b]).astype(dtype)
    pdf_series_a = gdf_series_a.to_pandas()
    pdf_series_b = gdf_series_b.to_pandas()

    gdf_series_result = getattr(gdf_series_a, func)(gdf_series_b,
                                                    fill_value=fill_value)
    pdf_series_result = getattr(pdf_series_a, func)(pdf_series_b,
                                                    fill_value=fill_value)

    if scalar_a in [None, np.nan] and scalar_b in [None, np.nan]:
        # cudf binary operations will return `None` when both left- and right-
        # side values are `None`. It will return `np.nan` when either side is
        # `np.nan`. As a consequence, when we convert our gdf => pdf during
        # assert_eq, we get a pdf with dtype='object' (all inputs are none).
        # to account for this, we use fillna.
        gdf_series_result.fillna(func == "ne", inplace=True)

    utils.assert_eq(pdf_series_result, gdf_series_result)