Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5d7ed7a

Browse files
committed
STY: PEP8 the rest of PolarAxes code.
1 parentaac76e0 commit5d7ed7a

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

‎lib/matplotlib/projections/polar.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
importnumpyasnp
1010

1111
importmatplotlib
12-
rcParams=matplotlib.rcParams
1312
frommatplotlib.axesimportAxes
1413
importmatplotlib.axisasmaxis
1514
frommatplotlibimportcbook
@@ -21,6 +20,9 @@
2120
importmatplotlib.spinesasmspines
2221

2322

23+
rcParams=matplotlib.rcParams
24+
25+
2426
classPolarTransform(mtransforms.Transform):
2527
"""
2628
The base polar transform. This handles projection *theta* and
@@ -526,8 +528,8 @@ def _set_lim_and_transforms(self):
526528
self._yaxis_text_transform=mtransforms.TransformWrapper(
527529
self._r_label_position+self.transData)
528530

529-
defget_xaxis_transform(self,which='grid'):
530-
ifwhichnotin ['tick1','tick2','grid']:
531+
defget_xaxis_transform(self,which='grid'):
532+
ifwhichnotin ['tick1','tick2','grid']:
531533
msg="'which' must be one of [ 'tick1' | 'tick2' | 'grid' ]"
532534
raiseValueError(msg)
533535
returnself._xaxis_transform
@@ -538,8 +540,8 @@ def get_xaxis_text1_transform(self, pad):
538540
defget_xaxis_text2_transform(self,pad):
539541
returnself._xaxis_text2_transform,'center','center'
540542

541-
defget_yaxis_transform(self,which='grid'):
542-
ifwhichnotin ['tick1','tick2','grid']:
543+
defget_yaxis_transform(self,which='grid'):
544+
ifwhichnotin ['tick1','tick2','grid']:
543545
msg="'which' must be on of [ 'tick1' | 'tick2' | 'grid' ]"
544546
raiseValueError(msg)
545547
returnself._yaxis_transform
@@ -686,7 +688,7 @@ def set_theta_zero_location(self, loc, offset=0.0):
686688
'S':np.pi*1.5,
687689
'SE':np.pi*1.75,
688690
'E':0,
689-
'NE':np.pi*0.25}
691+
'NE':np.pi*0.25}
690692
returnself.set_theta_offset(mapping[loc]+np.deg2rad(offset))
691693

692694
defset_theta_direction(self,direction):
@@ -707,7 +709,8 @@ def set_theta_direction(self, direction):
707709
elifdirectionin (1,-1):
708710
mtx[0,0]=direction
709711
else:
710-
raiseValueError("direction must be 1, -1, clockwise or counterclockwise")
712+
raiseValueError(
713+
"direction must be 1, -1, clockwise or counterclockwise")
711714
self._direction.invalidate()
712715

713716
defget_theta_direction(self):
@@ -773,6 +776,7 @@ def set_yscale(self, *args, **kwargs):
773776

774777
defset_rscale(self,*args,**kwargs):
775778
returnAxes.set_yscale(self,*args,**kwargs)
779+
776780
defset_rticks(self,*args,**kwargs):
777781
returnAxes.set_yticks(self,*args,**kwargs)
778782

@@ -857,7 +861,8 @@ def set_rgrids(self, radii, labels=None, angle=None, fmt=None,
857861

858862
defset_xscale(self,scale,*args,**kwargs):
859863
ifscale!='linear':
860-
raiseNotImplementedError("You can not set the xscale on a polar plot.")
864+
raiseNotImplementedError(
865+
"You can not set the xscale on a polar plot.")
861866

862867
defformat_coord(self,theta,r):
863868
"""
@@ -868,7 +873,9 @@ def format_coord(self, theta, r):
868873
# \u03b8: lower-case theta
869874
# \u03c0: lower-case pi
870875
# \u00b0: degree symbol
871-
return'\u03b8=%0.3f\u03c0 (%0.3f\u00b0), r=%0.3f'% (theta,theta*180.0,r)
876+
return'\u03b8=%0.3f\u03c0 (%0.3f\u00b0), r=%0.3f'% (theta,
877+
theta*180.0,
878+
r)
872879

873880
defget_data_ratio(self):
874881
'''
@@ -877,7 +884,7 @@ def get_data_ratio(self):
877884
'''
878885
return1.0
879886

880-
### Interactive panning
887+
# ## Interactive panning
881888

882889
defcan_zoom(self):
883890
"""
@@ -887,7 +894,7 @@ def can_zoom(self):
887894
"""
888895
returnFalse
889896

890-
defcan_pan(self):
897+
defcan_pan(self):
891898
"""
892899
Return *True* if this axes supports the pan/zoom button functionality.
893900
@@ -909,14 +916,13 @@ def start_pan(self, x, y, button):
909916
mode='zoom'
910917

911918
self._pan_start=cbook.Bunch(
912-
rmax=self.get_rmax(),
913-
trans=self.transData.frozen(),
914-
trans_inverse=self.transData.inverted().frozen(),
915-
r_label_angle=self.get_rlabel_position(),
916-
x=x,
917-
y=y,
918-
mode=mode
919-
)
919+
rmax=self.get_rmax(),
920+
trans=self.transData.frozen(),
921+
trans_inverse=self.transData.inverted().frozen(),
922+
r_label_angle=self.get_rlabel_position(),
923+
x=x,
924+
y=y,
925+
mode=mode)
920926

921927
defend_pan(self):
922928
delself._pan_start
@@ -950,8 +956,6 @@ def drag_pan(self, button, key, x, y):
950956
startt,startr=p.trans_inverse.transform_point((p.x,p.y))
951957
t,r=p.trans_inverse.transform_point((x,y))
952958

953-
dr=r-startr
954-
955959
# Deal with r
956960
scale=r/startr
957961
self.set_rmax(p.rmax/scale)
@@ -987,7 +991,8 @@ def drag_pan(self, button, key, x, y):
987991
# vertices = self.transform(vertices)
988992

989993
# result = np.zeros((len(vertices) * 3 - 2, 2), np.float_)
990-
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
994+
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
995+
# mpath.Path.code_type)
991996
# result[0] = vertices[0]
992997
# codes[0] = mpath.Path.MOVETO
993998

@@ -1024,8 +1029,8 @@ def drag_pan(self, button, key, x, y):
10241029

10251030
# result[3::3] = p1
10261031

1027-
# printvertices[-2:]
1028-
# printresult[-2:]
1032+
# print(vertices[-2:])
1033+
# print(result[-2:])
10291034

10301035
# return mpath.Path(result, codes)
10311036

@@ -1039,12 +1044,13 @@ def drag_pan(self, button, key, x, y):
10391044
# maxtd = td.max()
10401045
# interpolate = np.ceil(maxtd / halfpi)
10411046

1042-
# print"interpolate", interpolate
1047+
# print("interpolate", interpolate)
10431048
# if interpolate > 1.0:
10441049
# vertices = self.interpolate(vertices, interpolate)
10451050

10461051
# result = np.zeros((len(vertices) * 3 - 2, 2), np.float_)
1047-
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
1052+
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
1053+
# mpath.Path.code_type)
10481054
# result[0] = vertices[0]
10491055
# codes[0] = mpath.Path.MOVETO
10501056

@@ -1066,16 +1072,19 @@ def drag_pan(self, button, key, x, y):
10661072

10671073
# result[1::3, 0] = t0 + (tkappa * td_scaled)
10681074
# result[1::3, 1] = r0*hyp_kappa
1069-
# # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled) # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
1075+
# # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled)
1076+
# # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
10701077

10711078
# result[2::3, 0] = t1 - (tkappa * td_scaled)
10721079
# result[2::3, 1] = r1*hyp_kappa
1073-
# # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled) # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
1080+
# # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled)
1081+
# # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
10741082

10751083
# result[3::3, 0] = t1
10761084
# result[3::3, 1] = r1
10771085

1078-
# print vertices[:6], result[:6], t0[:6], t1[:6], td[:6], td_scaled[:6], tkappa
1086+
# print(vertices[:6], result[:6], t0[:6], t1[:6], td[:6],
1087+
# td_scaled[:6], tkappa)
10791088
# result = self.transform(result)
10801089
# return mpath.Path(result, codes)
10811090
# transform_path_non_affine = transform_path

‎lib/matplotlib/tests/test_coding_standards.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ def test_pep8_conformance_installed_files():
243243
'sphinxext/plot_directive.py',
244244
'projections/__init__.py',
245245
'projections/geo.py',
246-
'projections/polar.py',
247246
'externals/six.py']
248247
expected_bad_files= ['*/matplotlib/'+sforsinexpected_bad_files]
249248
assert_pep8_conformance(module=matplotlib,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp