Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7abf30

Browse files
committed
FIX: remove try, add test
1 parent 455fbeb commit a7abf30

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,16 @@ def _validate_date_converter(s):
183183
cbook._warn_external(f'date.converter string must be "auto" '
184184
f'or "concise", not "{s}". Check your '
185185
'matplotlibrc')
186-
try:
187-
import matplotlib.dates as mdates
188-
mdates._rcParam_helper.set_converter(s)
189-
except Exception as e:
190-
pass
186+
import matplotlib.dates as mdates
187+
mdates._rcParam_helper.set_converter(s)
191188

192189

193190
def _validate_date_int_mult(s):
194191
if s is None:
195192
return
196193
s = validate_bool(s)
197-
try:
198-
import matplotlib.dates as mdates
199-
mdates._rcParam_helper.set_int_mult(s)
200-
except Exception as e:
201-
pass
194+
import matplotlib.dates as mdates
195+
mdates._rcParam_helper.set_int_mult(s)
202196

203197

204198
def _validate_tex_preamble(s):

lib/matplotlib/tests/test_dates.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,8 @@ def test_change_converter():
977977
fig.canvas.draw()
978978
assert ax.get_xticklabels()[0].get_text() == 'Jan 01 2020'
979979
assert ax.get_xticklabels()[1].get_text() == 'Jan 15 2020'
980+
with pytest.warns(UserWarning) as rec:
981+
plt.rcParams['date.converter'] = 'boo'
980982

981983

982984
def test_change_interval_multiples():

0 commit comments

Comments
 (0)