Skip to content

Commit 73fbcc9

Browse files
authored
Fix styling (#40221)
1 parent e742820 commit 73fbcc9

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

pandas/tests/arrays/categorical/test_missing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ def test_use_inf_as_na_outside_context(self, values, expected):
154154
cat = Categorical(values)
155155

156156
with pd.option_context("mode.use_inf_as_na", True):
157-
result = pd.isna(cat)
157+
result = isna(cat)
158158
tm.assert_numpy_array_equal(result, expected)
159159

160-
result = pd.isna(Series(cat))
160+
result = isna(Series(cat))
161161
expected = Series(expected)
162162
tm.assert_series_equal(result, expected)
163163

164-
result = pd.isna(DataFrame(cat))
164+
result = isna(DataFrame(cat))
165165
expected = DataFrame(expected)
166166
tm.assert_frame_equal(result, expected)
167167

pandas/tests/arrays/datetimes/test_reductions.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,33 @@ def test_min_max(self, arr1d):
4040
assert result == expected
4141

4242
result = arr.min(skipna=False)
43-
assert result is pd.NaT
43+
assert result is NaT
4444

4545
result = arr.max(skipna=False)
46-
assert result is pd.NaT
46+
assert result is NaT
4747

4848
@pytest.mark.parametrize("tz", [None, "US/Central"])
4949
@pytest.mark.parametrize("skipna", [True, False])
5050
def test_min_max_empty(self, skipna, tz):
5151
dtype = DatetimeTZDtype(tz=tz) if tz is not None else np.dtype("M8[ns]")
5252
arr = DatetimeArray._from_sequence([], dtype=dtype)
5353
result = arr.min(skipna=skipna)
54-
assert result is pd.NaT
54+
assert result is NaT
5555

5656
result = arr.max(skipna=skipna)
57-
assert result is pd.NaT
57+
assert result is NaT
5858

5959
@pytest.mark.parametrize("tz", [None, "US/Central"])
6060
@pytest.mark.parametrize("skipna", [True, False])
6161
def test_median_empty(self, skipna, tz):
6262
dtype = DatetimeTZDtype(tz=tz) if tz is not None else np.dtype("M8[ns]")
6363
arr = DatetimeArray._from_sequence([], dtype=dtype)
6464
result = arr.median(skipna=skipna)
65-
assert result is pd.NaT
65+
assert result is NaT
6666

6767
arr = arr.reshape(0, 3)
6868
result = arr.median(axis=0, skipna=skipna)
69-
expected = type(arr)._from_sequence([pd.NaT, pd.NaT, pd.NaT], dtype=arr.dtype)
69+
expected = type(arr)._from_sequence([NaT, NaT, NaT], dtype=arr.dtype)
7070
tm.assert_equal(result, expected)
7171

7272
result = arr.median(axis=1, skipna=skipna)
@@ -79,7 +79,7 @@ def test_median(self, arr1d):
7979
result = arr.median()
8080
assert result == arr[0]
8181
result = arr.median(skipna=False)
82-
assert result is pd.NaT
82+
assert result is NaT
8383

8484
result = arr.dropna().median(skipna=False)
8585
assert result == arr[0]
@@ -90,7 +90,7 @@ def test_median(self, arr1d):
9090
def test_median_axis(self, arr1d):
9191
arr = arr1d
9292
assert arr.median(axis=0) == arr.median()
93-
assert arr.median(axis=0, skipna=False) is pd.NaT
93+
assert arr.median(axis=0, skipna=False) is NaT
9494

9595
msg = r"abs\(axis\) must be less than ndim"
9696
with pytest.raises(ValueError, match=msg):
@@ -102,7 +102,7 @@ def test_median_2d(self, arr1d):
102102

103103
# axis = None
104104
assert arr.median() == arr1d.median()
105-
assert arr.median(skipna=False) is pd.NaT
105+
assert arr.median(skipna=False) is NaT
106106

107107
# axis = 0
108108
result = arr.median(axis=0)
@@ -120,7 +120,7 @@ def test_median_2d(self, arr1d):
120120
tm.assert_equal(result, expected)
121121

122122
result = arr.median(axis=1, skipna=False)
123-
expected = type(arr)._from_sequence([pd.NaT], dtype=arr.dtype)
123+
expected = type(arr)._from_sequence([NaT], dtype=arr.dtype)
124124
tm.assert_equal(result, expected)
125125

126126
def test_mean(self, arr1d):
@@ -132,7 +132,7 @@ def test_mean(self, arr1d):
132132
result = arr.mean()
133133
assert result == expected
134134
result = arr.mean(skipna=False)
135-
assert result is pd.NaT
135+
assert result is NaT
136136

137137
result = arr.dropna().mean(skipna=False)
138138
assert result == expected

pandas/tests/arrays/interval/test_interval.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_shift(self):
9090
tm.assert_interval_array_equal(result, expected)
9191

9292
def test_shift_datetime(self):
93-
a = IntervalArray.from_breaks(pd.date_range("2000", periods=4))
93+
a = IntervalArray.from_breaks(date_range("2000", periods=4))
9494
result = a.shift(2)
9595
expected = a.take([-1, -1, 0], allow_fill=True)
9696
tm.assert_interval_array_equal(result, expected)
@@ -248,7 +248,7 @@ def test_arrow_array_missing():
248248
@pyarrow_skip
249249
@pytest.mark.parametrize(
250250
"breaks",
251-
[[0.0, 1.0, 2.0, 3.0], pd.date_range("2017", periods=4, freq="D")],
251+
[[0.0, 1.0, 2.0, 3.0], date_range("2017", periods=4, freq="D")],
252252
ids=["float", "datetime64[ns]"],
253253
)
254254
def test_arrow_table_roundtrip(breaks):
@@ -275,7 +275,7 @@ def test_arrow_table_roundtrip(breaks):
275275
@pyarrow_skip
276276
@pytest.mark.parametrize(
277277
"breaks",
278-
[[0.0, 1.0, 2.0, 3.0], pd.date_range("2017", periods=4, freq="D")],
278+
[[0.0, 1.0, 2.0, 3.0], date_range("2017", periods=4, freq="D")],
279279
ids=["float", "datetime64[ns]"],
280280
)
281281
def test_arrow_table_roundtrip_without_metadata(breaks):

pandas/tests/arrays/sparse/test_array.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def test_constructor_spindex_dtype_scalar_broadcasts(self):
185185
def test_constructor_inferred_fill_value(self, data, fill_value):
186186
result = SparseArray(data).fill_value
187187

188-
if pd.isna(fill_value):
189-
assert pd.isna(result)
188+
if isna(fill_value):
189+
assert isna(result)
190190
else:
191191
assert result == fill_value
192192

pandas/tests/arrays/test_datetimelike.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ def test_take_fill(self):
184184
arr = self.array_cls(data, freq="D")
185185

186186
result = arr.take([-1, 1], allow_fill=True, fill_value=None)
187-
assert result[0] is pd.NaT
187+
assert result[0] is NaT
188188

189189
result = arr.take([-1, 1], allow_fill=True, fill_value=np.nan)
190-
assert result[0] is pd.NaT
190+
assert result[0] is NaT
191191

192-
result = arr.take([-1, 1], allow_fill=True, fill_value=pd.NaT)
193-
assert result[0] is pd.NaT
192+
result = arr.take([-1, 1], allow_fill=True, fill_value=NaT)
193+
assert result[0] is NaT
194194

195195
def test_take_fill_str(self, arr1d):
196196
# Cast str fill_value matching other fill_value-taking methods
@@ -205,7 +205,7 @@ def test_take_fill_str(self, arr1d):
205205
def test_concat_same_type(self, arr1d):
206206
arr = arr1d
207207
idx = self.index_cls(arr)
208-
idx = idx.insert(0, pd.NaT)
208+
idx = idx.insert(0, NaT)
209209
arr = self.array_cls(idx)
210210

211211
result = arr._concat_same_type([arr[:-1], arr[1:], arr])
@@ -221,7 +221,7 @@ def test_unbox_scalar(self):
221221
expected = arr._data.dtype.type
222222
assert isinstance(result, expected)
223223

224-
result = arr._unbox_scalar(pd.NaT)
224+
result = arr._unbox_scalar(NaT)
225225
assert isinstance(result, expected)
226226

227227
msg = f"'value' should be a {self.dtype.__name__}."
@@ -234,7 +234,7 @@ def test_check_compatible_with(self):
234234

235235
arr._check_compatible_with(arr[0])
236236
arr._check_compatible_with(arr[:1])
237-
arr._check_compatible_with(pd.NaT)
237+
arr._check_compatible_with(NaT)
238238

239239
def test_scalar_from_string(self):
240240
data = np.arange(10, dtype="i8") * 24 * 3600 * 10 ** 9
@@ -254,15 +254,15 @@ def test_reduce_invalid(self):
254254
def test_fillna_method_doesnt_change_orig(self, method):
255255
data = np.arange(10, dtype="i8") * 24 * 3600 * 10 ** 9
256256
arr = self.array_cls(data, freq="D")
257-
arr[4] = pd.NaT
257+
arr[4] = NaT
258258

259259
fill_value = arr[3] if method == "pad" else arr[5]
260260

261261
result = arr.fillna(method=method)
262262
assert result[4] == fill_value
263263

264264
# check that the original was not changed
265-
assert arr[4] is pd.NaT
265+
assert arr[4] is NaT
266266

267267
def test_searchsorted(self):
268268
data = np.arange(10, dtype="i8") * 24 * 3600 * 10 ** 9
@@ -286,7 +286,7 @@ def test_searchsorted(self):
286286

287287
# GH#29884 match numpy convention on whether NaT goes
288288
# at the end or the beginning
289-
result = arr.searchsorted(pd.NaT)
289+
result = arr.searchsorted(NaT)
290290
if np_version_under1p18:
291291
# Following numpy convention, NaT goes at the beginning
292292
# (unlike NaN which goes at the end)
@@ -616,7 +616,7 @@ def test_median(self, arr1d):
616616

617617

618618
class TestDatetimeArray(SharedTests):
619-
index_cls = pd.DatetimeIndex
619+
index_cls = DatetimeIndex
620620
array_cls = DatetimeArray
621621
dtype = Timestamp
622622

@@ -749,7 +749,7 @@ def test_from_dti(self, arr1d):
749749

750750
# Check that Index.__new__ knows what to do with DatetimeArray
751751
dti2 = pd.Index(arr)
752-
assert isinstance(dti2, pd.DatetimeIndex)
752+
assert isinstance(dti2, DatetimeIndex)
753753
assert list(dti2) == list(arr)
754754

755755
def test_astype_object(self, arr1d):
@@ -800,7 +800,7 @@ def test_to_period_2d(self, arr1d):
800800
expected = arr1d.to_period("D").reshape(1, -1)
801801
tm.assert_period_array_equal(result, expected)
802802

803-
@pytest.mark.parametrize("propname", pd.DatetimeIndex._bool_ops)
803+
@pytest.mark.parametrize("propname", DatetimeIndex._bool_ops)
804804
def test_bool_properties(self, arr1d, propname):
805805
# in this case _bool_ops is just `is_leap_year`
806806
dti = self.index_cls(arr1d)
@@ -812,7 +812,7 @@ def test_bool_properties(self, arr1d, propname):
812812

813813
tm.assert_numpy_array_equal(result, expected)
814814

815-
@pytest.mark.parametrize("propname", pd.DatetimeIndex._field_ops)
815+
@pytest.mark.parametrize("propname", DatetimeIndex._field_ops)
816816
def test_int_properties(self, arr1d, propname):
817817
if propname in ["week", "weekofyear"]:
818818
# GH#33595 Deprecate week and weekofyear
@@ -849,7 +849,7 @@ def test_take_fill_valid(self, arr1d):
849849
# Timestamp with mismatched tz-awareness
850850
arr.take([-1, 1], allow_fill=True, fill_value=now)
851851

852-
value = pd.NaT.value
852+
value = NaT.value
853853
msg = f"value should be a '{arr1d._scalar_type.__name__}' or 'NaT'. Got"
854854
with pytest.raises(TypeError, match=msg):
855855
# require NaT, not iNaT, as it could be confused with an integer
@@ -908,7 +908,7 @@ def test_strftime(self, arr1d):
908908

909909
def test_strftime_nat(self):
910910
# GH 29578
911-
arr = DatetimeArray(DatetimeIndex(["2019-01-01", pd.NaT]))
911+
arr = DatetimeArray(DatetimeIndex(["2019-01-01", NaT]))
912912

913913
result = arr.strftime("%Y-%m-%d")
914914
expected = np.array(["2019-01-01", np.nan], dtype=object)
@@ -1064,7 +1064,7 @@ def test_astype_object(self, arr1d):
10641064
def test_take_fill_valid(self, arr1d):
10651065
arr = arr1d
10661066

1067-
value = pd.NaT.value
1067+
value = NaT.value
10681068
msg = f"value should be a '{arr1d._scalar_type.__name__}' or 'NaT'. Got"
10691069
with pytest.raises(TypeError, match=msg):
10701070
# require NaT, not iNaT, as it could be confused with an integer
@@ -1152,7 +1152,7 @@ def test_strftime(self, arr1d):
11521152

11531153
def test_strftime_nat(self):
11541154
# GH 29578
1155-
arr = PeriodArray(PeriodIndex(["2019-01-01", pd.NaT], dtype="period[D]"))
1155+
arr = PeriodArray(PeriodIndex(["2019-01-01", NaT], dtype="period[D]"))
11561156

11571157
result = arr.strftime("%Y-%m-%d")
11581158
expected = np.array(["2019-01-01", np.nan], dtype=object)
@@ -1164,18 +1164,18 @@ def test_strftime_nat(self):
11641164
[
11651165
(
11661166
TimedeltaIndex(["1 Day", "3 Hours", "NaT"])._data,
1167-
(pd.NaT, np.timedelta64("NaT", "ns")),
1167+
(NaT, np.timedelta64("NaT", "ns")),
11681168
),
11691169
(
11701170
pd.date_range("2000-01-01", periods=3, freq="D")._data,
1171-
(pd.NaT, np.datetime64("NaT", "ns")),
1171+
(NaT, np.datetime64("NaT", "ns")),
11721172
),
1173-
(pd.period_range("2000-01-01", periods=3, freq="D")._data, (pd.NaT,)),
1173+
(pd.period_range("2000-01-01", periods=3, freq="D")._data, (NaT,)),
11741174
],
11751175
ids=lambda x: type(x).__name__,
11761176
)
11771177
def test_casting_nat_setitem_array(array, casting_nats):
1178-
expected = type(array)._from_sequence([pd.NaT, array[1], array[2]])
1178+
expected = type(array)._from_sequence([NaT, array[1], array[2]])
11791179

11801180
for nat in casting_nats:
11811181
arr = array.copy()
@@ -1188,15 +1188,15 @@ def test_casting_nat_setitem_array(array, casting_nats):
11881188
[
11891189
(
11901190
TimedeltaIndex(["1 Day", "3 Hours", "NaT"])._data,
1191-
(np.datetime64("NaT", "ns"), pd.NaT.value),
1191+
(np.datetime64("NaT", "ns"), NaT.value),
11921192
),
11931193
(
11941194
pd.date_range("2000-01-01", periods=3, freq="D")._data,
1195-
(np.timedelta64("NaT", "ns"), pd.NaT.value),
1195+
(np.timedelta64("NaT", "ns"), NaT.value),
11961196
),
11971197
(
11981198
pd.period_range("2000-01-01", periods=3, freq="D")._data,
1199-
(np.datetime64("NaT", "ns"), np.timedelta64("NaT", "ns"), pd.NaT.value),
1199+
(np.datetime64("NaT", "ns"), np.timedelta64("NaT", "ns"), NaT.value),
12001200
),
12011201
],
12021202
ids=lambda x: type(x).__name__,
@@ -1226,7 +1226,7 @@ def test_to_numpy_extra(array):
12261226
else:
12271227
isnan = np.isnan
12281228

1229-
array[0] = pd.NaT
1229+
array[0] = NaT
12301230
original = array.copy()
12311231

12321232
result = array.to_numpy()

0 commit comments

Comments
 (0)