Skip to content

Commit 45d093d

Browse files
authored
Seventh batch of changes (#31986)
1 parent cc4c0b3 commit 45d093d

File tree

8 files changed

+18
-22
lines changed

8 files changed

+18
-22
lines changed

pandas/tests/scalar/timestamp/test_constructors.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def test_constructor_nanosecond(self, result):
314314
def test_constructor_invalid_Z0_isostring(self, z):
315315
# GH 8910
316316
with pytest.raises(ValueError):
317-
Timestamp("2014-11-02 01:00{}".format(z))
317+
Timestamp(f"2014-11-02 01:00{z}")
318318

319319
@pytest.mark.parametrize(
320320
"arg",
@@ -455,9 +455,7 @@ def test_disallow_setting_tz(self, tz):
455455
@pytest.mark.parametrize("offset", ["+0300", "+0200"])
456456
def test_construct_timestamp_near_dst(self, offset):
457457
# GH 20854
458-
expected = Timestamp(
459-
"2016-10-30 03:00:00{}".format(offset), tz="Europe/Helsinki"
460-
)
458+
expected = Timestamp(f"2016-10-30 03:00:00{offset}", tz="Europe/Helsinki")
461459
result = Timestamp(expected).tz_convert("Europe/Helsinki")
462460
assert result == expected
463461

pandas/tests/scalar/timestamp/test_rendering.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TestTimestampRendering:
1717
)
1818
def test_repr(self, date, freq, tz):
1919
# avoid to match with timezone name
20-
freq_repr = "'{0}'".format(freq)
20+
freq_repr = f"'{freq}'"
2121
if tz.startswith("dateutil"):
2222
tz_repr = tz.replace("dateutil", "")
2323
else:

pandas/tests/scalar/timestamp/test_unary_ops.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,17 @@ def test_round_int64(self, timestamp, freq):
232232

233233
# test floor
234234
result = dt.floor(freq)
235-
assert result.value % unit == 0, "floor not a {} multiple".format(freq)
235+
assert result.value % unit == 0, f"floor not a {freq} multiple"
236236
assert 0 <= dt.value - result.value < unit, "floor error"
237237

238238
# test ceil
239239
result = dt.ceil(freq)
240-
assert result.value % unit == 0, "ceil not a {} multiple".format(freq)
240+
assert result.value % unit == 0, f"ceil not a {freq} multiple"
241241
assert 0 <= result.value - dt.value < unit, "ceil error"
242242

243243
# test round
244244
result = dt.round(freq)
245-
assert result.value % unit == 0, "round not a {} multiple".format(freq)
245+
assert result.value % unit == 0, f"round not a {freq} multiple"
246246
assert abs(result.value - dt.value) <= unit // 2, "round error"
247247
if unit % 2 == 0 and abs(result.value - dt.value) == unit // 2:
248248
# round half to even

pandas/tests/series/methods/test_nlargest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class TestSeriesNLargestNSmallest:
9898
)
9999
def test_nlargest_error(self, r):
100100
dt = r.dtype
101-
msg = "Cannot use method 'n(larg|small)est' with dtype {dt}".format(dt=dt)
101+
msg = f"Cannot use method 'n(larg|small)est' with dtype {dt}"
102102
args = 2, len(r), 0, -1
103103
methods = r.nlargest, r.nsmallest
104104
for method, arg in product(methods, args):

pandas/tests/series/test_analytics.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ def test_validate_any_all_out_keepdims_raises(self, kwargs, func):
169169
name = func.__name__
170170

171171
msg = (
172-
r"the '{arg}' parameter is not "
173-
r"supported in the pandas "
174-
r"implementation of {fname}\(\)"
175-
).format(arg=param, fname=name)
172+
f"the '{param}' parameter is not "
173+
"supported in the pandas "
174+
fr"implementation of {name}\(\)"
175+
)
176176
with pytest.raises(ValueError, match=msg):
177177
func(s, **kwargs)
178178

pandas/tests/series/test_api.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ def test_constructor_subclass_dict(self, dict_subclass):
136136

137137
def test_constructor_ordereddict(self):
138138
# GH3283
139-
data = OrderedDict(
140-
("col{i}".format(i=i), np.random.random()) for i in range(12)
141-
)
139+
data = OrderedDict((f"col{i}", np.random.random()) for i in range(12))
142140

143141
series = Series(data)
144142
expected = Series(list(data.values()), list(data.keys()))
@@ -258,7 +256,7 @@ def get_dir(s):
258256
tm.makeIntIndex(10),
259257
tm.makeFloatIndex(10),
260258
Index([True, False]),
261-
Index(["a{}".format(i) for i in range(101)]),
259+
Index([f"a{i}" for i in range(101)]),
262260
pd.MultiIndex.from_tuples(zip("ABCD", "EFGH")),
263261
pd.MultiIndex.from_tuples(zip([0, 1, 2, 3], "EFGH")),
264262
],

pandas/tests/series/test_dtypes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def test_astype_categorical_to_other(self):
261261

262262
value = np.random.RandomState(0).randint(0, 10000, 100)
263263
df = DataFrame({"value": value})
264-
labels = ["{0} - {1}".format(i, i + 499) for i in range(0, 10000, 500)]
264+
labels = [f"{i} - {i + 499}" for i in range(0, 10000, 500)]
265265
cat_labels = Categorical(labels, labels)
266266

267267
df = df.sort_values(by=["value"], ascending=True)
@@ -384,9 +384,9 @@ def test_astype_generic_timestamp_no_frequency(self, dtype):
384384
s = Series(data)
385385

386386
msg = (
387-
r"The '{dtype}' dtype has no unit\. "
388-
r"Please pass in '{dtype}\[ns\]' instead."
389-
).format(dtype=dtype.__name__)
387+
fr"The '{dtype.__name__}' dtype has no unit\. "
388+
fr"Please pass in '{dtype.__name__}\[ns\]' instead."
389+
)
390390
with pytest.raises(ValueError, match=msg):
391391
s.astype(dtype)
392392

pandas/tests/series/test_ufunc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def __eq__(self, other) -> bool:
287287
return type(other) is Thing and self.value == other.value
288288

289289
def __repr__(self) -> str:
290-
return "Thing({})".format(self.value)
290+
return f"Thing({self.value})"
291291

292292
s = pd.Series([Thing(1), Thing(2)])
293293
result = np.add(s, Thing(1))

0 commit comments

Comments
 (0)