sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.31k stars 450 forks source link

Standardize modulo operator % on real numbers (step 1) #21745

Open videlec opened 7 years ago

videlec commented 7 years ago

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:

See this sage-devel thread and also #15260

CC: @sagetrac-tmonteil

Component: basic arithmetic

Author: Vincent Delecroix

Branch/Commit: u/vdelecroix/21745 @ 39f4053

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

videlec commented 7 years ago

Dependencies: #21746

videlec commented 7 years ago

Description changed:

--- 
+++ 
@@ -4,4 +4,4 @@

 This affects in particular QQ and RR that previously implement other operations.

-See [this sage-devel thread](https://groups.google.com/forum/#!topic/sage-devel/PfMop0nyiL0)
+See [this sage-devel thread](https://groups.google.com/forum/#!topic/sage-devel/PfMop0nyiL0) and also #15260
videlec commented 7 years ago

Description changed:

--- 
+++ 
@@ -2,6 +2,6 @@

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

-This affects in particular QQ and RR that previously implement other operations.
+This affects in particular QQ and RR that previously implement other operations. This ticket only affects QQ. For other numbers see #21747.

 See [this sage-devel thread](https://groups.google.com/forum/#!topic/sage-devel/PfMop0nyiL0) and also #15260
videlec commented 7 years ago

Author: Vincent Delecroix

videlec commented 7 years ago

Branch: u/vdelecroix/21745

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Commit: 710eee2

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

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
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

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

71f5d5921745: fix a UTF8 character
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Changed commit from 710eee2 to 71f5d59

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Changed commit from 71f5d59 to 1bbc03c

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

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

1bbc03c21745: better documentation in real_mod_floordiv.py
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Changed commit from 1bbc03c to 8517922

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

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

851792221745: better documentation in real_mod_floordiv.py
videlec commented 7 years ago

Description changed:

--- 
+++ 
@@ -2,6 +2,23 @@

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

-This affects in particular QQ and RR that previously implement other operations. This ticket only affects QQ. For other numbers see #21747.
+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. The ticket concentrates on QQ. For other numbers see #21747.

 See [this sage-devel thread](https://groups.google.com/forum/#!topic/sage-devel/PfMop0nyiL0) and also #15260
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

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/
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Changed commit from 8517922 to 6912371

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Changed commit from 6912371 to 2bd9c73

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

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

2bd9c7321745: make floordiv returns a rational
videlec commented 7 years ago

Description changed:

--- 
+++ 
@@ -19,6 +19,11 @@
 0.400000000000000

-The change mainly affects QQ and RR. The ticket concentrates on QQ. For other numbers see #21747. +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 (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

videlec commented 7 years ago

Description changed:

--- 
+++ 
@@ -23,7 +23,7 @@

 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 `(r/s)` is not an exact integer
+- 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](https://groups.google.com/forum/#!topic/sage-devel/PfMop0nyiL0) and also #15260
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

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
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 7 years ago

Changed commit from 2bd9c73 to 39f4053

videlec commented 7 years ago

Changed dependencies from #21746 to none

videlec commented 7 years ago
comment:15

rebased on 7.5.beta6

cheuberg commented 7 years ago
comment:16

failing doctests (see patchbot)