Skip to content

Commit cec46b5

Browse files
committed
DOC: add comment about JULIAN_OFFSET
1 parent fad3776 commit cec46b5

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

doc/api/next_api_changes/deprecations/17983-JMK.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ an accurate Matplotlib datenum relative to the new Matplotlib epoch
66
handling (`~.dates.get_epoch` and :rc:`date.epoch`). This version
77
reverts the deprecation.
88

9-
`~.dates.epoch2num`, `~.dates.julian2num` use :rc:`date.epoch`
10-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
Functions `~.dates.epoch2num` and ``julian2num`` use :rc:`date.epoch`
10+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1111

12-
Now `~.dates.epoch2num` and `~.dates.julian2num` return floating point
12+
Now `~.dates.epoch2num` and (undocumented) ``julian2num`` return floating point
1313
days since `~.dates.get_epoch` as set by :rc:`date.epoch`, instead of
1414
floating point days since the old epoch of "0000-12-31T00:00:00". If
1515
needed, you can translate from the new to old values as
16-
`old = new + mdates.date2num(np.datetime64('0000-12-31'))`
16+
``old = new + mdates.date2num(np.datetime64('0000-12-31'))``

lib/matplotlib/dates.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,13 @@ def _get_rc_timezone():
197197
Time-related constants.
198198
"""
199199
EPOCH_OFFSET = float(datetime.datetime(1970, 1, 1).toordinal())
200-
JULIAN_OFFSET = 1721424.5 # Julian date at 0001-01-01
200+
# EPOCH_OFFSET is not used by matplotlib
201+
JULIAN_OFFSET = 1721424.5 # Julian date at 0000-12-31
202+
# note that the Julian day epoch is achievable w/
203+
# np.datetime64('-4713-11-24T12:00:00'); datetime64 is proleptic
204+
# Gregorian and BC has a one-year offset. So
205+
# np.datetime64('0000-12-31') - np.datetime64('-4713-11-24T12:00') = 1721424.5
206+
# Ref: https://en.wikipedia.org/wiki/Julian_day
201207
MICROSECONDLY = SECONDLY + 1
202208
HOURS_PER_DAY = 24.
203209
MIN_PER_HOUR = 60.
@@ -445,7 +451,8 @@ def julian2num(j):
445451
Parameters
446452
----------
447453
j : float or sequence of floats
448-
Julian date(s) (days relative to 4713 BC Jan 1, 12:00:00)
454+
Julian date(s) (days relative to 4713 BC Jan 1, 12:00:00 Julian
455+
calendar or 4714 BC Nov 24, 12:00:00, proleptic Gregorian calendar)
449456
450457
Returns
451458
-------

setup.cfg.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[libs]
66
# By default, Matplotlib builds with LTO, which may be slow if you re-compile
77
# often, and don't need the space saving/speedup.
8-
#enable_lto = True
8+
enable_lto = False
99
# By default, Matplotlib downloads and builds its own copy of FreeType, and
1010
# builds its own copy of Qhull. You may set the following to True to instead
1111
# link against a system FreeType/Qhull.
@@ -18,6 +18,7 @@
1818
# image files) are installed by default, but that can be changed here.
1919
#tests = False
2020
#sample_data = True
21+
tests = True
2122

2223
[gui_support]
2324
# Matplotlib supports multiple GUI toolkits, known as backends.

0 commit comments

Comments
 (0)