Opened 11 years ago
Last modified 7 years ago
#9261 new enhancement
RealIntervalField: enable option style='bracket'
Reported by: | zimmerma | Owned by: | AlexGhitza |
---|---|---|---|
Priority: | minor | Milestone: | sage-6.4 |
Component: | basic arithmetic | Keywords: | |
Cc: | was, cwitty, mhansen | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Currently, the option style='bracket' (to display intervals as
[1.1 ... 1.2]) is only available in the str
method, so that
one has to provide it each time one calls str.
It would be nice to have an option style=... in the *creation* of the field, to override the default style. For example one would have:
sage: R = RealIntervalField(42, style='brackets') sage: R(pi) [3.1415926535892 .. 3.1415926535902]
Change History (10)
comment:1 Changed 11 years ago by
comment:2 follow-up: ↓ 4 Changed 11 years ago by
I don't like the idea of putting the print style in the parent. (I think the current sci_not is a design error that shouldn't be perpetuated.)
One problem is that if you have objects like RealIntervalField(42, style='brackets')(pi)
and RealIntervalField(42)(pi)
, then arithmetic between them is slower than between objects with the same parent. Also, there are several parts of Sage that create their own RealIntervalField
parents and return elements to the user, so the option you suggest would not suffice to hide question-mark printing from the user.
IMHO a global setting is a more sensible option; would that be all right, or do you really want the setting to be per-parent?
If a global setting is acceptable, then we're in luck, because it already exists: :)
sage: a = RIF(pi) sage: a 3.141592653589794? sage: sage.rings.real_mpfi.printing_style = 'brackets' sage: a [3.1415926535897931 .. 3.1415926535897936]
We could certainly document this global setting (I think it's entirely undocumented now), if that would help.
comment:3 Changed 11 years ago by
We could certainly document this global setting (I think it's entirely undocumented now), if that would help.
I strongly support this. This global setting was something I was missing since a long time, it is now in my init.sage file.
comment:4 in reply to: ↑ 2 Changed 11 years ago by
Replying to cwitty:
IMHO a global setting is a more sensible option; would that be all right, or do you really want the setting to be per-parent?
+1 to making such things (and keeping such things) global settings.
comment:5 Changed 11 years ago by
I'm OK with this, because it only impacts the *appearance* (not the mathematics) of the elements.
comment:6 Changed 11 years ago by
- Cc mhansen added
comment:7 Changed 8 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:8 Changed 7 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:9 Changed 7 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:10 Changed 7 years ago by
- Milestone changed from sage-6.3 to sage-6.4
This is almost implemented in #7682. The patch there is probably ready for review, but it's been a while since I looked at the patch, so it should probably have doctests run and possibly have a bit more documentation written. And it would be nice to implement this ticket either on top of #7682, or just by adding a few lines to #7682.