-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Bugfix for issue 16501 raised ValueError polar subplot with (thetamax - thetamin) > 2pi #16717
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
Changes from 5 commits
a6929f3
942ee4d
fe18d37
315a522
377abe0
a69db44
e38a5bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -987,13 +987,31 @@ def set_thetalim(self, *args, **kwargs): | |
where minval and maxval are the minimum and maximum limits. Values are | ||
wrapped in to the range :math:`[0, 2\pi]` (in radians), so for example | ||
it is possible to do ``set_thetalim(-np.pi / 2, np.pi / 2)`` to have | ||
an axes symmetric around 0. | ||
an axes symmetric around 0. A ValueError is raised if the absolute | ||
angle difference is larger than :math:2\pi. | ||
""" | ||
thetamin = None | ||
thetamax = None | ||
left = None | ||
right = None | ||
|
||
if 'thetamin' in kwargs: | ||
kwargs['xmin'] = np.deg2rad(kwargs.pop('thetamin')) | ||
thetamin = np.deg2rad(kwargs.pop('thetamin')) | ||
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. Is all this argument dance because we have to check the generic Later on, we should make the method signature explicit, which will simplify the check. Ideally, one would to this before adding the check, but since that will involve an API-change with a deprecation period, we would not be able to add the simplified check for the next to minor releases. So the more complex check is necessary for now. 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. Yes, the if statements there are to check the possible signatures. The signatures allowed for set_thetalim are as follows:
By "If, so we should parse to that thetamax and thetamin, check that once and pass it to set_xlim() explicitly" do you mean signature 1 ( radians ) would not be used anymore? 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. Ultimately (unless we decide to change the awkward rad/degree API altogether) we could at least do 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. for this change I have made changes. Made an explicit call to set_xlim using parameter thetamin, thetamax, left and right. Please let me know if further changes need to be made. I do agree making the set_thetalim explicit in the future when 3.8 rolls out. 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. Passing the parameters on consistently and checking them on the go is surprisingly complex. This code covers the documented API versions using two kwargs or two positional args. It does not catch all edge cases like I'll think about this but I think that's ok. I'd move these theta parsing down so that you have the order
|
||
if 'thetamax' in kwargs: | ||
kwargs['xmax'] = np.deg2rad(kwargs.pop('thetamax')) | ||
return tuple(np.rad2deg(self.set_xlim(*args, **kwargs))) | ||
thetamax = np.deg2rad(kwargs.pop('thetamax')) | ||
|
||
if len(args) == 2: | ||
if args[0] is not None and args[1] is not None: | ||
left = args[0] | ||
right = args[1] | ||
dstansby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if(abs(right - left) > 2 * np.pi): | ||
dstansby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise ValueError('Cannot pass angle range > 2 pi') | ||
dstansby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if(thetamin is not None and thetamax is not None): | ||
dstansby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if(abs(thetamax - thetamin) > 2 * np.pi): | ||
dstansby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise ValueError('Cannot pass angle range > 2 pi') | ||
dstansby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return tuple(np.rad2deg(self.set_xlim(left=left, right=right, | ||
xmin=thetamin, xmax=thetamax))) | ||
|
||
def set_theta_offset(self, offset): | ||
""" | ||
|
Uh oh!
There was an error while loading. Please reload this page.