mrzv / dionysus

Library for computing persistent homology
http://mrzv.org/software/dionysus2
Other
144 stars 31 forks source link

test_issue47.py::test_issue47 fails: #64

Open yurivict opened 2 months ago

yurivict commented 2 months ago
========================================================================================= FAILURES ==========================================================================================
_______________________________________________________________________________________ test_issue47 ________________________________________________________________________________________

    def test_issue47():
        # init the complex/filtration
        # any filtration that produces a diagram of only infinite points will work
        simplicies = [
            ([0], 0),
            ([1], 1),
        ]

        # create the filtration
        filtr = d.Filtration()
        for verts, idx in simplicies:
            simplex = d.Simplex(verts, idx)
            filtr.append(simplex)
        filtr.sort()

        # create the diagram
        m = d.homology_persistence(filtr)
        dgm = d.init_diagrams(m, filtr)

>       d.plot.plot_diagram(dgm[0])

test_issue47.py:23: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../stage/usr/local/lib/python3.9/site-packages/dionysus/plot.py:38: in plot_diagram
    ax = plt.axes()
/usr/local/lib/python3.9/site-packages/matplotlib/pyplot.py:1217: in axes
    fig = gcf()
/usr/local/lib/python3.9/site-packages/matplotlib/pyplot.py:1000: in gcf
    return figure()
/usr/local/lib/python3.9/site-packages/matplotlib/pyplot.py:934: in figure
    manager = new_figure_manager(
/usr/local/lib/python3.9/site-packages/matplotlib/pyplot.py:465: in new_figure_manager
    return _get_backend_mod().new_figure_manager(*args, **kwargs)
/usr/local/lib/python3.9/site-packages/matplotlib/backend_bases.py:3396: in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
/usr/local/lib/python3.9/site-packages/matplotlib/backend_bases.py:3401: in new_figure_manager_given_figure
    return cls.FigureCanvas.new_manager(figure, num)
/usr/local/lib/python3.9/site-packages/matplotlib/backend_bases.py:1785: in new_manager
    return cls.manager_class.create_with_canvas(cls, figure, num)
/usr/local/lib/python3.9/site-packages/matplotlib/backends/_backend_tk.py:486: in create_with_canvas
    window = tk.Tk(className="matplotlib")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tkinter.Tk object .>, screenName = None, baseName = '__main__', className = 'matplotlib', useTk = True, sync = False, use = None

    def __init__(self, screenName=None, baseName=None, className='Tk',
                 useTk=True, sync=False, use=None):
        """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will
        be created. BASENAME will be used for the identification of the profile file (see
        readprofile).
        It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
        is the name of the widget class."""
        self.master = None
        self.children = {}
        self._tkloaded = False
        # to avoid recursions in the getattr code in case of failure, we
        # ensure that self.tk is always _something_.
        self.tk = None
        if baseName is None:
            import os
            baseName = os.path.basename(sys.argv[0])
            baseName, ext = os.path.splitext(baseName)
            if ext not in ('.py', '.pyc'):
                baseName = baseName + ext
        interactive = False
>       self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
E       _tkinter.TclError: no display name and no $DISPLAY environment variable

/usr/local/lib/python3.9/tkinter/__init__.py:2270: TclError
================================================================================ 1 failed, 1 passed in 2.94s ================================================================================

Python-3.9 FreeBSD 14.0

mrzv commented 2 months ago

@yurivict I can't reproduce this, but it's clearly an artifact of how matplotlib is setup. It sounds like yours defaults to using Tk interface, but fails without $DISPLAY. (I have something that renders images inline in the kitty terminal.) I'm not sure what the right fix is. Why are you running this test in the first place?

yurivict commented 2 months ago

The DISPLAY variable is set when tests are run.

The tests are run as part of the 'test' target in the FreeBSD port.

mrzv commented 2 months ago

Then it's something about matplotlib, not dionysus. I have no idea why its Tk backend would fail in this case.