desihub / specsim

Quick simulations of spectrograph response
2 stars 9 forks source link

Fix matplotlib errors when no $DISPLAY #88

Closed weaverba137 closed 6 years ago

weaverba137 commented 6 years ago

As reported by @sbailey, when running python setup.py test with astropy 2.x and with the $DISPLAY variable unset, multiple errors were reported. The cause turned out to be in fitgalsim.py, which imported matplotlib at the top level, without setting matplotlib.use('Agg').

It turns out that fitgalsim.py does not actually use matplotlib at all, so the solution was to remove the import entirely.

Technical note: The reason this is a problem in astropy 2.x is that astropy 2.x scans (imports) all files for tests (specifically doctests), not just the specsim/tests/test_*.py files.

weaverba137 commented 6 years ago

It looks like I'm also going to have to fix the doctest in atmosphere.py.

weaverba137 commented 6 years ago

I had to fix a couple of unrelated things to get tests to pass. @sbailey or @dkirkby, you might want to review this again.

sbailey commented 6 years ago

I hadn't realized how complicated my "could you open a PR about that?" would be. Thanks for the debugging and chasing this one down. Nicely done. I independently confirmed that tests pass without $DISPLAY set with astropy 2. Thanks.