def test_index_copy_float(name, dtype, deep=True): """Test for NumericIndex Copy Casts """ cidx = cudf.Float64Index([1.0, 2.0, 3.0]) pidx = cidx.to_pandas() pidx_copy = pidx.copy(name=name, deep=deep, dtype=dtype) cidx_copy = cidx.copy(name=name, deep=deep, dtype=dtype) assert_eq(pidx_copy, cidx_copy)
def test_float_index_apis(data, name, dtype): pindex = pd.Float64Index(data, dtype=dtype, name=name) # Float32Index gindex = cudf.Float32Index(data, dtype=dtype, name=name) assert_eq(pindex, gindex) assert gindex.dtype == np.dtype("float32") # Float64Index gindex = cudf.Float64Index(data, dtype=dtype, name=name) assert_eq(pindex, gindex) assert gindex.dtype == np.dtype("float64")
pidx = cidx.to_pandas() pidx_copy = pidx.copy(name=name, deep=deep, dtype=dtype) cidx_copy = cidx.copy(name=name, deep=deep, dtype=dtype) assert_eq(pidx_copy, cidx_copy) @pytest.mark.parametrize("deep", [True, False]) @pytest.mark.parametrize( "idx", [ cudf.DatetimeIndex(["2001", "2002", "2003"]), cudf.core.index.StringIndex(["a", "b", "c"]), cudf.Int64Index([1, 2, 3]), cudf.Float64Index([1.0, 2.0, 3.0]), cudf.CategoricalIndex([1, 2, 3]), cudf.CategoricalIndex(["a", "b", "c"]), ], ) def test_index_copy_deep(idx, deep): """Test if deep copy creates a new instance for device data. The general criterion is to compare `Buffer.ptr` between two data objects. Specifically for: - CategoricalIndex, this applies to both `.codes` and `.categories` - StringIndex, to every element in `._base_children` - Others, to `.base_data` No test is defined for RangeIndex. """ idx_copy = idx.copy(deep=deep) same_ref = not deep