Skip to content

UnCamelCase examples. #16201

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

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/event_handling/pipong.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,18 @@ def __init__(self, ax):
self.ax = ax
ax.set_ylim([-1, 1])
ax.set_xlim([0, 7])
padAx = 0
padBx = .50
padAy = padBy = .30
padBx += 6.3
pad_a_x = 0
pad_b_x = .50
pad_a_y = pad_b_y = .30
pad_b_x += 6.3

# pads
pA, = self.ax.barh(padAy, .2,
pA, = self.ax.barh(pad_a_y, .2,
height=.3, color='k', alpha=.5, edgecolor='b',
lw=2, label="Player B",
animated=True)
pB, = self.ax.barh(padBy, .2,
height=.3, left=padBx, color='k', alpha=.5,
pB, = self.ax.barh(pad_b_y, .2,
height=.3, left=pad_b_x, color='k', alpha=.5,
edgecolor='r', lw=2, label="Player A",
animated=True)

Expand Down Expand Up @@ -169,8 +169,8 @@ def __init__(self, ax):
self.on = False
self.inst = True # show instructions from the beginning
self.background = None
self.pads = [Pad(pA, padAx, padAy),
Pad(pB, padBx, padBy, 'r')]
self.pads = [Pad(pA, pad_a_x, pad_a_y),
Pad(pB, pad_b_x, pad_b_y, 'r')]
self.pucks = []
self.i = self.ax.annotate(instructions, (.5, 0.5),
name='monospace',
Expand Down
42 changes: 20 additions & 22 deletions examples/statistics/boxplot_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
The following examples show off how to visualize boxplots with
Matplotlib. There are many options to control their appearance and
the statistics that they use to summarize the data.

"""

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Polygon
Expand Down Expand Up @@ -130,23 +130,23 @@
medians = np.empty(num_boxes)
for i in range(num_boxes):
box = bp['boxes'][i]
boxX = []
boxY = []
box_x = []
box_y = []
for j in range(5):
boxX.append(box.get_xdata()[j])
boxY.append(box.get_ydata()[j])
box_coords = np.column_stack([boxX, boxY])
box_x.append(box.get_xdata()[j])
box_y.append(box.get_ydata()[j])
box_coords = np.column_stack([box_x, box_y])
# Alternate between Dark Khaki and Royal Blue
ax1.add_patch(Polygon(box_coords, facecolor=box_colors[i % 2]))
# Now draw the median lines back over what we just filled in
med = bp['medians'][i]
medianX = []
medianY = []
median_x = []
median_y = []
for j in range(2):
medianX.append(med.get_xdata()[j])
medianY.append(med.get_ydata()[j])
ax1.plot(medianX, medianY, 'k')
medians[i] = medianY[0]
median_x.append(med.get_xdata()[j])
median_y.append(med.get_ydata()[j])
ax1.plot(median_x, median_y, 'k')
medians[i] = median_y[0]
# Finally, overplot the sample averages, with horizontal alignment
# in the center of each box
ax1.plot(np.average(med.get_xdata()), np.average(data[i]),
Expand Down Expand Up @@ -193,22 +193,20 @@
# We can then use the boxplot along with this function to show these intervals.


def fakeBootStrapper(n):
def fake_bootstrapper(n):
"""
This is just a placeholder for the user's method of
bootstrapping the median and its confidence intervals.

Returns an arbitrary median and confidence intervals
packed into a tuple
Returns an arbitrary median and confidence interval packed into a tuple.
"""
if n == 1:
med = 0.1
CI = (-0.25, 0.25)
ci = (-0.25, 0.25)
else:
med = 0.2
CI = (-0.35, 0.50)

return med, CI
ci = (-0.35, 0.50)
return med, ci

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

treatments = [e1, e2, e3, e4]
med1, CI1 = fakeBootStrapper(1)
med2, CI2 = fakeBootStrapper(2)
med1, ci1 = fake_bootstrapper(1)
med2, ci2 = fake_bootstrapper(2)
medians = [None, None, med1, med2]
conf_intervals = [None, None, CI1, CI2]
conf_intervals = [None, None, ci1, ci2]

fig, ax = plt.subplots()
pos = np.array(range(len(treatments))) + 1
Expand Down
4 changes: 2 additions & 2 deletions examples/statistics/customized_violin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def set_axis_style(ax, labels):
whiskers = np.array([
adjacent_values(sorted_array, q1, q3)
for sorted_array, q1, q3 in zip(data, quartile1, quartile3)])
whiskersMin, whiskersMax = whiskers[:, 0], whiskers[:, 1]
whiskers_min, whiskers_max = whiskers[:, 0], whiskers[:, 1]

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

# set style for the axes
labels = ['A', 'B', 'C', 'D']
Expand Down
8 changes: 1 addition & 7 deletions examples/units/basic_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,8 @@ def __new__(cls, value, unit):
try:
subcls = type(f'TaggedValue_of_{value_class.__name__}',
(cls, value_class), {})
if subcls not in units.registry:
units.registry[subcls] = basicConverter
return object.__new__(subcls)
except TypeError:
if cls not in units.registry:
units.registry[cls] = basicConverter
return object.__new__(cls)

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


basicConverter = BasicUnitConverter()
units.registry[BasicUnit] = basicConverter
units.registry[TaggedValue] = basicConverter
units.registry[BasicUnit] = units.registry[TaggedValue] = BasicUnitConverter()