Ticket #6510 (closed defect: fixed)

Opened 14 months ago

Last modified 14 months ago

[with patch, positive review] Adds __nonzero__ method to abelian groups

Reported by: tsutton Owned by: tbd
Priority: minor Milestone: sage-4.1.1
Component: algebra Keywords: abelian groups
Cc: Author(s): Taylor Sutton
Report Upstream: Reviewer(s): David Roe
Merged in: sage-4.1.1.alpha0 Work issues:

Description

 sage: E=EllipticCurve([0,82])
 sage: tor=E.torsion_subgroup()
 sage: if tor:
 ...       print tor.order()
 1

We'd like to have tor evaluate to false in boolean context.

Attachments

trac_6510.patch Download (0.7 KB) - added by tsutton 14 months ago.
trac_6510.2.patch Download (0.7 KB) - added by tsutton 14 months ago.
trac_6510.3.patch Download (0.9 KB) - added by roed 14 months ago.

Change History

Changed 14 months ago by tsutton

Changed 14 months ago by tsutton

  • summary changed from Adds __nonzero__ method to abelian groups to [with patch, needs review] Adds __nonzero__ method to abelian groups

Changed 14 months ago by roed

  • summary changed from [with patch, needs review] Adds __nonzero__ method to abelian groups to [with patch, needs work] Adds __nonzero__ method to abelian groups

Needs a doctest.

Changed 14 months ago by tsutton

Changed 14 months ago by roed

  • summary changed from [with patch, needs work] Adds __nonzero__ method to abelian groups to [with patch, positive review] Adds __nonzero__ method to abelian groups

Looks good. All tests pass for me.

Changed 14 months ago by ylchapuy

  • summary changed from [with patch, positive review] Adds __nonzero__ method to abelian groups to [with patch, needs work] Adds __nonzero__ method to abelian groups

Still needs a doctest!

Changed 14 months ago by roed

  • summary changed from [with patch, needs work] Adds __nonzero__ method to abelian groups to [with patch, positive review] Adds __nonzero__ method to abelian groups

Now includes #indirect doctest

Changed 14 months ago by mvngu

  • reviewer changed from roed to David Roe

What's the real name of tsutton? The real name should be used so we can give proper credit to contributors.

Changed 14 months ago by mvngu

  • summary changed from [with patch, positive review] Adds __nonzero__ method to abelian groups to [with patch, needs work] Adds __nonzero__ method to abelian groups

I assume that I only need to apply the patch trac_6510.3.patch. But why are there three functions __nonzero__(self) all of which are the same and reside in the same module, but each block of definition contains different stuff? For example, after applying trac_6510.3.patch, I get the following in sage/groups/abelian_gps/abelian_group.py:

    def __nonzero__(self):
        return len(self.invariants()) != 0

    def __nonzero__(self):
        """                                                                     
        Returns True if this group is nontrivial.                               
                                                                                
        EXAMPLES::                                                              
                                                                                
            sage: E = EllipticCurve([0,82])                                     
            sage: T = E.torsion_subgroup()                                      
            sage: bool(T)                                                       
            False                                                               
        """
        return len(self.invariants()) != 0

    def __nonzero__(self):
        """                                                                     
        Returns True if this group is nontrivial.                               
                                                                                
        EXAMPLES::                                                              
                                                                                
            sage: E = EllipticCurve([0,82])                                     
            sage: T = E.torsion_subgroup()                                      
            sage: bool(T) # indirect doctest                                    
            False                                                               
        """
        return len(self.invariants()) != 0

Choose which block of function definition you want, and upload a new patch. Preferrably, you should replace trac_6510.3.patch with your new patch. I'm marking this as needs work. After a new patch is uploaded, positive review can be reinstated.

Changed 14 months ago by roed

Changed 14 months ago by roed

  • summary changed from [with patch, needs work] Adds __nonzero__ method to abelian groups to [with patch, positive review] Adds __nonzero__ method to abelian groups

Fixed. tsutton's real name is Taylor Sutton.

Changed 14 months ago by mvngu

  • author changed from tsutton to Taylor Sutton

Merged the patch trac_6510.3.patch in sage-4.1.1-alpha0. I can't close this ticket because I don't have the privilege to do so. Sorry, folks :-(

Changed 14 months ago by mvngu

  • status changed from new to closed
  • resolution set to fixed
  • merged set to sage-4.1.1.alpha0
Note: See TracTickets for help on using tickets.