Opened 5 years ago
Closed 5 years ago
#18334 closed enhancement (fixed)
sign and more truncation functions on real intervals
Reported by:  vdelecroix  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)  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 5 years ago by
 Branch set to u/vdelecroix/18334
 Commit set to d96885c0b700b6ae5f703dcf62dae6cf62323759
 Description modified (diff)
 Status changed from new to needs_review
 Summary changed from unique_sign and unique_trunc on real intervals to sign and more truncation functions on real intervals
comment:2 Changed 5 years ago by
 Description modified (diff)
comment:3 Changed 5 years ago by
 Status changed from needs_review to 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 5 years ago by
The following would be a good doctest:
sage: RIF(0.9, 0.9).unique_trunc() 0
comment:5 Changed 5 years ago by
 Reviewers set to Jeroen Demeyer
comment:6 followup: ↓ 8 Changed 5 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 5 years ago by
 Commit changed from d96885c0b700b6ae5f703dcf62dae6cf62323759 to 10067b5735103012c8fcd0eba6e84d6cefa69573
Branch pushed to git repo; I updated commit sha1. New commits:
10067b5  Trac 18334: fixed frac + doctests

comment:8 in reply to: ↑ 6 Changed 5 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 5 years ago by
 Status changed from needs_work to needs_review
comment:10 Changed 5 years ago by
 Status changed from needs_review to 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 5 years ago by
 Commit changed from 10067b5735103012c8fcd0eba6e84d6cefa69573 to 3aa1904cab0c50d160a30051571bb69321654888
Branch pushed to git repo; I updated commit sha1. New commits:
3aa1904  Trac 18334: more doctests

comment:12 Changed 5 years ago by
 Commit changed from 3aa1904cab0c50d160a30051571bb69321654888 to 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 5 years ago by
 Status changed from needs_work to needs_review
comment:14 Changed 5 years ago by
 Status changed from needs_review to positive_review
comment:15 Changed 5 years ago by
Thanks Jeroen!
comment:16 Changed 5 years ago by
 Branch changed from u/vdelecroix/18334 to 7fe18d6e2d9b459340c9c6e1527a6eb4ebd4e24e
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
Trac 18334: sign and truncations for real intervals