Conversation
r3kste
left a comment
There was a problem hiding this comment.
@Sreekanth-M8 This looks good. As discussed, you can go ahead condense this solution to put as a comment to ask for initial feedback. There is just one minor comment about radial locator.
269eb94 to
dec73c7
Compare
dec73c7 to
8aa5624
Compare
There was a problem hiding this comment.
I ran test_polar.py and left some comments about the failing tests.
-
For Theta Tick, there is one test failing:
lib/matplotlib/tests/test_polar.py::test_polar_theta_limits. -
For Radial Tick, there are a lot of tests failing.
As mentioned below, it would be better if we stick with only changing Theta ticks in this PR (as that is what the issue also expects).
8e3af65 to
f64510d
Compare
r3kste
left a comment
There was a problem hiding this comment.
@Sreekanth-M8 Sorry for the delay in the review. Apart from the below comments you can go ahead with implementing tests.
- See how Cartesian Axes Locators are tested and add similar tests for
ChoiceLocator. - Make sure previously existing tests with full circle plots still pass.
- Update the test image for
lib/matplotlib/tests/test_polar.py::test_polar_theta_limits
| """ | ||
|
|
||
| def __init__(self, base): | ||
| class ChoiceLocator(mticker.Locator): |
|
|
||
| def __init__(self, base): | ||
| class ChoiceLocator(mticker.Locator): | ||
| def __init__(self, base=None, choices=None): |
There was a problem hiding this comment.
- Should
basebe optional here, considering forThetaLocatorit was not. - I think we don't need to take
choicesas a parameter. Or is there a usecase to be able to control this?
| if _is_full_circle_deg(lim[0], lim[1]): | ||
| return np.deg2rad(min(lim)) + np.arange(8) * 2 * np.pi / 8 | ||
| if (vmax - vmin > 60): | ||
| for ticks in self.choices: | ||
| in_range = (ticks >= vmin - tol) & (ticks <= vmax + tol) | ||
| ticks = ticks[in_range] | ||
| if len(ticks) > max_ticks: | ||
| continue | ||
| if len(ticks) == max_ticks: | ||
| if vmin != ticks[0]: | ||
| ticks[0] = vmin | ||
| if vmax != ticks[-1]: | ||
| ticks[-1] = vmax | ||
| return np.deg2rad(ticks) | ||
| if len(ticks) < max_ticks: | ||
| if vmin != ticks[0]: | ||
| if abs(ticks[0] - vmin) >= tick_interval: | ||
| ticks = np.concatenate(([vmin], ticks)) | ||
| else: | ||
| ticks[0] = vmin | ||
| if vmax != ticks[-1]: | ||
| if len(ticks) < max_ticks: | ||
| if abs(vmax - ticks[-1]) >= tick_interval: | ||
| ticks = np.concatenate((ticks, [vmax])) | ||
| else: | ||
| ticks[-1] = vmax | ||
| else: | ||
| ticks[-1] = vmax | ||
| return np.deg2rad(ticks) | ||
| else: | ||
| return np.deg2rad(self.base()) | ||
| ticks = self.choices[-1] | ||
| ticks = ticks[(ticks >= vmin - tol) & (ticks <= vmax + tol)] | ||
| return ticks |
There was a problem hiding this comment.
The logic here is pretty convoluted, but seems to be correct. Can you add comments for each case?
| ticks[-1] = vmax | ||
| return np.deg2rad(ticks) | ||
| else: | ||
| return np.deg2rad(self.base()) |
PR summary
added ChoiceLocator as per 20012
PR checklist