def test_factorize_result_classes(): data = [1, 2, 3] labels, cats = cudf.factorize(cudf.Series(data)) assert isinstance(labels, cp.ndarray) assert isinstance(cats, cudf.BaseIndex) labels, cats = cudf.factorize(cudf.Index(data)) assert isinstance(labels, cp.ndarray) assert isinstance(cats, cudf.BaseIndex) labels, cats = cudf.factorize(cp.array(data)) assert isinstance(labels, cp.ndarray) assert isinstance(cats, cp.ndarray)
def test_cudf_factorize_index(): data = [1, 2, 3, 4, 5] pi = pd.Index(data) gi = cudf.Index(data) expect = pd.factorize(pi) got = cudf.factorize(gi) assert len(expect) == len(got) np.testing.assert_array_equal(expect[0], got[0].get()) np.testing.assert_array_equal(expect[1], got[1].values.get())
def test_cudf_factorize_series(): data = [1, 2, 3, 4, 5] psr = pd.Series(data) gsr = cudf.Series(data) expect = pd.factorize(psr) got = cudf.factorize(gsr) assert len(expect) == len(got) np.testing.assert_array_equal(expect[0], got[0].get()) np.testing.assert_array_equal(expect[1], got[1].values.get())
def test_cudf_factorize_array(): data = [1, 2, 3, 4, 5] parr = np.array(data) garr = cp.array(data) expect = pd.factorize(parr) got = cudf.factorize(garr) assert len(expect) == len(got) np.testing.assert_array_equal(expect[0], got[0].get()) np.testing.assert_array_equal(expect[1], got[1].get())