Opened 5 years ago
Closed 5 years ago
#14601 closed defect (fixed)
table.__repr__() replaces True and False by 1 and 0
Reported by: | slabbe | Owned by: | jason |
---|---|---|---|
Priority: | major | Milestone: | sage-5.10 |
Component: | misc | Keywords: | |
Cc: | Merged in: | sage-5.10.beta5 | |
Authors: | John Palmieri | Reviewers: | Sébastien Labbé |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #13131 | Stopgaps: |
Description
Using sage-5.8 with #13131 merged in sage-5.10.beta0, I get
sage: table([('a','b','c'), (True, False,None)]) a b c 1 0 None
I was expecting :
sage: table([('a','b','c'), (True, False,None)]) a b c True False None
Attachments (1)
Change History (8)
comment:1 Changed 5 years ago by
comment:2 Changed 5 years ago by
I did not know about this !s
I have never used this format syntax for strings...
Related to this same line, I got the following deprecation warning when I called table the first time in my session :
/Users/slabbe/Applications/sage-5.8/local/lib/python2.7/site-packages/sage/misc/table.py:503: PendingDeprecationWarning: object.__format__ with a non-empty format string is deprecated s += ("{:" + align_char + str(width) + "}").format(entry)
Do you get such warning also?
UPDATE : I am not able to reproduce the warning...
comment:3 Changed 5 years ago by
After reading http://docs.python.org/2/library/string.html
and doing some tests, I now understand your suggestion :
sage: ("{:^10}").format(False) ' 0 ' sage: ("{!s:^10}").format(False) ' False ' sage: ("{!r:^10}").format(False) ' False '
sage: ("{:^10}").format(None) ' None ' sage: ("{!s:^10}").format(None) ' None ' sage: ("{!r:^10}").format(None) ' None '
I think !s
is preferable to !r
, so I agree with your diff.
comment:4 Changed 5 years ago by
- Status changed from new to needs_review
Here's a patch. By the way, I used this format syntax as an experiment, because it's going to be the standard way of doing things in Python 3.
Changed 5 years ago by
comment:5 Changed 5 years ago by
- Dependencies set to #13131
comment:6 Changed 5 years ago by
- Reviewers set to Sébastien Labbé
- Status changed from needs_review to positive_review
All tests passed on sage/misc/table.py
. Problem shown in the ticket is solved. Doc builds fine. Patch have a commit message. Positive review. (Tested using sage-5.8 with #13131.)
I believe the patchbot plugin failed blue icon issue is unrelated.
comment:7 Changed 5 years ago by
- Merged in set to sage-5.10.beta5
- Resolution set to fixed
- Status changed from positive_review to closed
Maybe the calls to
format
should include!s
in the string? As insage/misc/table.py
:" + align_char + str(width) + "}").format(entry)and another similar change. (Untested.)