Ticket #3810 (new enhancement)

Opened 4 months ago

Last modified 2 days ago

[with patch, needs review] make abelian group list/iter and classgroup list/iter more modern

Reported by: ncalexan Assigned to: was
Priority: minor Milestone: sage-3.2.2
Component: number theory Keywords:
Cc:

Description

list/iter on abelian groups does not agree with .list().

Also, list on classgroups returned abstract group elements -- essentially useless:

sage: x = QQ['x'].0
sage: K.<a> = NumberField(x^4 + 23)
sage: G = K.class_group()
sage: G
Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^4 + 23
sage: list(G)
[1, c, c^2]

This actually lists representatives in the class group.

Apply abelian group patch before classgroup patch.

Passes relevant tests:

/Users/ncalexan/sage-3.0.6/sage -b >/dev/null && /Users/ncalexan/sage-3.0.6/sage -t /Users/ncalexan/sage-3.0.6/devel/sage-nca/sage/groups/abelian_gps/*

real	0m1.610s
user	0m0.958s
sys	0m0.623s
sage -t  devel/sage-nca/sage/groups/abelian_gps/abelian_group.py
	 [5.3 s]
sage -t  devel/sage-nca/sage/groups/abelian_gps/abelian_group_element.py
	 [3.6 s]
sage -t  devel/sage-nca/sage/groups/abelian_gps/abelian_group_morphism.py
	 [3.0 s]
sage -t  devel/sage-nca/sage/groups/abelian_gps/all.py      
	 [2.2 s]
sage -t  devel/sage-nca/sage/groups/abelian_gps/dual_abelian_group.py
	 [3.9 s]
sage -t  devel/sage-nca/sage/groups/abelian_gps/dual_abelian_group_element.py
	 [3.0 s]
 
----------------------------------------------------------------------
All tests passed!
Total time for all tests: 20.9 seconds

and

/Users/ncalexan/sage-3.0.6/sage -b >/dev/null && /Users/ncalexan/sage-3.0.6/sage -t /Users/ncalexan/sage-3.0.6/devel/sage-nca/sage/rings/number_field/*

real	0m1.672s
user	0m0.959s
sys	0m0.618s
sage -t  devel/sage-nca/sage/rings/number_field/all.py      
	 [2.0 s]
sage -t  devel/sage-nca/sage/rings/number_field/class_group.py
	 [4.9 s]
sage -t  devel/sage-nca/sage/rings/number_field/galois_group.py
	 [3.5 s]
sage -t  devel/sage-nca/sage/rings/number_field/maps.py     
	 [2.9 s]
sage -t  devel/sage-nca/sage/rings/number_field/morphism.py 
	 [4.1 s]
sage -t  devel/sage-nca/sage/rings/number_field/number_field.py
  ***   Warning: large Minkowski bound: certification will be VERY long.
  ***   Warning: large Minkowski bound: certification will be VERY long.

	 [28.9 s]
sage -t  devel/sage-nca/sage/rings/number_field/number_field_base.pyx
	 [3.7 s]
sage -t  devel/sage-nca/sage/rings/number_field/number_field_element.pyx
	 [9.0 s]
sage -t  devel/sage-nca/sage/rings/number_field/number_field_element_quadratic.pyx
	 [4.0 s]
sage -t  devel/sage-nca/sage/rings/number_field/number_field_ideal.py
	 [6.6 s]
sage -t  devel/sage-nca/sage/rings/number_field/number_field_ideal_rel.py
	 [3.4 s]
sage -t  devel/sage-nca/sage/rings/number_field/order.py    
	 [10.2 s]
sage -t  devel/sage-nca/sage/rings/number_field/small_primes_of_degree_one.py
	 [3.5 s]
sage -t  devel/sage-nca/sage/rings/number_field/todo.py     
	 [2.1 s]
sage -t  devel/sage-nca/sage/rings/number_field/totallyreal.py
	 [3.1 s]
sage -t  devel/sage-nca/sage/rings/number_field/totallyreal_data.pyx
	 [2.1 s]
sage -t  devel/sage-nca/sage/rings/number_field/totallyreal_phc.py
	 [2.1 s]
sage -t  devel/sage-nca/sage/rings/number_field/totallyreal_rel.py
	 [4.3 s]
sage -t  devel/sage-nca/sage/rings/number_field/unit_group.py
	 [2.0 s]
 
----------------------------------------------------------------------
All tests passed!
Total time for all tests: 102.5 seconds

sage-test finished (all test passed) at Mon Aug 11 21:53:13

Attachments

3810-ncalexan-abelian-group-iter.patch (1.5 kB) - added by ncalexan on 08/11/2008 09:57:25 PM.
3810-ncalexan-class-group-list.patch (2.0 kB) - added by ncalexan on 08/11/2008 09:57:37 PM.
3810-ncalexan-abelian-group-iter-2.patch (2.0 kB) - added by ncalexan on 08/13/2008 02:42:44 PM.

Change History

08/11/2008 09:57:25 PM changed by ncalexan

  • attachment 3810-ncalexan-abelian-group-iter.patch added.

08/11/2008 09:57:37 PM changed by ncalexan

  • attachment 3810-ncalexan-class-group-list.patch added.

08/11/2008 10:36:12 PM changed by mabshoff

  • summary changed from make abelian group list/iter and classgroup list/iter more modern to [with patch, needs review] make abelian group list/iter and classgroup list/iter more modern.
  • milestone changed from sage-feature to sage-3.1.

08/12/2008 07:40:43 PM changed by was

  • summary changed from [with patch, needs review] make abelian group list/iter and classgroup list/iter more modern to [with patch, needs work] make abelian group list/iter and classgroup list/iter more modern.

Needs work. Your fix patch introduces a bug:

sage: G = AbelianGroup([2,3], names = "ab") sage: v = G.list()
sage: v
[1, b, b^2, a, a*b, a*b^2]
sage: v[0] = "hi nick!"
sage: G.list()
['hi nick!', b, b^2, a, a*b, a*b^2]

08/13/2008 02:42:44 PM changed by ncalexan

  • attachment 3810-ncalexan-abelian-group-iter-2.patch added.

08/13/2008 02:43:25 PM changed by ncalexan

  • summary changed from [with patch, needs work] make abelian group list/iter and classgroup list/iter more modern to [with patch, needs review] make abelian group list/iter and classgroup list/iter more modern.

3810-ncalexan-abelian-group-iter-2.patch replaces 3810-ncalexan-abelian-group-iter.patch and addresses referee comment.

08/23/2008 10:44:17 AM changed by cremona

  • summary changed from [with patch, needs review] make abelian group list/iter and classgroup list/iter more modern to [with patch, with positive review] make abelian group list/iter and classgroup list/iter more modern.

This is functionality which I wanted a few days ago so I am pleased to see this ticket!

I applied 3810-ncalexan-abelian-group-iter-2.patch and then 3810-ncalexan-class-group-list.patch in that order. When Sage applied the second one I was surprised that it popped up an edit window as when one does a commit. I just closed the window.

So I don't really know what it was I tested, but it seemed to work as advertised (and without the bug William pointed out).

Here's an enhancement I would like: If I create an ideal class from some random ideal, nothing really happens, and I cannot tell which class I got without testing for equality with every class. Am I missing something? I actually would have been happy to have class group elements display as abstract group elements (as they would in Magma), as long as functions were provided to go from fractional ideals to abstract ideal classes and back again.

08/24/2008 07:29:18 PM changed by mabshoff

  • summary changed from [with patch, with positive review] make abelian group list/iter and classgroup list/iter more modern to [with patch, needs work] make abelian group list/iter and classgroup list/iter more modern.

With the two patches John mentioned I get the following doctest failure:

sage -t -long devel/sage/sage/rings/number_field/class_group.py
**********************************************************************
File "/scratch/mabshoff/release-cycle/sage-3.1.2.alpha1/tmp/class_group.py", line 117:
    sage: list(G)
Expected:
    [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 + a - 1/2), Fractional ideal class (2, 1/2*a^2 + 1/2)]
Got:
    [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 - a + 3/2), Fractional ideal class (2, 1/2*a^2 + 1/2)]
**********************************************************************
File "/scratch/mabshoff/release-cycle/sage-3.1.2.alpha1/tmp/class_group.py", line 119:
    sage: G.list()
Expected:
    [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 + a - 1/2), Fractional ideal class (2, 1/2*a^2 + 1/2)]
Got:
    [Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a^2 - a + 3/2), Fractional ideal class (2, 1/2*a^2 + 1/2)]
**********************************************************************

The reason that trac_3810-ncalexan-class-group-list.patch popped up a window is that it is a straight diff instead of a patch. Nick: Can you post a unified patch and delete the old ones?

Cheers,

Michael

08/25/2008 02:15:14 AM changed by cremona

Those doctest differences are insignificant in that the output is mathematically identical to what is expected. For deterministic output we need (as well as the usual sorting): the same ideals representing each class, and the same presentation of each ideal. Here it's just that the second ideal in the list has a different second generator.

My understanding is that these generators come from pari. If so, it is probably safe to replace the doctest output with the new output. Perhaps Nick could say if that sounds right to him.

11/30/2008 03:51:23 AM changed by cremona

Nick, any news on this? It might be relevant to #4061 which I am about to post a patch for.

11/30/2008 08:28:50 PM changed by ncalexan

  • summary changed from [with patch, needs work] make abelian group list/iter and classgroup list/iter more modern to [with patch, needs review] make abelian group list/iter and classgroup list/iter more modern.

I think these should be applied. The doctest output should be updated, but I don't have the original patch queue anymore to give a non-patch.