igraph / python-igraph

Python interface for igraph
GNU General Public License v2.0
1.31k stars 249 forks source link

Test failure on 0.11.8 #805

Open limburgher opened 6 days ago

limburgher commented 6 days ago

Describe the bug Building 0.11.8 with igraph 0.10.15: =================================== FAILURES =================================== _ GraphTestRunner.test_labels __

args = (,) kwds = {}

@wraps(func)
def inner(*args, **kwds):
    with self._recreate_cm():
      return func(*args, **kwds)

E matplotlib.testing.exceptions.ImageComparisonFailure: images not close (RMS 3.652): E result_images/test_graph/graph_labels.png E result_images/test_graph/graph_labels-expected.png E result_images/test_graph/graph_labels-failed-diff.png

/usr/lib64/python3.13/contextlib.py:85: ImageComparisonFailure =========================== short test summary info ============================ FAILED tests/drawing/matplotlib/test_graph.py::GraphTestRunner::test_labels ======================== 1 failed, 509 passed in 22.50s ========================

szhorvat commented 4 days ago

I tried this with Fedora Rawhide in Docker.

If I use the test.sh script, which installs dependencies from PyPI (matplotlib 3.9.2), all tests pass.

If I use Fedora's own matplotlib (version 3.9.1), I do see this failure. It's not due to igraph, but due to matplotlib, or more likely something matplotlib depends on for font rendering. The difference is that the label "5" is rendered one pixel lower.

Expected image:

graph_labels

Actual image:

graph_labels

Diff:

graph_labels-failed-diff

limburgher commented 3 days ago

Interesting.

QuLogic commented 3 days ago

PyPI wheels are always built with FreeType 2.6. System builds use system dependencies, with latest FreeType that renders a bit different. This would not be limited to Fedora, but also, e.g., conda-forge unless you were using their testing label (which bundles older FreeType.)

If you want to check, you can look at matplotlib.ft2font.__freetype_version__ and set a higher tolerance, or you can leave it to downstreams to patch.

ntamas commented 1 day ago

@szhorvat Can we just bump the tolerance then? Since you already set things up in Docker, can you suggest a new threshold that we could use?

szhorvat commented 1 day ago

@limburgher Can you please ignore this test for now and get this version into Fedora? The failure clearly doesn't indicate a bug. We'll find a way to deal with the test.

limburgher commented 1 day ago

On it!

szhorvat commented 1 day ago

@ntamas That's going to be a pretty huge bump in tolerance. Currently it is 0.025. If I set 3.0, it still fails. If I set 4.0, it passes. I'm experimenting here:

https://github.com/igraph/python-igraph/blob/912f7d9fa3a2b22e0ea4f70bca3738349cdb7c4f/tests/drawing/matplotlib/utils.py#L72-L76

What do we do then?

Any input on this, @iosonofabio ?

szhorvat commented 1 day ago

3.66 is the lowest tolerance that passes. To do further experimentation, I'd have to re-create the now-deleted Docker environment, which I hope to avoid.