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

Skip to content

Commit 7057ddf

Browse files
committed
FIX latching logic simplified
1 parent a4bd0c5 commit 7057ddf

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

lib/matplotlib/dates.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,13 @@ def _get_rc_timezone():
222222

223223
# default epoch: passed to np.datetime64...
224224
_epoch = None
225-
_epoch_used = False
226225

227226

228227
def _reset_epoch_test_example():
229-
"""Reset the Matplotlib date epoch to its rcParams value."""
228+
"""Reset the Matplotlib date epoch so it can be set again."""
230229
global _epoch
231-
global _epoch_used
232230

233-
_epoch_used = False
234-
_epoch = matplotlib.rcParams['date.epoch']
231+
_epoch = None
235232

236233

237234
def set_epoch(epoch):
@@ -260,8 +257,7 @@ def set_epoch(epoch):
260257
261258
"""
262259
global _epoch
263-
global _epoch_used
264-
if _epoch_used:
260+
if _epoch is not None:
265261
raise RuntimeError('set_epoch must be called before dates plotted.')
266262
_epoch = epoch
267263

@@ -276,13 +272,9 @@ def get_epoch():
276272
String for the epoch (parsable by `numpy.datetime64`)
277273
"""
278274
global _epoch
279-
global _epoch_used
280275

281276
if _epoch is None:
282277
_epoch = matplotlib.rcParams['date.epoch']
283-
# if get_epoch is called, then set_epoch can no longer be called.
284-
# _epoch_used is the latch for checking this.
285-
_epoch_used = True
286278
return _epoch
287279

288280

0 commit comments

Comments
 (0)