Skip to content

Commit

Permalink
Avoid indirect imports
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Nov 28, 2023
1 parent aba9dda commit e2f6fb7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions pandas/tests/extension/test_masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
)
from pandas.compat.numpy import np_version_gt2

from pandas.core.dtypes.common import (
is_float_dtype,
is_signed_integer_dtype,
is_unsigned_integer_dtype,
)

import pandas as pd
import pandas._testing as tm
from pandas.core.arrays.boolean import BooleanDtype
Expand Down Expand Up @@ -281,23 +287,23 @@ def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool):
tm.assert_almost_equal(result, expected)

def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
if tm.is_float_dtype(arr.dtype):
if is_float_dtype(arr.dtype):
cmp_dtype = arr.dtype.name
elif op_name in ["mean", "median", "var", "std", "skew"]:
cmp_dtype = "Float64"
elif op_name in ["max", "min"]:
cmp_dtype = arr.dtype.name
elif arr.dtype in ["Int64", "UInt64"]:
cmp_dtype = arr.dtype.name
elif tm.is_signed_integer_dtype(arr.dtype):
elif is_signed_integer_dtype(arr.dtype):
# TODO: Why does Window Numpy 2.0 dtype depend on skipna?
cmp_dtype = (
"Int32"
if (is_platform_windows() and (not np_version_gt2 or not skipna))
or not IS64
else "Int64"
)
elif tm.is_unsigned_integer_dtype(arr.dtype):
elif is_unsigned_integer_dtype(arr.dtype):
cmp_dtype = (
"UInt32"
if (is_platform_windows() and (not np_version_gt2 or not skipna))
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/indexes/interval/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import pytest

from pandas.core.dtypes.common import is_unsigned_integer_dtype
from pandas.core.dtypes.dtypes import IntervalDtype

from pandas import (
Expand Down Expand Up @@ -330,7 +331,7 @@ def get_kwargs_from_breaks(self, breaks, closed="right"):
converts intervals in breaks format to a dictionary of kwargs to
specific to the format expected by IntervalIndex.from_tuples
"""
if tm.is_unsigned_integer_dtype(breaks):
if is_unsigned_integer_dtype(breaks):
pytest.skip(f"{breaks.dtype} not relevant IntervalIndex.from_tuples tests")

if len(breaks) == 0:
Expand Down Expand Up @@ -388,7 +389,7 @@ def get_kwargs_from_breaks(self, breaks, closed="right"):
converts intervals in breaks format to a dictionary of kwargs to
specific to the format expected by the IntervalIndex/Index constructors
"""
if tm.is_unsigned_integer_dtype(breaks):
if is_unsigned_integer_dtype(breaks):
pytest.skip(f"{breaks.dtype} not relevant for class constructor tests")

if len(breaks) == 0:
Expand Down

0 comments on commit e2f6fb7

Please sign in to comment.