Skip to content

Commit 762b89c

Browse files
jbrockmendeljreback
authored andcommitted
CLN: Exception in io/plotting (#28720)
1 parent 65815e6 commit 762b89c

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

pandas/plotting/_matplotlib/tools.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212

1313
def format_date_labels(ax, rot):
1414
# mini version of autofmt_xdate
15-
try:
16-
for label in ax.get_xticklabels():
17-
label.set_ha("right")
18-
label.set_rotation(rot)
19-
fig = ax.get_figure()
20-
fig.subplots_adjust(bottom=0.2)
21-
except Exception: # pragma: no cover
22-
pass
15+
for label in ax.get_xticklabels():
16+
label.set_ha("right")
17+
label.set_rotation(rot)
18+
fig = ax.get_figure()
19+
fig.subplots_adjust(bottom=0.2)
2320

2421

2522
def table(ax, data, rowLabels=None, colLabels=None, **kwargs):

pandas/tests/io/test_sql.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,16 @@ def _transaction_test(self):
539539
with self.pandasSQL.run_transaction() as trans:
540540
trans.execute("CREATE TABLE test_trans (A INT, B TEXT)")
541541

542+
class DummyException(Exception):
543+
pass
544+
542545
# Make sure when transaction is rolled back, no rows get inserted
543546
ins_sql = "INSERT INTO test_trans (A,B) VALUES (1, 'blah')"
544547
try:
545548
with self.pandasSQL.run_transaction() as trans:
546549
trans.execute(ins_sql)
547-
raise Exception("error")
548-
except Exception:
550+
raise DummyException("error")
551+
except DummyException:
549552
# ignore raised exception
550553
pass
551554
res = self.pandasSQL.read_query("SELECT * FROM test_trans")

pandas/tests/plotting/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def _check_plot_works(f, filterwarnings="always", **kwargs):
536536

537537
plt.clf()
538538

539-
ax = kwargs.get("ax", fig.add_subplot(211)) # noqa
539+
kwargs.get("ax", fig.add_subplot(211))
540540
ret = f(**kwargs)
541541

542542
assert_is_valid_plot_return_object(ret)

pandas/tests/plotting/test_datetimelike.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1553,12 +1553,9 @@ def _check_plot_works(f, freq=None, series=None, *args, **kwargs):
15531553
assert ax.freq == freq
15541554

15551555
ax = fig.add_subplot(212)
1556-
try:
1557-
kwargs["ax"] = ax
1558-
ret = f(*args, **kwargs)
1559-
assert ret is not None # do something more intelligent
1560-
except Exception:
1561-
pass
1556+
kwargs["ax"] = ax
1557+
ret = f(*args, **kwargs)
1558+
assert ret is not None # TODO: do something more intelligent
15621559

15631560
with ensure_clean(return_filelike=True) as path:
15641561
plt.savefig(path)

0 commit comments

Comments
 (0)