Repository navigation
BUG: fix extraneous space in LaTeX repr for Quantity objects with superscript units - #16043
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.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
5fb3c45 to
bcf7284
Compare
| delimiter_left, delimiter_right = formats[format][subfmt] | ||
|
|
||
| return rf"{delimiter_left}{latex_value} \; {latex_unit}{delimiter_right}" | ||
| if self.unit == Unit("deg"): |
There was a problem hiding this comment.
Hmm, we probably then also should do "arcmin", "arcsec", and "hourangle"
And this is of course not the first time we are dealing with this - as you note, you don't want to do it for composite units, or if the unit is raised to some power....
How about the following hack?
# Add a space in front except for super-script units like degrees.
if not latex_unit.startswith("{}^") or unit is u.deg_C:
latex_unit = r"\;" + latex_unit
and then remove the \; below.
There was a problem hiding this comment.
of course ! sorry for not thinking of other angular units. I've extended the test and refactored the code based on your suggestion
fe73492 to
3e436d2
Compare
3e436d2 to
aebba02
Compare
mhvk
left a comment
There was a problem hiding this comment.
Sorry, had lost track of this one - now looks all good!
Description
Fixes #14385
Special casing seems simple enough here. Maybe the check should be more fine tuned so that composite units that have
degas their first element also follow this special path ? I just assumed this wasn't desired.