Opened 4 years ago

Last modified 4 years ago

#21745 needs_work enhancement

Standardize modulo operator % on real numbers (step 1)

Reported by: vdelecroix Owned by:
Priority: major Milestone: sage-7.5
Component: basic arithmetic Keywords:
Cc: tmonteil Merged in:
Authors: Vincent Delecroix Reviewers:
Report Upstream: N/A Work issues:
Branch: u/vdelecroix/21745 (Commits) Commit: 39f4053cc260b5816cde2faa816e7be72617d4ba
Dependencies: Stopgaps:

Description (last modified by vdelecroix)

For any subset of the real numbers we change the modulo operator to be

x%y is the unique x' between [0,y) of the form x + ny with n integer

The main reason for the shift are the following incoherences

sage: 5 % 3
2
sage: 5. % 3.
-1.00000000000000

and

sage: 2/5 % 3
1
sage: 2./5. % 3.
0.400000000000000

The change mainly affects QQ and RR. This ticket concentrates on QQ. For other numbers see #21747.

The specifications for the transition period are as follows:

  • both // and % with rational arguments will return rationals
  • there will be a deprecation warning with (p/q) % (r/s) when p/q or r/s is not an exact integer
  • there will be a deprecation warning with (p/q) // (r/s) when the result is not an exact integer

See this sage-devel thread and also #15260

Change History (16)

comment:1 Changed 4 years ago by vdelecroix

  • Cc tmonteil added

comment:2 Changed 4 years ago by vdelecroix

  • Dependencies set to #21746

comment:3 Changed 4 years ago by vdelecroix

  • Description modified (diff)

comment:4 Changed 4 years ago by vdelecroix

  • Authors set to Vincent Delecroix
  • Branch set to u/vdelecroix/21745
  • Description modified (diff)
  • Status changed from new to needs_review
  • Summary changed from Standardize modulo operator % on real numbers to Standardize modulo operator % on real numbers (step 1)

comment:5 Changed 4 years ago by git

  • Commit set to 710eee221d82bf66b7a2b1f4234dd4877d140a9a

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

624c32221745: fix integer mod ring initialization with rationals
cc204ef21745: fix doctests in integer.pyx
0e5730421745: use / instead of // in one place
5735ee121745: include real_mod_floordiv in the documentation
7e1a28121745: fix bernoulli mod p tests
6435af121745: fix pari ffelt initialization
f62f8bf21745: fix doctests in ideal.py and integer_ring.pyx
f70825b21745: doctest finite field initialization
05657ad21745: fix quadratic form of ideals
710eee221745: fix some french book examples

comment:6 Changed 4 years ago by git

  • Commit changed from 710eee221d82bf66b7a2b1f4234dd4877d140a9a to 71f5d5900cfb54fca4d472401999baae24b9792c

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

71f5d5921745: fix a UTF8 character

comment:7 Changed 4 years ago by git

  • Commit changed from 71f5d5900cfb54fca4d472401999baae24b9792c to 1bbc03ca2e75800cbe6b90eefd5dd44665a97c19

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

1bbc03c21745: better documentation in real_mod_floordiv.py

comment:8 Changed 4 years ago by git

  • Commit changed from 1bbc03ca2e75800cbe6b90eefd5dd44665a97c19 to 851792263137eba893897312c7778cf57c9050c9

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

851792221745: better documentation in real_mod_floordiv.py

comment:9 Changed 4 years ago by vdelecroix

  • Description modified (diff)

comment:10 Changed 4 years ago by git

  • Commit changed from 851792263137eba893897312c7778cf57c9050c9 to 69123710378e0041d641ab336439d4ba9dcb3099

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

c97709521745: fix quadratic_forms
84a893721745: fix in root system
691237121745: two fixes in graphs/

comment:11 Changed 4 years ago by git

  • Commit changed from 69123710378e0041d641ab336439d4ba9dcb3099 to 2bd9c73ebd4352eae2bd9fdf2adbec55349b69aa

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

2bd9c7321745: make floordiv returns a rational

comment:12 Changed 4 years ago by vdelecroix

  • Description modified (diff)

comment:13 Changed 4 years ago by vdelecroix

  • Description modified (diff)

comment:14 Changed 4 years ago by git

  • Commit changed from 2bd9c73ebd4352eae2bd9fdf2adbec55349b69aa to 39f4053cc260b5816cde2faa816e7be72617d4ba

Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:

9decbae21745: doctest finite field initialization
25a335e21745: fix quadratic form of ideals
ad9f81821745: fix some french book examples
f2ceaf121745: fix a UTF8 character
2d78c1d21745: better documentation in real_mod_floordiv.py
5b720f421745: fix quadratic_forms
c45b55321745: fix in root system
6e16f4d21745: two fixes in graphs/
7aa12c521745: make floordiv returns a rational
39f405321745: fix projective_morphism.py

comment:15 Changed 4 years ago by vdelecroix

  • Dependencies #21746 deleted

rebased on 7.5.beta6

comment:16 Changed 4 years ago by cheuberg

  • Status changed from needs_review to needs_work

failing doctests (see patchbot)

Note: See TracTickets for help on using tickets.