Skip to content

GH: 624 - added new is_any_real_numeric_dtype function #715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pandas-stubs/api/types/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pandas._libs.lib import infer_dtype as infer_dtype

from pandas.core.dtypes.api import (
is_any_real_numeric_dtype as is_any_real_numeric_dtype,
is_array_like as is_array_like,
is_bool as is_bool,
is_bool_dtype as is_bool_dtype,
Expand Down
1 change: 1 addition & 0 deletions pandas-stubs/core/dtypes/api.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pandas.core.dtypes.common import (
is_any_real_numeric_dtype as is_any_real_numeric_dtype,
is_array_like as is_array_like,
is_bool as is_bool,
is_bool_dtype as is_bool_dtype,
Expand Down
1 change: 1 addition & 0 deletions pandas-stubs/core/dtypes/common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ def is_float_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_bool_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_extension_array_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_complex_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_any_real_numeric_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def pandas_dtype(dtype: object) -> DtypeObj: ...
7 changes: 7 additions & 0 deletions tests/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import numpy as np
import pandas as pd
from pandas.api.types import is_any_real_numeric_dtype
from pandas.core.arrays import BooleanArray # noqa: F401
from pandas.core.arrays import IntegerArray # noqa: F401
import pyarrow as pa
Expand Down Expand Up @@ -144,3 +145,9 @@ def test_arrow_dtype() -> None:
a_dt = pd.ArrowDtype(pa.int64())
check(assert_type(a_dt, pd.ArrowDtype), pd.ArrowDtype)
check(assert_type(a_dt.pyarrow_dtype, pa.DataType), pa.DataType)


def test_is_any_real_numeric_dtype() -> None:
check(assert_type(is_any_real_numeric_dtype(np.array([1, 2])), bool), bool)
check(assert_type(is_any_real_numeric_dtype(int), bool), bool)
check(assert_type(is_any_real_numeric_dtype(float), bool), bool)