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

Skip to content

Commit 231704f

Browse files
committed
[TST] Add unit test for consistency of datetime units between mpl.dates and jpl_units
1 parent e25f65b commit 231704f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/matplotlib/tests/test_units.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ def test_jpl_barh_units():
156156
ax.set_xlim([b - 1 * day, b + w[-1] + (1.001) * day])
157157

158158

159+
def test_jpl_datetime_units_consistent():
160+
import matplotlib.testing.jpl_units as units
161+
units.register()
162+
163+
dt = datetime(2009, 4, 26)
164+
jpl = units.Epoch("ET", dt=dt)
165+
dt_conv = munits.registry.get_converter(dt).convert(dt, None, None)
166+
jpl_conv = munits.registry.get_converter(jpl).convert(jpl, None, None)
167+
assert dt_conv == jpl_conv
168+
169+
159170
def test_empty_arrays():
160171
# Check that plotting an empty array with a dtype works
161172
plt.scatter(np.array([], dtype='datetime64[ns]'), np.array([]))

0 commit comments

Comments
 (0)