-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Cleaning up the Formatter API #5787
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
Comments
From 10k feet looks good. Keep in mind the coming conversion to traitlets which is going to deprecate most of the getter/setter methods ( I have a preference for more simpler functions/classes over fewer more complex functions/classes. Having attributes/arguments that affect drawing conditional on the value of some other attribute/argument makes the API more frustrating to use. |
Also going back and forth on if this should be lumped in with 2.0 style changes or 2.1. Tagged this as 2.1, but if these changes make the style changes to the offset text easier to do I am in favor of re-implementing the old API in terms of the new, using the new everywhere internally and starting the deprecation cycle on the old in 2.1 (to be removed in 2.3). |
What's the status of the switch to traitlets? (Specifically, is it certain that there will be a switch?) Given that the Formatter class is actually fairly self-contained, would it be OK for me to directly write a traitlets-based API? (I don't want to maintain two compatibility layers.) I would suggest
Do you mean that you'd rather keep |
We have not hit a major technical issue with traitlets yet. Unless there is On Sat, Jan 2, 2016, 20:18 Antony Lee notifications@github.com wrote:
|
It would be nice to have this on 2.0 (I think), which won't have Traitlets. So, unfortunately, if we agree it should be on 2.0, we will have to do a non-Traitlets implementation now and a Traitlets one later. In our experience with Traitlets so far, though, this won't mean maintaining two code paths, but simply replacing to use Traitlets. |
A pattern we used else where is to use the 'old-school' property model to On Mon, Jan 4, 2016 at 10:19 AM Michael Droettboom notifications@github.com
|
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
This is somewhat outdated, but we could still at least consider deprecating (or rather making private) |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Still on my offset-text rewrite spree...
Currently, the formatter API (in charge of picking the strings for the tick labels, axis offset and cursor position in the status bar) is a bit messy: the public methods available are
Formatter.__call__(self, val, idx)
: computes the label textsFormatter.format_data(self, val)
: not publicly usedFormatter.format_data_short(self, val)
: computes the cursor position textFormatter.get_offset(self)
: returns the offset textFormatter.set_locs(self, locs)
: required for computing the labelsFormatter.fix_minus(self, s)
: overriden only by ScalarFormatter to use a unicode minusFixedFormatter also provides
set_offset_string
.The commonly used ScalarFormatter and LogFormatter also provide
pprint_val
(with different signatures, and not publicly used).ScalarFormatter also provides a couple of getter/setters (for
useOffset
,useLocale
,scientific
,powerlimits
); LogFormatter providesbase
andlabel_minor
as setters for instance variables.LogFormatterExponent and LogFormatterMathtext are variants of LogFormatter.
EngFormatter also provides
format_eng
(not publicly used).There are also a bunch of instance attributes which are public but probably intended as private.
I propose simplifying the API to the following:
Formatter.get_label_text(self, val: float, idx: int)
: computes the label textsFormatter.get_cursor_text(self, val: float)
: computes the cursor position textFormatter.get_offset_text(self)
andFormatter.set_offset_text(self, s: str)
: get/set the offset textFormatter.set_locs(self, locs: array-like)
: because we need itFormatter.set_uselocale(self, b: bool)
: because there's no reason only ScalarFormatter has it(the new method names can be made to fallback on the old method names with a deprecation warning in the base class)
and drop or make private basically everything else:
fix_minus
(let's first check if any backend doesn't support unicode)pprint_val/format_eng
scientific
,powerlimits
,base
,label_minor
, using getter/setters)and fold the
LogFormatterExponent
andLogFormatterMathText
classes into options for theLogFormatter
class.Thoughts?
The text was updated successfully, but these errors were encountered: