Opened 8 years ago
Closed 8 years ago
#18334 closed enhancement (fixed)
sign and more truncation functions on real intervals
Reported by:  Vincent Delecroix  Owned by:  

Priority:  major  Milestone:  sage6.7 
Component:  basic arithmetic  Keywords:  
Cc:  Merged in:  
Authors:  Vincent Delecroix  Reviewers:  Jeroen Demeyer 
Report Upstream:  N/A  Work issues:  
Branch:  7fe18d6 (Commits, GitHub, GitLab)  Commit:  7fe18d6e2d9b459340c9c6e1527a6eb4ebd4e24e 
Dependencies:  Stopgaps: 
Description (last modified by )
Real intervals are missing truncation functions:
frac
trunc
round
unique_sign
unique_trunc
We also add some more documentation to truncation methods.
see also: #18337
Change History (16)
comment:1 Changed 8 years ago by
Branch:  → u/vdelecroix/18334 

Commit:  → d96885c0b700b6ae5f703dcf62dae6cf62323759 
Description:  modified (diff) 
Status:  new → needs_review 
Summary:  unique_sign and unique_trunc on real intervals → sign and more truncation functions on real intervals 
comment:2 Changed 8 years ago by
Description:  modified (diff) 

comment:3 Changed 8 years ago by
Status:  needs_review → needs_work 

The frac()
of an interval is not the same as
self.parent()(self.lower().frac(), self.upper().frac())
For example, the frac()
of RIF(6,7)
should be the whole interval RIF(0,1)
.
comment:4 Changed 8 years ago by
The following would be a good doctest:
sage: RIF(0.9, 0.9).unique_trunc() 0
comment:5 Changed 8 years ago by
Reviewers:  → Jeroen Demeyer 

comment:6 followup: 8 Changed 8 years ago by
For frac()
, you should check specifically if 1
or 1
should be contained in the result:
 if the interval
]a,b]
contains a positive integer (check iffloor(b) > max(a,0)
):frac()
must contain[0,1]
 if the interval
[a,b[
contains a negative integer (check ifceil(a) < min(b,0)
):frac()
must contain[1,0]
If you add the frac()
of the endpoints, you should get everything.
comment:7 Changed 8 years ago by
Commit:  d96885c0b700b6ae5f703dcf62dae6cf62323759 → 10067b5735103012c8fcd0eba6e84d6cefa69573 

Branch pushed to git repo; I updated commit sha1. New commits:
10067b5  Trac 18334: fixed frac + doctests

comment:8 Changed 8 years ago by
Replying to jdemeyer:
For
frac()
, you should check specifically if1
or1
should be contained in the result:
 if the interval
]a,b]
contains a positive integer (check iffloor(b) > max(a,0)
):frac()
must contain[0,1]
 if the interval
[a,b[
contains a negative integer (check ifceil(a) < min(b,0)
):frac()
must contain[1,0]
If you add the
frac()
of the endpoints, you should get everything.
Of course. This was completely wrong! Thanks.
comment:9 Changed 8 years ago by
Status:  needs_work → needs_review 

comment:10 Changed 8 years ago by
Status:  needs_review → needs_work 

Add some comments like I wrote in 6. I would also like to see doctests where one endpoint is an integer:
sage: RIF(0.5, 1).frac() sage: RIF(1, 1.5).frac()
comment:11 Changed 8 years ago by
Commit:  10067b5735103012c8fcd0eba6e84d6cefa69573 → 3aa1904cab0c50d160a30051571bb69321654888 

Branch pushed to git repo; I updated commit sha1. New commits:
3aa1904  Trac 18334: more doctests

comment:12 Changed 8 years ago by
Commit:  3aa1904cab0c50d160a30051571bb69321654888 → 7fe18d6e2d9b459340c9c6e1527a6eb4ebd4e24e 

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
7fe18d6  Trac 18334: more doctests

comment:13 Changed 8 years ago by
Status:  needs_work → needs_review 

comment:14 Changed 8 years ago by
Status:  needs_review → positive_review 

comment:16 Changed 8 years ago by
Branch:  u/vdelecroix/18334 → 7fe18d6e2d9b459340c9c6e1527a6eb4ebd4e24e 

Resolution:  → fixed 
Status:  positive_review → closed 
New commits:
Trac 18334: sign and truncations for real intervals