From dbf08cb84026e185971f29b71e278765c3d55093 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Mon, 29 Jan 2024 08:48:51 -0600 Subject: [PATCH] Fix style issues in 2.0 feature branch (#14918) This PR fixes all style issues in pandas-2.0 feature branch --- .github/workflows/pr.yaml | 1 - python/cudf/cudf/_lib/column.pyx | 1 - python/cudf/cudf/api/types.py | 4 ++-- python/cudf/cudf/core/column/datetime.py | 1 - python/cudf/cudf/core/column/interval.py | 3 +-- python/cudf/cudf/core/column/timedelta.py | 3 +-- python/cudf/cudf/core/dataframe.py | 1 - python/cudf/cudf/core/dtypes.py | 14 +++++------ python/cudf/cudf/core/multiindex.py | 8 +++++-- python/cudf/cudf/testing/testing.py | 2 +- python/cudf/cudf/tests/test_api_types.py | 3 +-- python/cudf/cudf/tests/test_applymap.py | 2 +- python/cudf/cudf/tests/test_array_function.py | 3 ++- python/cudf/cudf/tests/test_categorical.py | 5 ---- .../cudf/cudf/tests/test_column_accessor.py | 2 +- python/cudf/cudf/tests/test_concat.py | 7 +++--- python/cudf/cudf/tests/test_csv.py | 2 +- python/cudf/cudf/tests/test_datasets.py | 2 +- python/cudf/cudf/tests/test_datetime.py | 24 ++++++------------- python/cudf/cudf/tests/test_dropna.py | 1 - python/cudf/cudf/tests/test_duplicates.py | 5 +--- python/cudf/cudf/tests/test_groupby.py | 2 +- python/cudf/cudf/tests/test_monotonic.py | 7 +----- python/cudf/cudf/tests/test_parquet.py | 1 - python/cudf/cudf/tests/test_resampling.py | 2 +- python/cudf/cudf/tests/test_rolling.py | 3 --- python/cudf/cudf/tests/test_series.py | 2 +- python/cudf/cudf/tests/test_stats.py | 5 +--- python/cudf/cudf/tests/test_timedelta.py | 2 +- .../cudf_pandas_tests/test_cudf_pandas.py | 1 - .../dask_cudf/tests/test_accessor.py | 3 +-- 31 files changed, 43 insertions(+), 79 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 734c7643808..14a74618413 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -196,4 +196,3 @@ jobs: # repo: context.repo.repo, # body: `${summary_comment}\n\nHere is [a link to the full test summary](${summary_url}).\n` # }) - diff --git a/python/cudf/cudf/_lib/column.pyx b/python/cudf/cudf/_lib/column.pyx index b97dc85ef8b..45aa1081b8d 100644 --- a/python/cudf/cudf/_lib/column.pyx +++ b/python/cudf/cudf/_lib/column.pyx @@ -12,7 +12,6 @@ import rmm import cudf import cudf._lib as libcudf from cudf._lib import pylibcudf -from cudf.api.types import _is_categorical_dtype, _is_datetime64tz_dtype from cudf.core.buffer import ( Buffer, ExposureTrackedBuffer, diff --git a/python/cudf/cudf/api/types.py b/python/cudf/cudf/api/types.py index 22fc3ea2c6f..f6f5e522cbd 100644 --- a/python/cudf/cudf/api/types.py +++ b/python/cudf/cudf/api/types.py @@ -12,9 +12,10 @@ import cupy as cp import numpy as np +import pandas as pd +from pandas.api import types as pd_types import cudf -import pandas as pd from cudf.core._compat import PANDAS_GE_150 from cudf.core.dtypes import ( # noqa: F401 _BaseDtype, @@ -30,7 +31,6 @@ is_list_dtype, is_struct_dtype, ) -from pandas.api import types as pd_types def is_numeric_dtype(obj): diff --git a/python/cudf/cudf/core/column/datetime.py b/python/cudf/cudf/core/column/datetime.py index 08a5103b409..a0c0b119ef7 100644 --- a/python/cudf/cudf/core/column/datetime.py +++ b/python/cudf/cudf/core/column/datetime.py @@ -28,7 +28,6 @@ is_scalar, is_timedelta64_dtype, ) - from cudf.core._compat import PANDAS_GE_200, PANDAS_GE_220 from cudf.core.buffer import Buffer, cuda_array_interface_wrapper from cudf.core.column import ColumnBase, as_column, column, string diff --git a/python/cudf/cudf/core/column/interval.py b/python/cudf/cudf/core/column/interval.py index f73c222624a..f5d527ad201 100644 --- a/python/cudf/cudf/core/column/interval.py +++ b/python/cudf/cudf/core/column/interval.py @@ -1,11 +1,10 @@ # Copyright (c) 2018-2024, NVIDIA CORPORATION. from typing import Optional -import pyarrow as pa import pandas as pd +import pyarrow as pa import cudf - from cudf.api.types import _is_interval_dtype from cudf.core.column import StructColumn from cudf.core.dtypes import CategoricalDtype, IntervalDtype diff --git a/python/cudf/cudf/core/column/timedelta.py b/python/cudf/cudf/core/column/timedelta.py index 2c12c77277c..094ccb57a1c 100644 --- a/python/cudf/cudf/core/column/timedelta.py +++ b/python/cudf/cudf/core/column/timedelta.py @@ -14,12 +14,11 @@ from cudf import _lib as libcudf from cudf._typing import ColumnBinaryOperand, DatetimeLikeScalar, Dtype from cudf.api.types import is_scalar, is_timedelta64_dtype +from cudf.core._compat import PANDAS_GE_200 from cudf.core.buffer import Buffer, acquire_spill_lock from cudf.core.column import ColumnBase, column, string from cudf.utils.dtypes import np_to_pa_dtype from cudf.utils.utils import _all_bools_with_nulls -from cudf.core._compat import PANDAS_GE_200 - _dtype_to_format_conversion = { "timedelta64[ns]": "%D days %H:%M:%S", diff --git a/python/cudf/cudf/core/dataframe.py b/python/cudf/cudf/core/dataframe.py index 86947fe6028..d0cbacfb7e8 100644 --- a/python/cudf/cudf/core/dataframe.py +++ b/python/cudf/cudf/core/dataframe.py @@ -6099,7 +6099,6 @@ def _reduce( numeric_only=False, **kwargs, ): - source = self if axis is None: diff --git a/python/cudf/cudf/core/dtypes.py b/python/cudf/cudf/core/dtypes.py index 0eb2e455544..734dd501d48 100644 --- a/python/cudf/cudf/core/dtypes.py +++ b/python/cudf/cudf/core/dtypes.py @@ -9,21 +9,21 @@ from typing import Any, Callable, Dict, List, Tuple, Type, Union import numpy as np +import pandas as pd import pyarrow as pa +from pandas.api import types as pd_types +from pandas.api.extensions import ExtensionDtype +from pandas.core.dtypes.dtypes import ( + CategoricalDtype as pd_CategoricalDtype, + CategoricalDtypeType as pd_CategoricalDtypeType, +) import cudf -import pandas as pd from cudf._typing import Dtype from cudf.core._compat import PANDAS_GE_150 from cudf.core.abc import Serializable from cudf.core.buffer import Buffer from cudf.utils.docutils import doc_apply -from pandas.api import types as pd_types -from pandas.api.extensions import ExtensionDtype -from pandas.core.dtypes.dtypes import ( - CategoricalDtype as pd_CategoricalDtype, - CategoricalDtypeType as pd_CategoricalDtypeType, -) if PANDAS_GE_150: from pandas.core.arrays.arrow.extension_types import ArrowIntervalType diff --git a/python/cudf/cudf/core/multiindex.py b/python/cudf/cudf/core/multiindex.py index e6ac114bfcb..081109e81bc 100644 --- a/python/cudf/cudf/core/multiindex.py +++ b/python/cudf/cudf/core/multiindex.py @@ -34,8 +34,8 @@ ) from cudf.core.join._join_helpers import _match_join_keys from cudf.utils.dtypes import is_column_like -from cudf.utils.utils import NotIterable, _external_only_api, _is_same_name from cudf.utils.nvtx_annotation import _cudf_nvtx_annotate +from cudf.utils.utils import NotIterable, _external_only_api, _is_same_name def _maybe_indices_to_slice(indices: cp.ndarray) -> Union[slice, cp.ndarray]: @@ -726,7 +726,11 @@ def _compute_validity_mask(self, index, row_tuple, max_length): [ frame, cudf.DataFrame( - {"idx": cudf.Series(column.as_column(range(len(frame))))} + { + "idx": cudf.Series( + column.as_column(range(len(frame))) + ) + } ), ], axis=1, diff --git a/python/cudf/cudf/testing/testing.py b/python/cudf/cudf/testing/testing.py index dc7d6b84d9b..fc253c5c197 100644 --- a/python/cudf/cudf/testing/testing.py +++ b/python/cudf/cudf/testing/testing.py @@ -4,9 +4,9 @@ import cupy as cp import numpy as np +import pandas as pd import cudf -import pandas as pd from cudf._lib.unary import is_nan from cudf.api.types import ( _is_categorical_dtype, diff --git a/python/cudf/cudf/tests/test_api_types.py b/python/cudf/cudf/tests/test_api_types.py index cc26815920c..7780f9853a2 100644 --- a/python/cudf/cudf/tests/test_api_types.py +++ b/python/cudf/cudf/tests/test_api_types.py @@ -6,9 +6,8 @@ from pandas.api import types as pd_types import cudf -from cudf.core._compat import PANDAS_GE_200, PANDAS_GE_210, PANDAS_GE_214 from cudf.api import types - +from cudf.core._compat import PANDAS_GE_200, PANDAS_GE_210, PANDAS_GE_214 from cudf.testing._utils import expect_warning_if diff --git a/python/cudf/cudf/tests/test_applymap.py b/python/cudf/cudf/tests/test_applymap.py index 523a7f424e8..38a34c206d7 100644 --- a/python/cudf/cudf/tests/test_applymap.py +++ b/python/cudf/cudf/tests/test_applymap.py @@ -3,8 +3,8 @@ import pytest from cudf import NA, DataFrame -from cudf.testing import _utils as utils from cudf.core._compat import PANDAS_GE_210 +from cudf.testing import _utils as utils @pytest.mark.parametrize( diff --git a/python/cudf/cudf/tests/test_array_function.py b/python/cudf/cudf/tests/test_array_function.py index b3f5267c3b2..090e8884991 100644 --- a/python/cudf/cudf/tests/test_array_function.py +++ b/python/cudf/cudf/tests/test_array_function.py @@ -1,4 +1,5 @@ -# Copyright (c) 2018-2023, NVIDIA CORPORATION. +# Copyright (c) 2018-2024, NVIDIA CORPORATION. + import numpy as np import pandas as pd import pytest diff --git a/python/cudf/cudf/tests/test_categorical.py b/python/cudf/cudf/tests/test_categorical.py index 0f7abab8104..ad32ebce01b 100644 --- a/python/cudf/cudf/tests/test_categorical.py +++ b/python/cudf/cudf/tests/test_categorical.py @@ -346,7 +346,6 @@ def test_categorical_set_categories_preserves_order(): def test_categorical_as_ordered(pd_str_cat): - pd_sr = pd.Series(pd_str_cat.copy().set_ordered(False)) cd_sr = cudf.Series(pd_str_cat.copy().set_ordered(False)) @@ -362,7 +361,6 @@ def test_categorical_as_ordered(pd_str_cat): def test_categorical_as_unordered(pd_str_cat): - pd_sr = pd.Series(pd_str_cat.copy().set_ordered(True)) cd_sr = cudf.Series(pd_str_cat.copy().set_ordered(True)) @@ -380,7 +378,6 @@ def test_categorical_as_unordered(pd_str_cat): @pytest.mark.parametrize("from_ordered", [True, False]) @pytest.mark.parametrize("to_ordered", [True, False]) def test_categorical_reorder_categories(pd_str_cat, from_ordered, to_ordered): - pd_sr = pd.Series(pd_str_cat.copy().set_ordered(from_ordered)) cd_sr = cudf.Series(pd_str_cat.copy().set_ordered(from_ordered)) @@ -401,7 +398,6 @@ def test_categorical_reorder_categories(pd_str_cat, from_ordered, to_ordered): def test_categorical_add_categories(pd_str_cat): - pd_sr = pd.Series(pd_str_cat.copy()) cd_sr = cudf.Series(pd_str_cat.copy()) @@ -419,7 +415,6 @@ def test_categorical_add_categories(pd_str_cat): def test_categorical_remove_categories(pd_str_cat): - pd_sr = pd.Series(pd_str_cat.copy()) cd_sr = cudf.Series(pd_str_cat.copy()) diff --git a/python/cudf/cudf/tests/test_column_accessor.py b/python/cudf/cudf/tests/test_column_accessor.py index e2a2b307856..bf764b02faa 100644 --- a/python/cudf/cudf/tests/test_column_accessor.py +++ b/python/cudf/cudf/tests/test_column_accessor.py @@ -5,9 +5,9 @@ import pytest import cudf +from cudf.core._compat import PANDAS_GE_200 from cudf.core.column_accessor import ColumnAccessor from cudf.testing._utils import assert_eq -from cudf.core._compat import PANDAS_GE_200 simple_test_data = [ {}, diff --git a/python/cudf/cudf/tests/test_concat.py b/python/cudf/cudf/tests/test_concat.py index 895e35614fa..ed8f32ed12b 100644 --- a/python/cudf/cudf/tests/test_concat.py +++ b/python/cudf/cudf/tests/test_concat.py @@ -1,17 +1,16 @@ # Copyright (c) 2018-2024, NVIDIA CORPORATION. +import warnings +from contextlib import contextmanager from decimal import Decimal -import warnings import numpy as np import pandas as pd import pytest -from contextlib import contextmanager - import cudf as gd from cudf.api.types import _is_categorical_dtype -from cudf.core._compat import PANDAS_GE_150, PANDAS_LT_140, PANDAS_GE_200 +from cudf.core._compat import PANDAS_GE_150, PANDAS_GE_200, PANDAS_LT_140 from cudf.core.dtypes import Decimal32Dtype, Decimal64Dtype, Decimal128Dtype from cudf.testing._utils import ( assert_eq, diff --git a/python/cudf/cudf/tests/test_csv.py b/python/cudf/cudf/tests/test_csv.py index 2fa4a313d6f..6de66bf1952 100644 --- a/python/cudf/cudf/tests/test_csv.py +++ b/python/cudf/cudf/tests/test_csv.py @@ -17,7 +17,7 @@ import cudf from cudf import read_csv -from cudf.core._compat import PANDAS_LT_140, PANDAS_GE_200 +from cudf.core._compat import PANDAS_GE_200, PANDAS_LT_140 from cudf.testing._utils import assert_eq, assert_exceptions_equal diff --git a/python/cudf/cudf/tests/test_datasets.py b/python/cudf/cudf/tests/test_datasets.py index fdab8cb5edf..320c221fcb2 100644 --- a/python/cudf/cudf/tests/test_datasets.py +++ b/python/cudf/cudf/tests/test_datasets.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2022, NVIDIA CORPORATION. +# Copyright (c) 2019-2024, NVIDIA CORPORATION. import numpy as np diff --git a/python/cudf/cudf/tests/test_datetime.py b/python/cudf/cudf/tests/test_datetime.py index 14a732deea4..d83b46250d0 100644 --- a/python/cudf/cudf/tests/test_datetime.py +++ b/python/cudf/cudf/tests/test_datetime.py @@ -2,6 +2,7 @@ import datetime import operator +import warnings import cupy as cp import numpy as np @@ -10,15 +11,14 @@ import pytest import cudf -import warnings import cudf.testing.dataset_generator as dataset_generator from cudf import DataFrame, Series from cudf.core._compat import ( - PANDAS_GE_150, - PANDAS_LT_140, PANDAS_EQ_200, + PANDAS_GE_150, PANDAS_GE_200, PANDAS_GE_210, + PANDAS_LT_140, ) from cudf.core.index import DatetimeIndex from cudf.testing._utils import ( @@ -623,22 +623,13 @@ def test_datetime_dataframe(): @pytest.mark.parametrize("dayfirst", [True, False]) def test_cudf_to_datetime(data, dayfirst): pd_data = data - is_string_data = False if isinstance(pd_data, (pd.Series, pd.DataFrame, pd.Index)): gd_data = cudf.from_pandas(pd_data) - is_string_data = ( - gd_data.ndim == 1 - and not gd_data.empty - and gd_data.dtype.kind == "O" - ) else: if type(pd_data).__module__ == np.__name__: gd_data = cp.array(pd_data) else: gd_data = pd_data - is_string_data = isinstance(gd_data, list) and isinstance( - next(iter(gd_data), None), str - ) expected = pd.to_datetime(pd_data, dayfirst=dayfirst) actual = cudf.to_datetime(gd_data, dayfirst=dayfirst) @@ -696,7 +687,6 @@ def test_to_datetime_errors(data): def test_to_datetime_not_implemented(): - with pytest.raises(NotImplementedError): cudf.to_datetime([], exact=False) @@ -817,7 +807,6 @@ def test_to_datetime_different_formats_notimplemented(): def test_datetime_can_cast_safely(): - sr = cudf.Series( ["1679-01-01", "2000-01-31", "2261-01-01"], dtype="datetime64[ms]" ) @@ -938,7 +927,6 @@ def test_str_to_datetime_error(): @pytest.mark.parametrize("data_dtype", DATETIME_TYPES) @pytest.mark.parametrize("other_dtype", DATETIME_TYPES) def test_datetime_subtract(data, other, data_dtype, other_dtype): - gsr = cudf.Series(data, dtype=data_dtype) psr = gsr.to_pandas() @@ -1580,7 +1568,8 @@ def test_date_range_start_end_freq(request, start, end, freq): request.applymarker( pytest.mark.xfail( condition=( - not PANDAS_GE_200 and isinstance(freq, dict) + not PANDAS_GE_200 + and isinstance(freq, dict) and freq.get("hours", None) == 10 and freq.get("days", None) == 57 and freq.get("nanoseconds", None) == 3 @@ -1634,7 +1623,8 @@ def test_date_range_start_freq_periods(request, start, freq, periods): request.applymarker( pytest.mark.xfail( condition=( - not PANDAS_GE_200 and isinstance(freq, dict) + not PANDAS_GE_200 + and isinstance(freq, dict) and freq.get("hours", None) == 10 and freq.get("days", None) == 57 and freq.get("nanoseconds", None) == 3 diff --git a/python/cudf/cudf/tests/test_dropna.py b/python/cudf/cudf/tests/test_dropna.py index 4b665cb6f0a..f1acd7b4320 100644 --- a/python/cudf/cudf/tests/test_dropna.py +++ b/python/cudf/cudf/tests/test_dropna.py @@ -21,7 +21,6 @@ @pytest.mark.parametrize("nulls", ["one", "some", "all", "none"]) @pytest.mark.parametrize("inplace", [True, False]) def test_dropna_series(data, nulls, inplace): - psr = pd.Series(data) if len(data) > 0: diff --git a/python/cudf/cudf/tests/test_duplicates.py b/python/cudf/cudf/tests/test_duplicates.py index b01130d5fa1..447b2b3c4f5 100644 --- a/python/cudf/cudf/tests/test_duplicates.py +++ b/python/cudf/cudf/tests/test_duplicates.py @@ -9,10 +9,7 @@ import cudf from cudf import concat -from cudf.testing._utils import ( - assert_eq, - assert_exceptions_equal, -) +from cudf.testing._utils import assert_eq, assert_exceptions_equal # TODO: PANDAS 1.0 support # Revisit drop_duplicates() tests to update parameters like ignore_index. diff --git a/python/cudf/cudf/tests/test_groupby.py b/python/cudf/cudf/tests/test_groupby.py index 77a25e2dbae..0c71d74f89f 100644 --- a/python/cudf/cudf/tests/test_groupby.py +++ b/python/cudf/cudf/tests/test_groupby.py @@ -22,9 +22,9 @@ from cudf.api.extensions import no_default from cudf.core._compat import ( PANDAS_GE_150, - PANDAS_LT_140, PANDAS_GE_200, PANDAS_GE_210, + PANDAS_LT_140, ) from cudf.core.udf._ops import arith_ops, comparison_ops, unary_ops from cudf.core.udf.groupby_typing import SUPPORTED_GROUPBY_NUMPY_TYPES diff --git a/python/cudf/cudf/tests/test_monotonic.py b/python/cudf/cudf/tests/test_monotonic.py index c84088c1cd3..53919a95115 100644 --- a/python/cudf/cudf/tests/test_monotonic.py +++ b/python/cudf/cudf/tests/test_monotonic.py @@ -10,11 +10,7 @@ import cudf from cudf import Index, MultiIndex, Series -from cudf.core.index import ( - CategoricalIndex, - DatetimeIndex, - RangeIndex, -) +from cudf.core.index import CategoricalIndex, DatetimeIndex, RangeIndex from cudf.testing._utils import assert_eq @@ -46,7 +42,6 @@ def test_range_index(testrange): ], ) def test_generic_index(testlist): - index = Index(testlist) index_pd = pd.Index(testlist) diff --git a/python/cudf/cudf/tests/test_parquet.py b/python/cudf/cudf/tests/test_parquet.py index 69d3fe0b83f..105c31cc71f 100644 --- a/python/cudf/cudf/tests/test_parquet.py +++ b/python/cudf/cudf/tests/test_parquet.py @@ -1622,7 +1622,6 @@ def test_parquet_writer_int96_timestamps(tmpdir, pdf, gdf): def test_multifile_parquet_folder(tmpdir): - test_pdf1 = make_pdf(nrows=10, nvalids=10 // 2, dtype="float64") test_pdf2 = make_pdf(nrows=20, dtype="float64") expect = pd.concat([test_pdf1, test_pdf2]) diff --git a/python/cudf/cudf/tests/test_resampling.py b/python/cudf/cudf/tests/test_resampling.py index 7cc4b465873..6281d54aa60 100644 --- a/python/cudf/cudf/tests/test_resampling.py +++ b/python/cudf/cudf/tests/test_resampling.py @@ -5,8 +5,8 @@ import pytest import cudf -from cudf.testing._utils import assert_eq from cudf.core._compat import PANDAS_GE_200 +from cudf.testing._utils import assert_eq def assert_resample_results_equal(lhs, rhs, **kwargs): diff --git a/python/cudf/cudf/tests/test_rolling.py b/python/cudf/cudf/tests/test_rolling.py index 7d3e19c002b..22dcf5dfa7e 100644 --- a/python/cudf/cudf/tests/test_rolling.py +++ b/python/cudf/cudf/tests/test_rolling.py @@ -151,7 +151,6 @@ def test_rolling_with_offset(agg): @pytest.mark.parametrize("seed", [100, 2000]) @pytest.mark.parametrize("window_size", [2, 10, 100]) def test_rolling_var_std_large(agg, ddof, center, seed, window_size): - iupper_bound = math.sqrt(np.iinfo(np.int64).max / window_size) ilower_bound = -math.sqrt(abs(np.iinfo(np.int64).min) / window_size) @@ -312,7 +311,6 @@ def test_rolling_getitem_window(): ) @pytest.mark.parametrize("center", [True, False]) def test_rollling_series_numba_udf_basic(data, index, center): - psr = pd.Series(data, index=index) gsr = cudf.from_pandas(psr) @@ -349,7 +347,6 @@ def some_func(A): ) @pytest.mark.parametrize("center", [True, False]) def test_rolling_dataframe_numba_udf_basic(data, center): - pdf = pd.DataFrame(data) gdf = cudf.from_pandas(pdf) diff --git a/python/cudf/cudf/tests/test_series.py b/python/cudf/cudf/tests/test_series.py index 2e39345f63a..b7be3878412 100644 --- a/python/cudf/cudf/tests/test_series.py +++ b/python/cudf/cudf/tests/test_series.py @@ -14,6 +14,7 @@ import pytest import cudf +from cudf.api.extensions import no_default from cudf.core._compat import PANDAS_LT_140 from cudf.errors import MixedTypeError from cudf.testing._utils import ( @@ -25,7 +26,6 @@ expect_warning_if, gen_rand, ) -from cudf.api.extensions import no_default def _series_na_data(): diff --git a/python/cudf/cudf/tests/test_stats.py b/python/cudf/cudf/tests/test_stats.py index 6dbb23fbf04..b35dd28c4ec 100644 --- a/python/cudf/cudf/tests/test_stats.py +++ b/python/cudf/cudf/tests/test_stats.py @@ -9,13 +9,13 @@ import cudf from cudf.api.extensions import no_default +from cudf.core._compat import PANDAS_GE_210 from cudf.datasets import randomdata from cudf.testing._utils import ( assert_eq, assert_exceptions_equal, expect_warning_if, ) -from cudf.core._compat import PANDAS_GE_210 params_dtypes = [np.int32, np.uint32, np.float32, np.float64] methods = ["min", "max", "sum", "mean", "var", "std"] @@ -182,7 +182,6 @@ def test_exact_quantiles_int(int_method): def test_approx_quantiles(): - arr = np.asarray([6.8, 0.15, 3.4, 4.17, 2.13, 1.11, -1.01, 0.8, 5.7]) quant_values = [0.0, 0.25, 0.33, 0.5, 1.0] @@ -222,7 +221,6 @@ def test_approx_quantiles_int(): ], ) def test_misc_quantiles(data, q): - pdf_series = pd.Series(data, dtype="float64" if len(data) == 0 else None) gdf_series = cudf.from_pandas(pdf_series) @@ -503,7 +501,6 @@ def test_corr1d(data1, data2, method): @pytest.mark.parametrize("method", ["spearman", "pearson"]) def test_df_corr(method): - gdf = randomdata(100, {str(x): float for x in range(50)}) pdf = gdf.to_pandas() got = gdf.corr(method) diff --git a/python/cudf/cudf/tests/test_timedelta.py b/python/cudf/cudf/tests/test_timedelta.py index 850c56b7614..980a8c0df2e 100644 --- a/python/cudf/cudf/tests/test_timedelta.py +++ b/python/cudf/cudf/tests/test_timedelta.py @@ -9,9 +9,9 @@ import pytest import cudf +from cudf.core._compat import PANDAS_GE_200 from cudf.testing import _utils as utils from cudf.testing._utils import assert_eq, assert_exceptions_equal -from cudf.core._compat import PANDAS_GE_200 _TIMEDELTA_DATA = [ [1000000, 200000, 3000000], diff --git a/python/cudf/cudf_pandas_tests/test_cudf_pandas.py b/python/cudf/cudf_pandas_tests/test_cudf_pandas.py index 2425c323060..e36e1a68114 100644 --- a/python/cudf/cudf_pandas_tests/test_cudf_pandas.py +++ b/python/cudf/cudf_pandas_tests/test_cudf_pandas.py @@ -269,7 +269,6 @@ def test_rename_categories(): tm.assert_series_equal(psr, sr) - def test_column_rename(dataframe): pdf, df = dataframe pdf.columns = ["x", "y"] diff --git a/python/dask_cudf/dask_cudf/tests/test_accessor.py b/python/dask_cudf/dask_cudf/tests/test_accessor.py index f6b8c34fef0..a6a457d98a4 100644 --- a/python/dask_cudf/dask_cudf/tests/test_accessor.py +++ b/python/dask_cudf/dask_cudf/tests/test_accessor.py @@ -2,11 +2,10 @@ import numpy as np import pandas as pd -import dask import pytest - from pandas.testing import assert_series_equal +import dask from dask import dataframe as dd from cudf import DataFrame, Series, date_range