Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec83125

Browse files
authored
Merge pull request #16201 from anntzer/camelicide
UnCamelCase examples.
2 parents 696be2c + ebde562 commit ec83125

File tree

4 files changed

+32
-40
lines changed

4 files changed

+32
-40
lines changed

examples/event_handling/pipong.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ def __init__(self, ax):
126126
self.ax = ax
127127
ax.set_ylim([-1, 1])
128128
ax.set_xlim([0, 7])
129-
padAx = 0
130-
padBx = .50
131-
padAy = padBy = .30
132-
padBx += 6.3
129+
pad_a_x = 0
130+
pad_b_x = .50
131+
pad_a_y = pad_b_y = .30
132+
pad_b_x += 6.3
133133

134134
# pads
135-
pA, = self.ax.barh(padAy, .2,
135+
pA, = self.ax.barh(pad_a_y, .2,
136136
height=.3, color='k', alpha=.5, edgecolor='b',
137137
lw=2, label="Player B",
138138
animated=True)
139-
pB, = self.ax.barh(padBy, .2,
140-
height=.3, left=padBx, color='k', alpha=.5,
139+
pB, = self.ax.barh(pad_b_y, .2,
140+
height=.3, left=pad_b_x, color='k', alpha=.5,
141141
edgecolor='r', lw=2, label="Player A",
142142
animated=True)
143143

@@ -169,8 +169,8 @@ def __init__(self, ax):
169169
self.on = False
170170
self.inst = True # show instructions from the beginning
171171
self.background = None
172-
self.pads = [Pad(pA, padAx, padAy),
173-
Pad(pB, padBx, padBy, 'r')]
172+
self.pads = [Pad(pA, pad_a_x, pad_a_y),
173+
Pad(pB, pad_b_x, pad_b_y, 'r')]
174174
self.pucks = []
175175
self.i = self.ax.annotate(instructions, (.5, 0.5),
176176
name='monospace',

examples/statistics/boxplot_demo.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
The following examples show off how to visualize boxplots with
99
Matplotlib. There are many options to control their appearance and
1010
the statistics that they use to summarize the data.
11-
1211
"""
12+
1313
import matplotlib.pyplot as plt
1414
import numpy as np
1515
from matplotlib.patches import Polygon
@@ -130,23 +130,23 @@
130130
medians = np.empty(num_boxes)
131131
for i in range(num_boxes):
132132
box = bp['boxes'][i]
133-
boxX = []
134-
boxY = []
133+
box_x = []
134+
box_y = []
135135
for j in range(5):
136-
boxX.append(box.get_xdata()[j])
137-
boxY.append(box.get_ydata()[j])
138-
box_coords = np.column_stack([boxX, boxY])
136+
box_x.append(box.get_xdata()[j])
137+
box_y.append(box.get_ydata()[j])
138+
box_coords = np.column_stack([box_x, box_y])
139139
# Alternate between Dark Khaki and Royal Blue
140140
ax1.add_patch(Polygon(box_coords, facecolor=box_colors[i % 2]))
141141
# Now draw the median lines back over what we just filled in
142142
med = bp['medians'][i]
143-
medianX = []
144-
medianY = []
143+
median_x = []
144+
median_y = []
145145
for j in range(2):
146-
medianX.append(med.get_xdata()[j])
147-
medianY.append(med.get_ydata()[j])
148-
ax1.plot(medianX, medianY, 'k')
149-
medians[i] = medianY[0]
146+
median_x.append(med.get_xdata()[j])
147+
median_y.append(med.get_ydata()[j])
148+
ax1.plot(median_x, median_y, 'k')
149+
medians[i] = median_y[0]
150150
# Finally, overplot the sample averages, with horizontal alignment
151151
# in the center of each box
152152
ax1.plot(np.average(med.get_xdata()), np.average(data[i]),
@@ -193,22 +193,20 @@
193193
# We can then use the boxplot along with this function to show these intervals.
194194

195195

196-
def fakeBootStrapper(n):
196+
def fake_bootstrapper(n):
197197
"""
198198
This is just a placeholder for the user's method of
199199
bootstrapping the median and its confidence intervals.
200200
201-
Returns an arbitrary median and confidence intervals
202-
packed into a tuple
201+
Returns an arbitrary median and confidence interval packed into a tuple.
203202
"""
204203
if n == 1:
205204
med = 0.1
206-
CI = (-0.25, 0.25)
205+
ci = (-0.25, 0.25)
207206
else:
208207
med = 0.2
209-
CI = (-0.35, 0.50)
210-
211-
return med, CI
208+
ci = (-0.35, 0.50)
209+
return med, ci
212210

213211
inc = 0.1
214212
e1 = np.random.normal(0, 1, size=500)
@@ -217,10 +215,10 @@ def fakeBootStrapper(n):
217215
e4 = np.random.normal(0, 1 + 2*inc, size=500)
218216

219217
treatments = [e1, e2, e3, e4]
220-
med1, CI1 = fakeBootStrapper(1)
221-
med2, CI2 = fakeBootStrapper(2)
218+
med1, ci1 = fake_bootstrapper(1)
219+
med2, ci2 = fake_bootstrapper(2)
222220
medians = [None, None, med1, med2]
223-
conf_intervals = [None, None, CI1, CI2]
221+
conf_intervals = [None, None, ci1, ci2]
224222

225223
fig, ax = plt.subplots()
226224
pos = np.array(range(len(treatments))) + 1

examples/statistics/customized_violin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ def set_axis_style(ax, labels):
6060
whiskers = np.array([
6161
adjacent_values(sorted_array, q1, q3)
6262
for sorted_array, q1, q3 in zip(data, quartile1, quartile3)])
63-
whiskersMin, whiskersMax = whiskers[:, 0], whiskers[:, 1]
63+
whiskers_min, whiskers_max = whiskers[:, 0], whiskers[:, 1]
6464

6565
inds = np.arange(1, len(medians) + 1)
6666
ax2.scatter(inds, medians, marker='o', color='white', s=30, zorder=3)
6767
ax2.vlines(inds, quartile1, quartile3, color='k', linestyle='-', lw=5)
68-
ax2.vlines(inds, whiskersMin, whiskersMax, color='k', linestyle='-', lw=1)
68+
ax2.vlines(inds, whiskers_min, whiskers_max, color='k', linestyle='-', lw=1)
6969

7070
# set style for the axes
7171
labels = ['A', 'B', 'C', 'D']

examples/units/basic_units.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,8 @@ def __new__(cls, value, unit):
122122
try:
123123
subcls = type(f'TaggedValue_of_{value_class.__name__}',
124124
(cls, value_class), {})
125-
if subcls not in units.registry:
126-
units.registry[subcls] = basicConverter
127125
return object.__new__(subcls)
128126
except TypeError:
129-
if cls not in units.registry:
130-
units.registry[cls] = basicConverter
131127
return object.__new__(cls)
132128

133129
def __init__(self, value, unit):
@@ -378,6 +374,4 @@ def cos(x):
378374
return math.cos(x.convert_to(radians).get_value())
379375

380376

381-
basicConverter = BasicUnitConverter()
382-
units.registry[BasicUnit] = basicConverter
383-
units.registry[TaggedValue] = basicConverter
377+
units.registry[BasicUnit] = units.registry[TaggedValue] = BasicUnitConverter()

0 commit comments

Comments
 (0)