Skip to content

STYLE: Inconsistent namespace - dtypes (pandas-dev#39992) #40161

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 1 commit into from
Mar 2, 2021
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
2 changes: 1 addition & 1 deletion pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ class TestCategoricalDtypeParametrized:
np.arange(1000),
["a", "b", 10, 2, 1.3, True],
[True, False],
pd.date_range("2017", periods=4),
date_range("2017", periods=4),
],
)
def test_basic(self, categories, ordered):
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def test_unicode(self):
(object, None, True, "empty"),
],
)
@pytest.mark.parametrize("box", [pd.Series, np.array])
@pytest.mark.parametrize("box", [Series, np.array])
def test_object_empty(self, box, missing, dtype, skipna, expected):
# GH 23421
arr = box([missing, missing], dtype=dtype)
Expand Down Expand Up @@ -915,7 +915,7 @@ def test_infer_dtype_period(self):
arr = np.array([Period("2011-01", freq="D"), Period("2011-02", freq="M")])
assert lib.infer_dtype(arr, skipna=True) == "period"

@pytest.mark.parametrize("klass", [pd.array, pd.Series, pd.Index])
@pytest.mark.parametrize("klass", [pd.array, Series, Index])
@pytest.mark.parametrize("skipna", [True, False])
def test_infer_dtype_period_array(self, klass, skipna):
# https://github.com/pandas-dev/pandas/issues/23553
Expand Down Expand Up @@ -1264,7 +1264,7 @@ def test_interval(self):
inferred = lib.infer_dtype(Series(idx), skipna=False)
assert inferred == "interval"

@pytest.mark.parametrize("klass", [pd.array, pd.Series])
@pytest.mark.parametrize("klass", [pd.array, Series])
@pytest.mark.parametrize("skipna", [True, False])
@pytest.mark.parametrize("data", [["a", "b", "c"], ["a", "b", pd.NA]])
def test_string_dtype(self, data, skipna, klass):
Expand All @@ -1273,7 +1273,7 @@ def test_string_dtype(self, data, skipna, klass):
inferred = lib.infer_dtype(val, skipna=skipna)
assert inferred == "string"

@pytest.mark.parametrize("klass", [pd.array, pd.Series])
@pytest.mark.parametrize("klass", [pd.array, Series])
@pytest.mark.parametrize("skipna", [True, False])
@pytest.mark.parametrize("data", [[True, False, True], [True, False, pd.NA]])
def test_boolean_dtype(self, data, skipna, klass):
Expand Down
28 changes: 14 additions & 14 deletions pandas/tests/dtypes/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,16 @@ def test_isna_datetime(self):

def test_isna_old_datetimelike(self):
# isna_old should work for dt64tz, td64, and period, not just tznaive
dti = pd.date_range("2016-01-01", periods=3)
dti = date_range("2016-01-01", periods=3)
dta = dti._data
dta[-1] = pd.NaT
dta[-1] = NaT
expected = np.array([False, False, True], dtype=bool)

objs = [dta, dta.tz_localize("US/Eastern"), dta - dta, dta.to_period("D")]

for obj in objs:
with cf.option_context("mode.use_inf_as_na", True):
result = pd.isna(obj)
result = isna(obj)

tm.assert_numpy_array_equal(result, expected)

Expand Down Expand Up @@ -320,38 +320,38 @@ def test_period(self):
def test_decimal(self):
# scalars GH#23530
a = Decimal(1.0)
assert pd.isna(a) is False
assert pd.notna(a) is True
assert isna(a) is False
assert notna(a) is True

b = Decimal("NaN")
assert pd.isna(b) is True
assert pd.notna(b) is False
assert isna(b) is True
assert notna(b) is False

# array
arr = np.array([a, b])
expected = np.array([False, True])
result = pd.isna(arr)
result = isna(arr)
tm.assert_numpy_array_equal(result, expected)

result = pd.notna(arr)
result = notna(arr)
tm.assert_numpy_array_equal(result, ~expected)

# series
ser = Series(arr)
expected = Series(expected)
result = pd.isna(ser)
result = isna(ser)
tm.assert_series_equal(result, expected)

result = pd.notna(ser)
result = notna(ser)
tm.assert_series_equal(result, ~expected)

# index
idx = pd.Index(arr)
expected = np.array([False, True])
result = pd.isna(idx)
result = isna(idx)
tm.assert_numpy_array_equal(result, expected)

result = pd.notna(idx)
result = notna(idx)
tm.assert_numpy_array_equal(result, ~expected)


Expand Down Expand Up @@ -578,7 +578,7 @@ def _check_behavior(self, arr, expected):
tm.assert_numpy_array_equal(result, expected)

def test_basic(self):
arr = np.array([1, None, "foo", -5.1, pd.NaT, np.nan])
arr = np.array([1, None, "foo", -5.1, NaT, np.nan])
expected = np.array([False, True, False, False, True, True])

self._check_behavior(arr, expected)
Expand Down