8000 STY: PEP8 the rest of PolarAxes code. · matplotlib/matplotlib@d549014 · GitHub
[go: up one dir, main page]

Skip to content

Commit d549014

Browse files
committed
STY: PEP8 the rest of 8000 PolarAxes code.
1 parent b47ccba commit d549014

File tree

2 files changed

+35
-37
lines changed

2 files changed

+35
-37
lines changed

lib/matplotlib/projections/polar.py

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
import six
5-
6-
import math
7-
import warnings
8-
94
import numpy as np
105

11-
import matplotlib
12-
rcParams = matplotlib.rcParams
136
from matplotlib.axes import Axes
147
import matplotlib.axis as maxis
158
from matplotlib import cbook
169
from matplotlib import docstring
1710
import matplotlib.patches as mpatches
1811
import matplotlib.path as mpath
12+
from matplotlib import rcParams
1913
import matplotlib.ticker as mticker
2014
import matplotlib.transforms as mtransforms
2115
import matplotlib.spines as mspines
@@ -530,8 +524,8 @@ def _set_lim_and_transforms(self):
530524
self._yaxis_text_transform = mtransforms.TransformWrapper(
531525
self._r_label_position + self.transData)
532526

533-
def get_xaxis_transform(self,which='grid'):
534-
if which not in ['tick1','tick2','grid']:
527+
def get_xaxis_transform(self, which='grid'):
528+
if which not in ['tick1', 'tick2', 'grid']:
535529
msg = "'which' must be one of [ 'tick1' | 'tick2' | 'grid' ]"
536530
raise ValueError(msg)
537531
return self._xaxis_transform
@@ -542,8 +536,8 @@ def get_xaxis_text1_transform(self, pad):
542536
def get_xaxis_text2_transform(self, pad):
543537
return self._xaxis_text2_transform, 'center', 'center'
544538

545-
def get_yaxis_transform(self,which='grid'):
546-
if which not in ['tick1','tick2','grid']:
539+
def get_yaxis_transform(self, which='grid'):
540+
if which not in ['tick1', 'tick2', 'grid']:
547541
msg = "'which' must be on of [ 'tick1' | 'tick2' | 'grid' ]"
548542
raise ValueError(msg)
549543
return self._yaxis_transform
@@ -715,7 +709,7 @@ def set_theta_zero_location(self, loc, offset=0.0):
715709
'S': np.pi * 1.5,
716710
'SE': np.pi * 1.75,
717711
'E': 0,
718-
'NE': np.pi * 0.25 }
712+
'NE': np.pi * 0.25}
719713
return self.set_theta_offset(mapping[loc] + np.deg2rad(offset))
720714

721715
def set_theta_direction(self, direction):
@@ -736,7 +730,8 @@ def set_theta_direction(self, direction):
736730
elif direction in (1, -1):
737731
mtx[0, 0] = direction
738732
else:
739-
raise ValueError("direction must be 1, -1, clockwise or counterclockwise")
733+
raise ValueError(
734+
"direction must be 1, -1, clockwise or counterclockwise")
740735
self._direction.invalidate()
741736

742737
def get_theta_direction(self):
@@ -802,6 +797,7 @@ def set_yscale(self, *args, **kwargs):
802797

803798
def set_rscale(self, *args, **kwargs):
804799
return Axes.set_yscale(self, *args, **kwargs)
800+
805801
def set_rticks(self, *args, **kwargs):
806802
return Axes.set_yticks(self, *args, **kwargs)
807803

@@ -886,16 +882,17 @@ def set_rgrids(self, radii, labels=None, angle=None, fmt=None,
886882

887883
def set_xscale(self, scale, *args, **kwargs):
888884
if scale != 'linear':
889-
raise NotImplementedError("You can not set the xscale on a polar plot.")
885+
raise NotImplementedError(
886+
"You can not set the xscale on a polar plot.")
890887

891888
def format_coord(self, theta, r):
892889
"""
893890
Return a format string formatting the coordinate using Unicode
894891
characters.
895892
"""
896893
if theta < 0:
897-
theta += 2 * math.pi
898-
theta /= math.pi
894+
theta += 2 * np.pi
895+
theta /= np.pi
899896
return ('\N{GREEK SMALL LETTER THETA}=%0.3f\N{GREEK SMALL LETTER PI} '
900897
'(%0.3f\N{DEGREE SIGN}), r=%0.3f') % (theta, theta * 180.0, r)
901898

@@ -906,7 +903,7 @@ def get_data_ratio(self):
906903
'''
907904
return 1.0
908905

909-
### Interactive panning
906+
# # # Interactive panning
910907

911908
def can_zoom(self):
912909
"""
@@ -916,7 +913,7 @@ def can_zoom(self):
916913
"""
917914
return False
918915

919-
def can_pan(self) :
916+
def can_pan(self):
920917
"""
921918
Return *True* if this axes supports the pan/zoom button functionality.
922919
@@ -938,14 +935,13 @@ def start_pan(self, x, y, button):
938935
mode = 'zoom'
939936

940937
self._pan_start = cbook.Bunch(
941-
rmax = self.get_rmax(),
942-
trans = self.transData.frozen(),
943-
trans_inverse = self.transData.inverted().frozen(),
944-
r_label_angle = self.get_rlabel_position(),
945-
x = x,
946-
y = y,
947-
mode = mode
948-
)
938+
rmax=self.get_rmax(),
939+
trans=self.transData.frozen(),
940+
trans_inverse=self.transData.inverted().frozen(),
941+
r_label_angle=self.get_rlabel_position(),
942+
x=x,
943+
y=y,
944+
mode=mode)
949945

950946
def end_pan(self):
951947
del self._pan_start
@@ -979,8 +975,6 @@ def drag_pan(self, button, key, x, y):
979975
startt, startr = p.trans_inverse.transform_point((p.x, p.y))
980976
t, r = p.trans_inverse.transform_point((x, y))
981977

982-
dr = r - startr
983-
984978
# Deal with r
985979
scale = r / startr
986980
self.set_rmax(p.rmax / scale)
@@ -1016,7 +1010,8 @@ def drag_pan(self, button, key, x, y):
10161010
# vertices = self.transform(vertices)
10171011

10181012
# result = np.zeros((len(vertices) * 3 - 2, 2), float)
1019-
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
1013+
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
1014+
# mpath.Path.code_type)
10201015
# result[0] = vertices[0]
10211016
# codes[0] = mpath.Path.MOVETO
10221017

@@ -1053,8 +1048,8 @@ def drag_pan(self, button, key, x, y):
10531048

10541049
# result[3::3] = p1
10551050

1056-
# print vertices[-2:]
1057-
# print result[-2:]
1051+
# print(vertices[-2:])
1052+
# print(result[-2:])
10581053

10591054
# return mpath.Path(result, codes)
10601055

@@ -1068,12 +1063,13 @@ def drag_pan(self, button, key, x, y):
10681063
# maxtd = td.max()
10691064
# interpolate = np.ceil(maxtd / halfpi)
10701065

1071-
# print "interpolate", interpolate
1066+
# print("interpolate", interpolate)
10721067
# if interpolate > 1.0:
10731068
# vertices = self.interpolate(vertices, interpolate)
10741069

10751070
# result = np.zeros((len(vertices) * 3 - 2, 2), float)
1076-
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
1071+
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
1072+
# mpath.Path.code_type)
10771073
# result[0] = vertices[0]
10781074
# codes[0] = mpath.Path.MOVETO
10791075

@@ -1095,16 +1091,19 @@ def drag_pan(self, button, key, x, y):
10951091

10961092
# result[1::3, 0] = t0 + (tkappa * td_scaled)
10971093
# result[1::3, 1] = r0*hyp_kappa
1098-
# # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled) # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
1094+
# # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled)
1095+
# # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
10991096

11001097
# result[2::3, 0] = t1 - (tkappa * td_scaled)
11011098
# result[2::3, 1] = r1*hyp_kappa
1102-
# # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled) # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
1099+
# # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled)
1100+
# # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
11031101

11041102
# result[3::3, 0] = t1
11051103
# result[3::3, 1] = r1
11061104

1107-
# print vertices[:6], result[:6], t0[:6], t1[:6], td[:6], td_scaled[:6], tkappa
1105+
# print(vertices[:6], result[:6], t0[:6], t1[:6], td[:6],
1106+
# td_scaled[:6], tkappa)
11081107
# result = self.transform(result)
11091108
# return mpath.Path(result, codes)
11101109
# transform_path_non_affine = transform_path

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ pep8ignore =
4242
matplotlib/backend_bases.py E225 E501 E712
4343
matplotlib/projections/__init__.py E302
4444
matplotlib/projections/geo.py E203 E221 E231 E261 E302 E402 E501 E502
45-
matplotlib/projections/polar.py E202 E203 E221 E231 E251 E301 E402 E501
4645
matplotlib/sphinxext/mathmpl.py E302
4746
matplotlib/sphinxext/only_directives.py E302
4847
matplotlib/sphinxext/plot_directive.py E261 E301 E302 E401 E402 E501

0 commit comments

Comments
 (0)
0