#5152: order of abelian group element is a rational number, but should be an
integer
------------------------------+---------------------------------------------
 Reporter:  was               |       Owner:  somebody
     Type:  defect            |      Status:  new     
 Priority:  minor             |   Milestone:  sage-3.3
Component:  basic arithmetic  |    Keywords:          
------------------------------+---------------------------------------------
 The line commented with "error here???" below is frightening:
 {{{
 File: /sage/groups/abelian_gps/abelian_group_element.py
 Source Code (starting at line 268):
     def order(self):
         """
         Returns the (finite) order of this element or Infinity if this
 element
         does not have finite order.

         EXAMPLES:
             sage: F = AbelianGroup(3,[7,8,9]); F
             Multiplicative Abelian Group isomorphic to C7 x C8 x C9
             sage: F.gens()[2].order()
             9
             sage: a,b,c = F.gens()
             sage: (b*c).order()
             72
         """
         M = self.parent()
         if self == M(1):
             return Integer(1)
         invs = M.invariants()
         if self in M.gens():
             o = invs[list(M.gens()).index(self)]
             if o == 0:
                 return infinity
             return o
         L = list(self.list())
         N = LCM([invs[i]/GCD(invs[i],L[i]) for i in range(len(invs)) if
 L[i]!=0])   ####### error here????
         if N == 0:
             return infinity
         else:
             return N
 }}}


 But what bugs me about it is:
 {{{
 sage: G = AbelianGroup(3,[7,8,9])
 sage: type((G.0 * G.1).order())
 <type 'sage.rings.rational.Rational'>
 }}}

 a simple coercion to Integer at the end of the function would fix this, or
 using // instead of /.   And add a doctest that has a type check so this
 doesn't get re-introduced.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5152>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to