sagemath / sage

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

Fix failing doctests in groups/perm_gps/permgroup.py #32294

Open slel opened 3 years ago

slel commented 3 years ago

Part of #25536.

In Sage 9.4.rc1, the output for some examples varies depending on not-sure-what.

Some tests in src/sage/groups/perm_gps/permgroup.py can fail as follows:

$ sage -t --long src/sage/groups/perm_gps/permgroup.py
Running doctests with ID 2021-07-28-23-47-16-14f5337b.
Git branch: develop
Using --optional=...
Doctesting 1 file.
sage -t --long --random-seed=0 src/sage/groups/perm_gps/permgroup.py
**********************************************************************
File "src/sage/groups/perm_gps/permgroup.py", line 877, in sage.groups.perm_gps.permgroup.PermutationGroup_generic._coerce_map_from_
Failed example:
    p = f(mg); p
Expected:
    (2,33,32,23,31,55)(3,49,38,44,40,28)(4,17,59,62,58,46)(5,21,47,20,43,8)(6,53,50)(7,37,12,57,14,29)(9,41,56,34,64,10)(11,25,19)(13,61,26,51,22,15)(16,45,36)(18,27,35,48,52,54)(24,63,42)(30,39,60)
Got:
    (1,2,6,19,35,33)(3,9,26,14,31,23)(4,13,5)(7,22,17)(8,24,12)(10,16,32,27,20,28)(11,30,18)(15,25,36,34,29,21)
**********************************************************************
File "src/sage/groups/perm_gps/permgroup.py", line 926, in sage.groups.perm_gps.permgroup.PermutationGroup_generic._coerce_map_from_
Failed example:
    P(g1*g2)
Expected:
    (1,3,7,12)(2,4,8,10)(5,11)(6,9)
Got:
    (1,9,7,6)(2,10)(3,11)(4,5,8,12)
**********************************************************************
File "src/sage/groups/perm_gps/permgroup.py", line 928, in sage.groups.perm_gps.permgroup.PermutationGroup_generic._coerce_map_from_
Failed example:
    P1(g1*g2)
Expected:
    (2,29,25,68)(3,57,13,54)(4,11,72,37)(5,39,60,23)(6,64,75,63)(7,21,50,73)(8,46,38,32)(9,74,35,18)(10,44,49,48)(12,16,34,71)(14,79,27,40)(15,26)(17,62,59,76)(19,78,70,65)(20,22,58,51)(24,33,36,43)(28,81,80,52)(30,53,56,69)(31,61)(41,42,67,55)(45,77)(47,66)
Got:
    (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
**********************************************************************
1 item had failures:
   3 of  36 in sage.groups.perm_gps.permgroup.PermutationGroup_generic._coerce_map_from_
    [939 tests, 3 failures, 11.74 s]
----------------------------------------------------------------------
sage -t --long --random-seed=0 src/sage/groups/perm_gps/permgroup.py  # 3 doctests failed
----------------------------------------------------------------------
Total time for all tests: 12.0 seconds
    cpu time: 9.5 seconds
    cumulative wall time: 11.7 seconds
Pytest is not installed, skip checking tests that rely on it.

CC: @EmmanuelCharpentier @slel

Component: packages: experimental

Keywords: permgroup

Issue created by migration from https://trac.sagemath.org/ticket/32294

slel commented 3 years ago

Description changed:

--- 
+++ 
@@ -7,13 +7,10 @@
 fail with `gap_packages` installed:

-$ sagetest src/sage/groups/perm_gps/permgroup.py -too many failed tests, not using stored timings +$ sage -t --long src/sage/groups/perm_gps/permgroup.py Running doctests with ID 2021-07-28-23-47-16-14f5337b. Git branch: develop -Using --optional=4ti2,barvinok,benzene,bliss,buckygen,build,ccache,cunningham_tables,d3js,database_cremona_ellcurve,data -base_jones_numfield,database_kohel,database_mutation_class,database_odlyzko_zeta,database_stein_watkins,database_symboli -c_data,debian,dochtml,dot2tex,e_antic,frobby,gap_packages,glucose,gp2c,igraph,kenzo,latte_int,libogg,libsemigroups,lidia,lrslib,mcqd,meataxe,mpfrcx,normaliz,notedown,pandoc_attributes,pari_elldata,pari_galpol,pari_nftables,pari_seadata,pip,plantri,polylib,primecount,pycosat,pynormaliz,pysingular,python_igraph,qhull,rst2ipynb,rubiks,saclib,sage,sage_spkg,sip,speaklater,symengine,symengine_py,tdlib,texttable,tides,topcom +Using --optional=build,ccache,debian,dochtml,gap_packages,pip,sage,sage_spkg Doctesting 1 file. sage -t --long --random-seed=0 src/sage/groups/perm_gps/permgroup.py


slel commented 3 years ago
comment:2

It would be nice to know if this depends

So far I have observed this on Debian 10 "buster" with many optional packages installed.

Can this happen with no optional packages installed?

slel commented 3 years ago

Description changed:

--- 
+++ 
@@ -1,16 +1,16 @@
 Part of #25536.

-In Sage 9.4.rc0, the output for some examples
-depend on whether `gap_packages` is installed.
+In Sage 9.4.rc1, the output for some examples
+varies depending on not-sure-what.

 Some tests in `src/sage/groups/perm_gps/permgroup.py`
-fail with `gap_packages` installed:
+can fail as follows:

$ sage -t --long src/sage/groups/perm_gps/permgroup.py Running doctests with ID 2021-07-28-23-47-16-14f5337b. Git branch: develop -Using --optional=build,ccache,debian,dochtml,gap_packages,pip,sage,sage_spkg +Using --optional=... Doctesting 1 file. sage -t --long --random-seed=0 src/sage/groups/perm_gps/permgroup.py


@@ -50,4 +50,3 @@ Pytest is not installed, skip checking tests that rely on it.


-They pass if `gap_packages` is not installed.
slel commented 3 years ago

Changed keywords from optional, gap_packages, permgroup to permgroup

dimpase commented 3 years ago
comment:3

GAP has reimplementations of its various methods for group homomorphisms in gap_packages.

I presume one gets unequal, albeit equivalent, homomorphisms, here.

7822f248-ba56-45f1-ab3d-4de7482bdf9f commented 3 years ago
comment:4

Replying to @slel:

It would be nice to know if this depends

  • on the processor type
  • on the operating system
  • on some system package being used
  • on some optional package being installed
  • ...

So far I have observed this on Debian 10 "buster" with many optional packages installed.

Can this happen with no optional packages installed?

FWIW, the system where I observed (repeatedly) ths problem has the following packages installed :

charpent@zen-book-flip:~$ sage -optional | grep -v ot_instal | grep -v package |cut -d "." -f 1 | xargs echo

/usr/local/sage-9/local/lib/python3.9/site-packages/sage/misc/package.py:115: UserWarning: failed to fetch the version of pkg='ore_algebra' at https://pypi.org/pypi/ore_algebra/json

warnings.warn("failed to fetch the version of pkg={!r} at {}".format(pkg, url))

cmdstanpy cypari2 dot2tex fricas gap_jupyter iniconfig json5 jupyter_kernel_gap jupyter_kernel_singular jupyterlab jupyterlab_server kenzo libsemigroups pandas pycodestyle pyflakes pysingular pytest python_dateutil pyyaml relint saclib sagemath_standard singular_jupyter tqdm ujson

7822f248-ba56-45f1-ab3d-4de7482bdf9f commented 3 years ago
comment:5

Replying to @dimpase:

GAP has reimplementations of its various methods for group homomorphisms in gap_packages.

I presume one gets unequal, albeit equivalent, homomorphisms, here.

Is there a way to test the equivalence of the result obtained in the doctest to the one expected ? If so, we could do this test in the doctest and search for True or False.

dimpase commented 3 years ago
comment:7

line 877 test serves no purpose, and can be safely removed (it also depends upon random element generation, I suppose)

dimpase commented 3 years ago
comment:8

Replying to @EmmanuelCharpentier:

Replying to @dimpase:

GAP has reimplementations of its various methods for group homomorphisms in gap_packages.

I presume one gets unequal, albeit equivalent, homomorphisms, here.

Is there a way to test the equivalence of the result obtained in the doctest to the one expected ? If so, we could do this test in the doctest and search for True or False.

not without changing the code of as_permutation_group(), which does not return the underlying group isomorphism, but only its image.

If one has an underlying isomorphism, one can have a test of the isomorphism property in an invariant way.