sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.47k stars 485 forks source link

Fix flaky simplicial set test #38940

Open user202729 opened 2 weeks ago

user202729 commented 2 weeks ago

Fixes https://github.com/sagemath/sage/issues/38888 .

This test has been failing sporadically recently e.g. https://github.com/sagemath/sage/actions/runs/11733902583/job/32689016794?pr=38938 .

From my understanding of simplicial set, the two sigma_1 are actually representing two different cells (the wedge looks like a "8" shape), but because they both come from S1 (the 1-sphere i.e. circle), they get the same name.

SageMath does some magic during doctest so that dict entries are sorted, but the problem is

        At this point, comparison between v and w is random, based on
        their location in memory. ::

so with some chance it fails.

This change should make it deterministic --- since the two faces are named sigma_1 and sigma_1', the comparison should be by custom name…?

:memo: Checklist

github-actions[bot] commented 2 weeks ago

Documentation preview for this PR (built with commit f070aa374deb182f6b3c73b8f072785ad90cdbfa; changes) is ready! :tada: This preview will update shortly after each push to this PR.

user202729 commented 2 weeks ago

The failed test is

2024-11-08T15:09:09.5768206Z **********************************************************************
2024-11-08T15:09:09.5893109Z File "src/sage/groups/finitely_presented_named.py", line 489, in sage.groups.finitely_presented_named.AlternatingPresentation
2024-11-08T15:09:09.5894783Z Failed example:
2024-11-08T15:09:09.5895452Z     A1.is_isomorphic(A2), A1.order()
2024-11-08T15:09:09.5896032Z Expected:
2024-11-08T15:09:09.5896389Z     (True, 1)
2024-11-08T15:09:09.5896732Z Got:
2024-11-08T15:09:09.5897089Z     #I  Forcing finiteness test
2024-11-08T15:09:09.5897589Z     (True, 1)
2024-11-08T15:09:11.2068744Z **********************************************************************

This is obviously https://github.com/sagemath/sage/issues/38889 instead.

By the way, GitHub Actions doesn't seem to be able to report test failure to the GitHub interface?

orlitzky commented 2 weeks ago

This is obviously #38889 instead.

Potential solution: https://github.com/sagemath/sage/pull/38956

miguelmarco commented 1 week ago

Since there is no actual code being changed (just doctests), I see no risk in accepting it.

user202729 commented 1 week ago

There's always the risk of accidentally telling the user "this is the right way to do things" while it actually relies on dangerous internal implementation detail e.g. are you sure that the 1-cell is not shared between different objects, and mutate it is safe?

miguelmarco commented 4 days ago

I am not 100% sure it is safe in any circumstance, but at the same time cannot think of a scenario where it is not safe.

Maybe @jhpalmieri can have a deeper insight.

jhpalmieri commented 4 days ago

It looks okay to me (after a quick glance).

tobiasdiez commented 1 day ago

I didn't see these test failures pop up again, so this PR is definitely achieving its goal. Since there were no objections, let's get it in.