Repository navigation
Clean up formatting of units in unicode and console formats - #14413
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
| s = "" | ||
| else: | ||
| s = cls.format_exponential_notation(unit.scale) | ||
| s = cls.format_exponential_notation(unit.scale) + " " |
There was a problem hiding this comment.
To be nitpicky here: for a scale-only unit this adds a trailing space:
>>> u.Unit(10).to_string('unicode')
'10 'Probably one again use a "parts" list and " ".join(parts) at the end, as in generic.py (but just with 1-2 parts)?
There was a problem hiding this comment.
Good catch! the parts use is a bit tricky given the possible multiple lines so I just added the space only when needed. It turned out for latex the same mistake was made, so I corrected that while I was at it.
31327b9 to
5f40d64
Compare
pllim
left a comment
There was a problem hiding this comment.
I am approving by proxy but I will give nstarman a chance to review.
Thanks!
…le-strings Clean up formatting of units in unicode and console formats
…s include an extraneous space Pin 34d79ea59b3ba25820dfe7fc9782e9014826e8b0 and its regression selectors for reproducible runs. Source: astropy/astropy#14413
Description
This pull request is to address that in
consoleandunicodeformat, spaces were not always done properly: for units typeset as a fraction there was a space in front of the unit even without a scale factor, while for units set on a single line, there was no space between the scale factor and the unit.(Plus some small bits of refactoring while I was at it.)
Fixes #14409