From 3a6cfcaa60402258ed521dec8a06c29abc29365b Mon Sep 17 00:00:00 2001 From: ShisuiUzumaki Date: Tue, 13 Dec 2022 22:10:56 +0500 Subject: [PATCH 1/8] assertion error fix added in pandas/core/indexes/base.py --- pandas/core/indexes/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 7b8ba79789f41..922910d7005c8 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2425,6 +2425,13 @@ def is_categorical(self) -> bool: >>> s.index.is_categorical() False """ + warnings.warn( + f"{type(self).__name__}.is_categorical is deprecated." + "Use pandas.api.types.is_categorical_dtype instead", + FutureWarning, + stacklevel=find_stack_level(), + ) + return self.inferred_type in ["categorical"] @final From fc26996e785863c6f63bbe738e469011769ffb4e Mon Sep 17 00:00:00 2001 From: ShisuiUzumaki Date: Mon, 12 Dec 2022 09:36:55 +0500 Subject: [PATCH 2/8] changes made to pandas/core/infexes/base.py for is_interval deprecation in class Index --- pandas/core/indexes/base.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index fc2c51166a737..460f5e8b0132f 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -89,6 +89,7 @@ ensure_object, ensure_platform_int, is_bool_dtype, + is_interval_dtype, is_categorical_dtype, is_dtype_equal, is_ea_or_datetimelike_dtype, @@ -2209,7 +2210,7 @@ def is_boolean(self) -> bool: is_numeric : Check if the Index only consists of numeric data. is_object : Check if the Index is of the object dtype. is_categorical : Check if the Index holds categorical data. - is_interval : Check if the Index holds Interval objects. + is_interval : Check if the Index holds Interval objects (deprecated). Examples -------- @@ -2253,7 +2254,7 @@ def is_integer(self) -> bool: is_numeric : Check if the Index only consists of numeric data. is_object : Check if the Index is of the object dtype. is_categorical : Check if the Index holds categorical data (deprecated). - is_interval : Check if the Index holds Interval objects. + is_interval : Check if the Index holds Interval objects (deprecated). Examples -------- @@ -2301,7 +2302,7 @@ def is_floating(self) -> bool: is_numeric : Check if the Index only consists of numeric data. is_object : Check if the Index is of the object dtype. is_categorical : Check if the Index holds categorical data (deprecated). - is_interval : Check if the Index holds Interval objects. + is_interval : Check if the Index holds Interval objects (deprecated). Examples -------- @@ -2346,7 +2347,7 @@ def is_numeric(self) -> bool: is_floating : Check if the Index is a floating type (deprecated). is_object : Check if the Index is of the object dtype. is_categorical : Check if the Index holds categorical data (deprecated). - is_interval : Check if the Index holds Interval objects. + is_interval : Check if the Index holds Interval objects (deprecated). Examples -------- @@ -2389,7 +2390,7 @@ def is_object(self) -> bool: is_floating : Check if the Index is a floating type (deprecated). is_numeric : Check if the Index only consists of numeric data. is_categorical : Check if the Index holds categorical data (deprecated). - is_interval : Check if the Index holds Interval objects. + is_interval : Check if the Index holds Interval objects (deprecated). Examples -------- @@ -2433,7 +2434,7 @@ def is_categorical(self) -> bool: is_floating : Check if the Index is a floating type (deprecated). is_numeric : Check if the Index only consists of numeric data. is_object : Check if the Index is of the object dtype. - is_interval : Check if the Index holds Interval objects. + is_interval : Check if the Index holds Interval objects (deprecated). Examples -------- @@ -2470,6 +2471,9 @@ def is_interval(self) -> bool: """ Check if the Index holds Interval objects. + .. deprecated:: 2.0.0 + Use `pandas.api.types.is_interval_dtype` instead. + Returns ------- bool @@ -2496,6 +2500,12 @@ def is_interval(self) -> bool: >>> idx.is_interval() False """ + warnings.warn( + f"{type(self).__name__}.is_interval is deprecated." + "Use pandas.api.types.is_interval_dtype instead", + FutureWarning, + stacklevel=find_stack_level(), + ) return self.inferred_type in ["interval"] @final From 4e3aa15de324132e259dff43d55d22dfbd922576 Mon Sep 17 00:00:00 2001 From: ShisuiUzumaki Date: Mon, 12 Dec 2022 09:55:17 +0500 Subject: [PATCH 3/8] changes made to pandas/tests//indexes/common.py to test deprecation of is_interval --- pandas/tests/indexes/common.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandas/tests/indexes/common.py b/pandas/tests/indexes/common.py index cb17e7529ec7b..cd4cf9dd61b97 100644 --- a/pandas/tests/indexes/common.py +++ b/pandas/tests/indexes/common.py @@ -823,6 +823,12 @@ def test_is_categorical_is_deprecated(self, simple_index): ): idx.is_categorical() + def test_is_interval_is_deprecated(self, simple_index): + # GH50042 + idx = simple_index + with tm.assert_produces_warning(FutureWarning): + idx.is_interval() + class NumericBase(Base): """ From d808c25c3dbe031ed4a9bd0fce4d071f1cc55c90 Mon Sep 17 00:00:00 2001 From: ShisuiUzumaki Date: Mon, 12 Dec 2022 10:18:11 +0500 Subject: [PATCH 4/8] docs/source/whatsnew/v2.0.0.rst edited for index.is_interval --- doc/source/whatsnew/v2.0.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 605f1d4b26e13..c42f02c0be780 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -616,6 +616,7 @@ Deprecations - :meth:`Index.is_floating` has been deprecated. Use :func:`pandas.api.types.is_float_dtype` instead (:issue:`50042`) - :meth:`Index.holds_integer` has been deprecated. Use :func:`pandas.api.types.infer_dtype` instead (:issue:`50243`) - :meth:`Index.is_categorical` has been deprecated. Use :func:`pandas.api.types.is_categorical_dtype` instead (:issue:`50042`) +- :meth:`Index.is_interval` has been deprecated. Use :func:`pandas.api.types.is_intterval_dtype` instead (:issue:`50042`) .. --------------------------------------------------------------------------- .. _whatsnew_200.prior_deprecations: From 57a2b11de5a528dc70c9cbe5d093073ccdb9c39b Mon Sep 17 00:00:00 2001 From: ShisuiUzumaki Date: Mon, 12 Dec 2022 11:11:19 +0500 Subject: [PATCH 5/8] changes in pandas/core/indexes/base.py - removed extra import of is_interva;_dtype --- pandas/core/indexes/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 460f5e8b0132f..62af72685a3e9 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -89,7 +89,6 @@ ensure_object, ensure_platform_int, is_bool_dtype, - is_interval_dtype, is_categorical_dtype, is_dtype_equal, is_ea_or_datetimelike_dtype, From b07cb5a2d811f861e919ea629199ba51c31c2bd7 Mon Sep 17 00:00:00 2001 From: ShisuiUzumaki Date: Mon, 16 Jan 2023 08:55:51 +0500 Subject: [PATCH 6/8] brnahc state before rebase --- .pre-commit-config.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 118d77ff71151..95bcff367e4ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -114,6 +114,11 @@ repos: rev: v0.6.7 hooks: - id: sphinx-lint +- repo: https://github.com/asottile/yesqa + rev: v1.4.0 + hooks: + - id: yesqa + additional_dependencies: *flake8_dependencies - repo: local hooks: # NOTE: we make `black` a local hook because if it's installed from @@ -437,9 +442,3 @@ repos: additional_dependencies: - autotyping==22.9.0 - libcst==0.4.7 - - id: check-test-naming - name: check that test names start with 'test' - entry: python -m scripts.check_test_naming - types: [python] - files: ^pandas/tests - language: python From 5cb50fa2e34072b7fa34717fd1be39aa73089355 Mon Sep 17 00:00:00 2001 From: ShisuiUzumaki Date: Mon, 23 Jan 2023 09:48:30 +0500 Subject: [PATCH 7/8] Fixed error in .pre-commit-config.yaml file --- .pre-commit-config.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95bcff367e4ce..a5eea2155fa03 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -114,11 +114,6 @@ repos: rev: v0.6.7 hooks: - id: sphinx-lint -- repo: https://github.com/asottile/yesqa - rev: v1.4.0 - hooks: - - id: yesqa - additional_dependencies: *flake8_dependencies - repo: local hooks: # NOTE: we make `black` a local hook because if it's installed from From 13600dabe26d33406c3a87e7704222c3b5440674 Mon Sep 17 00:00:00 2001 From: ShisuiUzumaki Date: Tue, 24 Jan 2023 09:05:41 +0500 Subject: [PATCH 8/8] unwanted changed fixed in .pre-commit-cofig.yaml --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a5eea2155fa03..118d77ff71151 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -437,3 +437,9 @@ repos: additional_dependencies: - autotyping==22.9.0 - libcst==0.4.7 + - id: check-test-naming + name: check that test names start with 'test' + entry: python -m scripts.check_test_naming + types: [python] + files: ^pandas/tests + language: python