Skip to content

CLN changed .format to f-string for test_converter.py, test_datetimel… #30248

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
Dec 13, 2019
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/plotting/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _assert_less(ts1, ts2):
val1 = self.dtc.convert(ts1, None, None)
val2 = self.dtc.convert(ts2, None, None)
if not val1 < val2:
raise AssertionError("{0} is not less than {1}.".format(val1, val2))
raise AssertionError(f"{val1} is not less than {val2}.")

# Matplotlib's time representation using floats cannot distinguish
# intervals smaller than ~10 microsecond in the common range of years.
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ def test_plot_outofbounds_datetime(self):

def test_format_timedelta_ticks_narrow(self):

expected_labels = ["00:00:00.0000000{:0>2d}".format(i) for i in np.arange(10)]
expected_labels = [f"00:00:00.0000000{i:0>2d}" for i in np.arange(10)]

rng = timedelta_range("0", periods=10, freq="ns")
df = DataFrame(np.random.randn(len(rng), 3), rng)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/plotting/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def test_pie_series(self):
ax = _check_plot_works(
series.plot.pie, colors=color_args, autopct="%.2f", fontsize=7
)
pcts = ["{0:.2f}".format(s * 100) for s in series.values / float(series.sum())]
pcts = [f"{s*100:.2f}" for s in series.values / float(series.sum())]
expected_texts = list(chain.from_iterable(zip(series.index, pcts)))
self._check_text_labels(ax.texts, expected_texts)
for t in ax.texts:
Expand Down Expand Up @@ -865,15 +865,15 @@ def test_time_series_plot_color_with_empty_kwargs(self):

def test_xticklabels(self):
# GH11529
s = Series(np.arange(10), index=["P{i:02d}".format(i=i) for i in range(10)])
s = Series(np.arange(10), index=[f"P{i:02d}" for i in range(10)])
_, ax = self.plt.subplots()
ax = s.plot(xticks=[0, 3, 5, 9], ax=ax)
exp = ["P{i:02d}".format(i=i) for i in [0, 3, 5, 9]]
exp = [f"P{i:02d}" for i in [0, 3, 5, 9]]
self._check_text_labels(ax.get_xticklabels(), exp)

def test_xtick_barPlot(self):
# GH28172
s = pd.Series(range(10), index=["P{i:02d}".format(i=i) for i in range(10)])
s = pd.Series(range(10), index=[f"P{i:02d}" for i in range(10)])
ax = s.plot.bar(xticks=range(0, 11, 2))
exp = np.array(list(range(0, 11, 2)))
tm.assert_numpy_array_equal(exp, ax.get_xticks())
Expand Down