Beispiel #1
0
def test_operator_func_between_series(dtype, func, has_nulls, fill_value):
    nelem = 1000
    arr1 = utils.gen_rand(dtype, nelem) * 10000
    # Keeping a low value because CUDA 'pow' has 2 full range error
    arr2 = utils.gen_rand(dtype, nelem) * 100

    if has_nulls == 'some':
        nulls1 = utils.random_bitmask(nelem)
        nulls2 = utils.random_bitmask(nelem)
        sr1 = Series.from_masked_array(arr1, nulls1)
        sr2 = Series.from_masked_array(arr2, nulls2)
    else:
        sr1 = Series(arr1)
        sr2 = Series(arr2)

    psr1 = sr1.to_pandas()
    psr2 = sr2.to_pandas()

    expect = getattr(psr1, func)(psr2, fill_value=fill_value)
    got = getattr(sr1, func)(sr2, fill_value=fill_value)

    # This is being done because of the various gymnastics required to support
    # equality for null values. cudf.Series().to_pandas() replaces nulls with
    # None and so a bool Series becomes object Series. Which does not match the
    # output of equality op in pandas which remains a bool. Furthermore, NaN
    # values are treated as not comparable and always return False in a bool op
    # except in not-equal op where bool(Nan != Nan) gives True.
    if got.dtype == np.bool:
        got = got.fillna(True) if func == 'ne' else got.fillna(False)

    utils.assert_eq(expect, got)
Beispiel #2
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)