| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -7,9 +7,10 @@ | |
| from six.moves import xrange | ||
|
|
||
| import itertools | ||
| import warnings | ||
| import logging | ||
| import math | ||
| from operator import attrgetter | ||
| import warnings | ||
|
|
||
| import numpy as np | ||
|
|
||
| Expand Down Expand Up | @@ -38,6 +39,8 @@ | |
| from matplotlib.rcsetup import cycler | ||
| from matplotlib.rcsetup import validate_axisbelow | ||
|
|
||
| _log = logging.getLogger(__name__) | ||
|
|
||
| rcParams = matplotlib.rcParams | ||
|
|
||
| is_string_like = cbook.is_string_like | ||
| Expand Down Expand Up | @@ -1002,7 +1005,7 @@ def cla(self): | |
| else: | ||
| self.xaxis._set_scale('linear') | ||
| try: | ||
| self.set_xlim(0, 1) | ||
| self.set_xlim(0, 1, _converter=False) | ||
| except TypeError: | ||
| pass | ||
|
|
||
| Expand All | @@ -1016,7 +1019,7 @@ def cla(self): | |
| else: | ||
| self.yaxis._set_scale('linear') | ||
| try: | ||
| self.set_ylim(0, 1) | ||
| self.set_ylim(0, 1, _converter=False) | ||
| except TypeError: | ||
| pass | ||
|
|
||
| Expand Down Expand Up | @@ -2377,6 +2380,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True): | |
| case, use :meth:`matplotlib.axes.Axes.relim` prior to calling | ||
| autoscale_view. | ||
| """ | ||
| _log.debug('Autoscaling x: %s y: %s', scalex, scaley) | ||
| if tight is not None: | ||
| self._tight = bool(tight) | ||
|
|
||
| Expand Down Expand Up | @@ -2446,6 +2450,7 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval, | |
|
|
||
| if not self._tight: | ||
| x0, x1 = locator.view_limits(x0, x1) | ||
| _log.debug('Autolims: %e %e', x0, x1) | ||
| set_bound(x0, x1) | ||
| # End of definition of internal function 'handle_single_axis'. | ||
|
|
||
| Expand Down Expand Up | @@ -2923,6 +2928,7 @@ def set_xbound(self, lower=None, upper=None): | |
| self.set_xlim(upper, lower, auto=None) | ||
| else: | ||
| self.set_xlim(lower, upper, auto=None) | ||
| self.set_xlim(lower, upper, auto=None) | ||
| else: | ||
| if lower < upper: | ||
| self.set_xlim(lower, upper, auto=None) | ||
| Expand Down Expand Up | @@ -3028,15 +3034,19 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw): | |
| left = kw.pop('xmin') | ||
| if 'xmax' in kw: | ||
| right = kw.pop('xmax') | ||
| # _converter is private, usually True, but can be false | ||
| _converter = kw.pop('_converter', True) | ||
| if kw: | ||
| raise ValueError("unrecognized kwargs: %s" % list(kw)) | ||
|
|
||
| if right is None and iterable(left): | ||
| left, right = left | ||
|
|
||
| self._process_unit_info(xdata=(left, right)) | ||
| left = self._validate_converted_limits(left, self.convert_xunits) | ||
| right = self._validate_converted_limits(right, self.convert_xunits) | ||
| if _converter: | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhat's the purpose of this if statement?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAs above. Its because cla needs the set_x/ylim call. I tried getting rid of it, but bad things seemed to happen.
Sorry, something went wrong.
All reactions
|
||
| _log.debug('Converting xlim %s %s', left, right) | ||
| self._process_unit_info(xdata=(left, right)) | ||
| left = self._validate_converted_limits(left, self.convert_xunits) | ||
| right = self._validate_converted_limits(right, self.convert_xunits) | ||
|
|
||
| old_left, old_right = self.get_xlim() | ||
| if left is None: | ||
| Expand Down Expand Up | @@ -3352,14 +3362,20 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw): | |
| bottom = kw.pop('ymin') | ||
| if 'ymax' in kw: | ||
| top = kw.pop('ymax') | ||
| _converter = kw.pop('_converter', True) | ||
| if kw: | ||
| raise ValueError("unrecognized kwargs: %s" % list(kw)) | ||
|
|
||
| if top is None and iterable(bottom): | ||
| bottom, top = bottom | ||
|
|
||
| bottom = self._validate_converted_limits(bottom, self.convert_yunits) | ||
| top = self._validate_converted_limits(top, self.convert_yunits) | ||
| if _converter: | ||
| _log.debug('Converting ylim %s %s', bottom, top) | ||
| self._process_unit_info(ydata=(bottom, top)) | ||
| bottom = self._validate_converted_limits(bottom, | ||
| self.convert_yunits) | ||
| top = self._validate_converted_limits(top, | ||
| self.convert_yunits) | ||
|
|
||
| old_bottom, old_top = self.get_ylim() | ||
|
|
||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan kwargs be private? (I've never seen this before so I have no idea)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFrom a philosophical standpoint, nothing can be private in the panopticon that is Python symbol visibility, but here is an example from pytz of a private kwarg (though I think popping it from **kwargs so it doesn't show up under inspection is a better course to take).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think it is pretty clear that a kwarg with an underscore is intended as private.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityMaybe the better question is, will an underscored kwarg appear in the documentation? (I'm not convinced in this case that the kwarg is needed anyway)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@dstansby Looks to me like the way it's implemented, it's just being pulled from the kwargs dictionary, it's not an actual declared keyword argument, so you'd need a pretty smart document generator to even figure out that passing _converter to this would be meaningful.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityJust to justify this kwarg - the point of this PR is that the first time you conver units on an axis, the converter gets set. This happens on set_xticks, set_xlims or any of the plotting calls.
cla calls set_xlim but its not doing so because it has any data that might have units. So this kwarg is just an easy way to say "set the limit, but don't assign the units because this is just a placeholder".
We could, alternately, make a new method (_set_xlim_placeholder) that did the same thing, if that is better than a hidden kwarg?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think either way is fine.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.