Opened 13 years ago
Closed 5 years ago
#2034 closed defect (fixed)
__floordiv__ should be part of coercion model
Reported by:  malb  Owned by:  robertwb 

Priority:  major  Milestone:  sage7.1 
Component:  coercion  Keywords:  
Cc:  Merged in:  
Authors:  Jeroen Demeyer  Reviewers:  Vincent Delecroix 
Report Upstream:  N/A  Work issues:  
Branch:  3e0e5b8 (Commits, GitHub, GitLab)  Commit:  3e0e5b803b339a0086ab491bec113ab7b9cd10c1 
Dependencies:  Stopgaps: 
Description (last modified by )
Add __floordiv__
to the coercion model for RingElement
and change __floordiv__
to _floordiv_
where applicable.
This does not change any semantics of floor division, but it does fix floor division in a few cases where coercion is involved. It also fixes various segmentation faults like
sage: R.<x> = QQbar[] sage: int(1) // x ...
Finally, we also implement __itruediv__
, which was forgotten when adding __truediv__
.
Change History (19)
comment:1 Changed 12 years ago by
 Component changed from basic arithmetic to coercion
 Owner changed from somebody to robertwb
 Summary changed from {{{__floordiv__}}} should be part of coercion modell to {{{__floordiv__}}} should be part of coercion model
comment:2 Changed 8 years ago by
 Milestone changed from sage5.11 to sage5.12
comment:3 Changed 7 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:4 Changed 7 years ago by
 Milestone changed from sage6.2 to sage6.3
comment:5 Changed 7 years ago by
 Milestone changed from sage6.3 to sage6.4
comment:6 Changed 5 years ago by
 Description modified (diff)
 Milestone changed from sage6.4 to sage7.1
 Report Upstream set to N/A
 Summary changed from {{{__floordiv__}}} should be part of coercion model to __floordiv__ should be part of coercion model
comment:7 Changed 5 years ago by
 Description modified (diff)
comment:8 Changed 5 years ago by
 Description modified (diff)
comment:9 Changed 5 years ago by
 Description modified (diff)
comment:10 Changed 5 years ago by
 Branch set to u/jdemeyer/__floordiv___should_be_part_of_coercion_model
comment:11 Changed 5 years ago by
 Commit set to 5e8a5e386a7b9d0dc44b570136f2f1c1e9779834
 Status changed from new to needs_review
comment:12 Changed 5 years ago by
 Commit changed from 5e8a5e386a7b9d0dc44b570136f2f1c1e9779834 to 835059f776bc5c281ceddb25a567b626ccb08251
Branch pushed to git repo; I updated commit sha1. New commits:
835059f  Remove redundant __floordiv__ from number field elements

comment:13 Changed 5 years ago by
 Description modified (diff)
comment:14 Changed 5 years ago by
 Commit changed from 835059f776bc5c281ceddb25a567b626ccb08251 to 3e0e5b803b339a0086ab491bec113ab7b9cd10c1
Branch pushed to git repo; I updated commit sha1. New commits:
3e0e5b8  Add more doctests for floor division

comment:15 Changed 5 years ago by
 Description modified (diff)
comment:16 followup: ↓ 17 Changed 5 years ago by
According to the "principle of least surprise", supporting floordiv for finite fields looks suspicious
sage: ZZ(5) // ZZ(3) 1 sage: GF(7)(5) // GF(7)(3) 4
If this is just an alias of division, why do we need it?
comment:17 in reply to: ↑ 16 Changed 5 years ago by
Replying to vdelecroix:
According to the "principle of least surprise", supporting floordiv for finite fields looks suspicious
That's outside the scope of this ticket. This ticket only implements coercion for __floordiv__
, it doesn't otherwise change the semantics of floor division. There shouldn't be anything controversial in this ticket.
comment:18 Changed 5 years ago by
 Reviewers set to Vincent Delecroix
 Status changed from needs_review to positive_review
All right. Hope this will be fixed with #15260.
comment:19 Changed 5 years ago by
 Branch changed from u/jdemeyer/__floordiv___should_be_part_of_coercion_model to 3e0e5b803b339a0086ab491bec113ab7b9cd10c1
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
Implement __floordiv__ in the coercion model