Skip to content

Commit

Permalink
Fix issue with UnitsRegistry being overriden
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Jun 1, 2021
1 parent 3535bd8 commit a39f679
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
76 changes: 76 additions & 0 deletions before
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
glue/viewers/histogram/qt/tests/test_data_viewer.py HERE3 <matplotlib.dates.AutoDateLocator object at 0x7f6e4aac9340> <matplotlib.dates.AutoDateFormatter object at 0x7f6e4aac9580>
HERE1 1970-04-11
HERE2 719263.0
HERE1 1971-02-05
HERE2 719563.0
HERE1 1970-04-11
HERE2 719263.0
HERE1 1971-02-05
HERE2 719563.0
HERE1 1970-04-14
HERE2 719266.0
HERE1 1971-02-05
HERE2 719563.0
HERE3 <matplotlib.dates.AutoDateLocator object at 0x7f6e03595730> <matplotlib.dates.AutoDateFormatter object at 0x7f6e03595940>
HERE3 <matplotlib.dates.AutoDateLocator object at 0x7f6e035e2cd0> <matplotlib.dates.AutoDateFormatter object at 0x7f6e03595bb0>
HERE1 1970-04-14
HERE2 719266.0
HERE1 1971-02-05
HERE2 719563.0
.
glue/viewers/scatter/qt/tests/test_data_viewer.py HERE3 <matplotlib.dates.AutoDateLocator object at 0x7f6e024d1910> <matplotlib.dates.AutoDateFormatter object at 0x7f6e024d1b20>
HERE1 1970-03-30
HERE2 719251.0
HERE1 1971-02-17
HERE2 719575.0
HERE1 1970-03-30
HERE2 719251.0
HERE1 1971-02-17
HERE2 719575.0
HERE1 []
HERE1 []
HERE1 1970-03-30
HERE2 719251.0
HERE1 1971-02-17
HERE2 719575.0
HERE3 <matplotlib.dates.AutoDateLocator object at 0x7f6e024f1dc0> <matplotlib.dates.AutoDateFormatter object at 0x7f6e024f1fd0>
HERE1 1970-07-08
HERE2 719351.0
HERE1 1971-05-28
HERE2 719675.0
HERE1 1970-03-30
HERE2 719251.0
HERE1 1971-02-17
HERE2 719575.0
HERE1 1970-07-08
HERE2 719351.0
HERE1 1971-05-28
HERE2 719675.0
HERE1 []
HERE1 []
HERE1 []
HERE1 []
HERE1 1970-03-30
HERE2 719251.0
HERE1 1971-02-17
HERE2 719575.0
HERE1 1970-03-30
HERE2 719251.0
HERE1 1971-02-17
HERE2 719575.0
HERE1 1970-04-14
HERE2 719266.0
HERE1 1971-02-17
HERE2 719575.0
HERE3 <matplotlib.dates.AutoDateLocator object at 0x7f6e02483340> <matplotlib.dates.AutoDateFormatter object at 0x7f6e02483550>
HERE3 <matplotlib.dates.AutoDateLocator object at 0x7f6e0250c8e0> <matplotlib.dates.AutoDateFormatter object at 0x7f6e024837c0>
HERE1 1970-04-14
HERE2 719266.0
HERE1 1971-02-17
HERE2 719575.0
HERE1 []
HERE1 []
HERE1 []
HERE1 []
HERE1 []
HERE1 []
7 changes: 7 additions & 0 deletions glue/_mpl_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import numpy as np


class MatplotlibBackendSetter(object):
Expand Down Expand Up @@ -46,3 +47,9 @@ def set_mpl_backend():
# Explicitly switch backend
from matplotlib.pyplot import switch_backend
switch_backend('agg')

# We override the datetime64 units.registry entry to use our class. We do
# this here to make sure that rcdefaults hasn't reset this.
import matplotlib.units as units
from glue.utils.matplotlib import Datetime64Converter
units.registry[np.datetime64] = Datetime64Converter()
3 changes: 3 additions & 0 deletions glue/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def pytest_configure(config):

os.environ['GLUE_TESTING'] = 'True'

from glue._mpl_backend import set_mpl_backend
set_mpl_backend()

if config.getoption('no_optional_skip'):
from glue.tests import helpers
for attr in helpers.__dict__:
Expand Down

0 comments on commit a39f679

Please sign in to comment.