Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RDF round and friends return Integers #2899

Closed
jasongrout opened this issue Apr 12, 2008 · 10 comments
Closed

Make RDF round and friends return Integers #2899

jasongrout opened this issue Apr 12, 2008 · 10 comments

Comments

@jasongrout
Copy link
Member

> Also, round(RR(3.0)) returns an Integer...should RDF behave the same
> > way? (currently round(RDF(3.0)) returns an RDF).

We recently changed round, floor, ceiling, and trunc on RR to return
integers; yes, I think the corresponding RDF methods should change as
well.

Carl

Component: coercion

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

@jasongrout
Copy link
Member Author

comment:1

The fix for #2898 will fix this.

@ncalexan
Copy link
Mannequin

ncalexan mannequin commented Aug 14, 2008

comment:2

Attachment: 2899-ncalexan-RIF-floor-ceil-1.patch.gz

This makes floor and ceil do what I expect for RIF. I believe that #2898 does make RDF work.

@ncalexan ncalexan mannequin added the s: needs review label Aug 14, 2008
@craigcitro
Copy link
Member

comment:3

I just tried to apply this against 3.2, and it fails. It's just a matter of moving the doctests around, I think.

@craigcitro craigcitro changed the title Make RDF round and friends return Integers [needs rebase] Make RDF round and friends return Integers Nov 27, 2008
@robertwb
Copy link
Contributor

comment:4

This appears to have already been fixed.

----------------------------------------------------------------------
| Sage Version 3.4.2, Release Date: 2009-05-05                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------

sage: a = RDF(3.4)

sage: a.round(), a.floor(), a.ceil()
 (3, 3, 4)

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented May 18, 2009

comment:5

Did someone add a doctest? Otherwise this should not have been closed.

Cheers,

Michael

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented May 19, 2009

comment:6

Reopening until someone either points to a doctests or post a doctest patch.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin removed the r: worksforme label May 19, 2009
@sagetrac-mabshoff sagetrac-mabshoff mannequin reopened this May 19, 2009
@ncalexan
Copy link
Mannequin

ncalexan mannequin commented May 19, 2009

comment:7

There are doctests for RDF for sure:


    def round(self):
        """
        Given real number x, rounds up if fractional part is greater than
        .5, rounds down if fractional part is less than .5.

        EXAMPLES::
        
            sage: RDF(0.49).round()
            0
            sage: a=RDF(0.51).round(); a
            1
        """
        return Integer(round(self._value))

    def floor(self):
        """
        Returns the floor of this number
        
        EXAMPLES::
        
            sage: RDF(2.99).floor()
            2
            sage: RDF(2.00).floor()
            2
            sage: RDF(-5/2).floor()
            -3
        """
        return Integer(math.floor(self._value))

    def ceil(self):
        """
        Returns the ceiling of this number
        
        OUTPUT: integer
        
        EXAMPLES::
        
            sage: RDF(2.99).ceil()
            3
            sage: RDF(2.00).ceil()
            2
            sage: RDF(-5/2).ceil()
            -2
        """
        return Integer(math.ceil(self._value))

@ncalexan ncalexan mannequin changed the title [needs rebase] Make RDF round and friends return Integers Make RDF round and friends return Integers May 19, 2009
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented May 19, 2009

comment:8

Excellent. Closed as fixed.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed May 19, 2009
@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-4.0.1, sage-4.0 May 19, 2009
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented May 19, 2009

comment:9

Wait. There are doctests via Nick's ticket, but that patch has not been merged into the Sage library, but fixed in some other way, i.e. the symbolics switch in 4.0. I assume.

In that case we might still need doctests, so until this is sorted out I am reopening this again :(

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin reopened this May 19, 2009
@williamstein williamstein modified the milestones: sage-4.0, sage-4.0.1 May 28, 2009
@robertwb
Copy link
Contributor

comment:11

There are doctests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants