New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow "console" and "unicode" formats for function units #14407
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.
|
0f76ee8
to
745678c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks good beyond a few nitpicks, but I feel we might as well propagate inline
here too -- i.e., get #14393 in first and then rebase. What do you think?
42348af
to
0776524
Compare
This requires the implementation of function units with multiline unit format.
0776524
to
3bafd56
Compare
After merging #14393, we get >>> print(f"{u.decibel(u.m**-1):unicode}")
dB(m⁻¹)
>>> print(f"{u.decibel(u.m**-1):console}")
dB(m^-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
Description
Originally, function unit format were restricted to
generic
,unscaled
,latex
andlatex_inline
:Also, functional units didn't support the
__format__
function:This PR implements both, including the required implementation of function units with multiline unit format:
If #14393 is merged before this, we need to adjust this one a bit depending on the outcome of #14393. Specifically, we could to add
**kwargs
propagation to theto_string()
function to enable/disable multiline.