Opened 3 years ago
Closed 3 years ago
#23502 closed defect (fixed)
.round() will not round an integer
Reported by: | christelle | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | sage-8.1 |
Component: | misc | Keywords: | round(), Integer, sd87 |
Cc: | Merged in: | ||
Authors: | Kiran Kedlaya | Reviewers: | Frédéric Chapoton |
Report Upstream: | N/A | Work issues: | |
Branch: | b5f8abf (Commits) | Commit: | b5f8abf6b5cc02f0ce6247e6fe6a31768221e729 |
Dependencies: | Stopgaps: |
Description
The Sage function .round() cannot be called on an Integer. This can be annoying. For example,
sage: 7.round() AttributeError: 'sage.rings.integer.Integer' object has no attribute 'round'
but
sage: 7.0.round() 7
Change History (7)
comment:1 Changed 3 years ago by
comment:2 Changed 3 years ago by
- Branch set to u/kedlaya/_round___will_not_round_an_integer
comment:3 Changed 3 years ago by
I have a branch to upload, but git trac push
doesn't seem to be working for me right now. Will get this up as soon as I can.
comment:4 Changed 3 years ago by
- Commit set to b5f8abf6b5cc02f0ce6247e6fe6a31768221e729
comment:5 Changed 3 years ago by
- Status changed from new to needs_review
Waiting for patchbot, but in the meantime here goes.
comment:6 Changed 3 years ago by
- Reviewers set to Frédéric Chapoton
- Status changed from needs_review to positive_review
ok
comment:7 Changed 3 years ago by
- Branch changed from u/kedlaya/_round___will_not_round_an_integer to b5f8abf6b5cc02f0ce6247e6fe6a31768221e729
- Resolution set to fixed
- Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
To make things even more confusing, the global
round
function does allow an integer input, but the output is not a Sage integer!According to the docstring for this function, "If no precision is specified this just calls the element's
.round()
method." This means that addressing the originally reported problem, by adding a.round()
method to Sage integers which acts as the identity map, would fix this too.