-
Notifications
You must be signed in to change notification settings - Fork 469
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
custom formatters: pass unit modifiers to the formatter #1448
base: master
Are you sure you want to change the base?
Conversation
As mentioned on the issue, this PR solves #1486. Because of the changes in (I mean that part :
) All to say that I would be quite happy with this change in |
I was wondering what is the status of this PR? This would be valuable to our team. |
I've not had the time to finish this so far Edit: @jules-ch, maybe we can continue that discussion? In any case, I still think this is the correct choice: modifiers are basically options to the formatter, and thus it makes sense to me that the formatter handles them. However, I realize that a lot of formatters would use the default implementation for Edit2: for full customization of formatters we should maybe also allow arbitrary modifiers, not just |
Hi there, I work alongside @huard and @aulemahal. I've run into some issues today around this. Is there anything we could do to help this along? |
@Zeitsperre Take a look at #1913 We are far ahead into change the way the formatter is implemented. We think the proposed solution is superior as it make it easier to fix things and making everything works across different formatters. But also, it allows you to very easy swap the formatter by a new one! You can actually already test this if you install pint from the master branch. We could use some feedback. |
As noted in xarray-contrib/cf-xarray#278, it is important to pass the modifiers to the custom formatters in order to support both short and long formats with the same name if the distinction is not as simple as using the symbol instead of the long name.
This PR shifts the modifier support to the formatters. For the builtin formatters, this is implemented using a helper function which we should probably expose as public API to help with custom formatters that don't need that sort of control.
cc @dcherian
pre-commit run --all-files
with no errorsDocumented in docs/ as appropriateno custom formatter section yet, requires add a example for a custom unit formatter #1422