Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • L ltfatpy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4
    • Issues 4
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • dev
  • ltfatpy
  • Issues
  • #10
Closed
Open
Issue created May 02, 2017 by Florent Jaillet@florent.jailletOwner

test_tfplot fails when no $DISPLAY environment variable is defined

When running the tests with nosetests in an environment with no $DISPLAY variable defined (in particular in a Docker container) the following error occurs:

======================================================================
ERROR: Check that the all the plotting sections of tfplot can be run
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ltfatpy/ltfatpy/tests/gabor/test_tfplot.py", line 183, in test_plot
    tfplot(coef, step, yr, plottype=plottype)
  File "/ltfatpy/ltfatpy/gabor/tfplot.py", line 230, in tfplot
    interpolation='nearest', origin='lower')
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 2881, in imshow
    ax = gca()
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 803, in gca
    ax =  gcf().gca(**kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 450, in gcf
    return figure()
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 423, in figure
    **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager
    return new_figure_manager_given_figure(num, figure)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 87, in new_figure_manager_given_figure
    window = Tk.Tk()
  File "/usr/lib/python3.4/tkinter/__init__.py", line 1854, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
nose.proxy.TclError: no display name and no $DISPLAY environment variable
-------------------- >> begin captured stdout << ---------------------

This happens despite the fact that the tests are not doing any actual display with matplotlib (matplotlib.pyplot.show() is never called).

The solution is to force the use of a non-interactive backend for matplotlib, for example the backend ps. The function matplotlib.pyplot.switch_backend can be used to switch the backend.

Assignee
Assign to
Time tracking