Opened 13 years ago

Closed 6 years ago

#2034 closed defect (fixed)

__floordiv__ should be part of coercion model

Reported by: malb Owned by: robertwb
Priority: major Milestone: sage-7.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:

Status badges

Description (last modified by jdemeyer)

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 AlexGhitza

  • 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 jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:3 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:4 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:5 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:6 Changed 6 years ago by jdemeyer

  • Authors set to Jeroen Demeyer
  • Description modified (diff)
  • Milestone changed from sage-6.4 to sage-7.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 6 years ago by jdemeyer

  • Description modified (diff)

comment:8 Changed 6 years ago by jdemeyer

  • Description modified (diff)

comment:9 Changed 6 years ago by jdemeyer

  • Description modified (diff)

comment:10 Changed 6 years ago by jdemeyer

  • Branch set to u/jdemeyer/__floordiv___should_be_part_of_coercion_model

comment:11 Changed 6 years ago by jdemeyer

  • Commit set to 5e8a5e386a7b9d0dc44b570136f2f1c1e9779834
  • Status changed from new to needs_review

New commits:

5e8a5e3Implement __floordiv__ in the coercion model

comment:12 Changed 6 years ago by git

  • Commit changed from 5e8a5e386a7b9d0dc44b570136f2f1c1e9779834 to 835059f776bc5c281ceddb25a567b626ccb08251

Branch pushed to git repo; I updated commit sha1. New commits:

835059fRemove redundant __floordiv__ from number field elements

comment:13 Changed 6 years ago by jdemeyer

  • Description modified (diff)

comment:14 Changed 6 years ago by git

  • Commit changed from 835059f776bc5c281ceddb25a567b626ccb08251 to 3e0e5b803b339a0086ab491bec113ab7b9cd10c1

Branch pushed to git repo; I updated commit sha1. New commits:

3e0e5b8Add more doctests for floor division

comment:15 Changed 6 years ago by jdemeyer

  • Description modified (diff)

comment:16 follow-up: Changed 6 years ago by vdelecroix

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 6 years ago by jdemeyer

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.

Version 0, edited 6 years ago by jdemeyer (next)

comment:18 Changed 6 years ago by vdelecroix

  • 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 6 years ago by vbraun

  • 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
Note: See TracTickets for help on using tickets.