Skip to content

Commit

Permalink
Fix new codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Sep 5, 2016
1 parent 0191d45 commit 4ff6deb
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 41 deletions.
26 changes: 13 additions & 13 deletions pygal/graph/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ def _value_format(self, value, serie):
"""
if self.box_mode == "extremes":
return (
'Min: %s\nQ1 : %s\nQ2 : %s\nQ3 : %s\nMax: %s' %
tuple(map(self._y_format, serie.points[1:6])))
'Min: %s\nQ1 : %s\nQ2 : %s\nQ3 : %s\nMax: %s' % tuple(
map(self._y_format, serie.points[1:6])))
elif self.box_mode in ["tukey", "stdev", "pstdev"]:
return (
'Min: %s\nLower Whisker: %s\nQ1: %s\nQ2: %s\nQ3: %s\n'
'Upper Whisker: %s\nMax: %s' % tuple(map(
self._y_format, serie.points)))
'Min: %s\nLower Whisker: %s\nQ1: %s\nQ2: %s\nQ3: %s\n'
'Upper Whisker: %s\nMax: %s' % tuple(map(
self._y_format, serie.points)))
elif self.box_mode == '1.5IQR':
# 1.5IQR mode
return 'Q1: %s\nQ2: %s\nQ3: %s' % tuple(map(
Expand Down Expand Up @@ -166,7 +166,7 @@ def _draw_box(self, parent_node, quartiles, outliers, box_index, metadata):
alter(self.svg.node(
parent_node,
tag='circle',
cx=left_edge+width/2,
cx=left_edge + width / 2,
cy=self.view.y(o),
r=3,
class_='subtle-fill reactive tooltip-trigger'), metadata)
Expand Down Expand Up @@ -241,12 +241,12 @@ def pstdev(seq):
q3 = s[0]
elif n % 4 == 1: # n is of form 4n + 1 where n >= 1
m = (n - 1) // 4
q1 = 0.25 * s[m-1] + 0.75 * s[m]
q3 = 0.75 * s[3*m] + 0.25 * s[3*m+1]
q1 = 0.25 * s[m - 1] + 0.75 * s[m]
q3 = 0.75 * s[3 * m] + 0.25 * s[3 * m + 1]
else: # n is of form 4n + 3 where n >= 1
m = (n - 3) // 4
q1 = 0.75 * s[m] + 0.25 * s[m+1]
q3 = 0.25 * s[3*m+1] + 0.75 * s[3*m+2]
q1 = 0.75 * s[m] + 0.25 * s[m + 1]
q3 = 0.25 * s[3 * m + 1] + 0.75 * s[3 * m + 2]

iqr = q3 - q1
min_s = s[0]
Expand All @@ -261,15 +261,15 @@ def pstdev(seq):
b0 = bisect_left(s, q1 - 1.5 * iqr)
b4 = bisect_right(s, q3 + 1.5 * iqr)
q0 = s[b0]
q4 = s[b4-1]
q4 = s[b4 - 1]
outliers = s[:b0] + s[b4:]
elif mode == 'stdev':
# one standard deviation above and below the mean of the data
sd = stdev(s)
b0 = bisect_left(s, q2 - sd)
b4 = bisect_right(s, q2 + sd)
q0 = s[b0]
q4 = s[b4-1]
q4 = s[b4 - 1]
outliers = s[:b0] + s[b4:]
elif mode == 'pstdev':
# one population standard deviation above and below
Expand All @@ -278,7 +278,7 @@ def pstdev(seq):
b0 = bisect_left(s, q2 - sdp)
b4 = bisect_right(s, q2 + sdp)
q0 = s[b0]
q4 = s[b4-1]
q4 = s[b4 - 1]
outliers = s[:b0] + s[b4:]
elif mode == '1.5IQR':
# 1.5IQR mode
Expand Down
4 changes: 2 additions & 2 deletions pygal/graph/dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def _value_format(self, value):
Format value for dual value display.
"""
return '%s: %s' % (
self._x_format(value[0]),
self._y_format(value[1]))
self._x_format(value[0]),
self._y_format(value[1]))

def _compute_x_labels(self):
x_pos = compute_scale(
Expand Down
9 changes: 5 additions & 4 deletions pygal/graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,8 @@ def _compute_y_labels_major(self):
self._y_labels_major = []

def add_squares(self, squares):
x_lines = squares[0]-1
y_lines = squares[1]-1
x_lines = squares[0] - 1
y_lines = squares[1] - 1

_current_x = 0
_current_y = 0
Expand All @@ -905,15 +905,16 @@ def add_squares(self, squares):
self.nodes['plot'], 'path',
class_='bg-lines',
d='M%s %s L%s %s' % (
_current_x, 0, _current_x, self.height-self.margin_box.y))
_current_x, 0, _current_x,
self.height - self.margin_box.y))

for line in range(y_lines):
_current_y += (self.height - self.margin_box.y) / squares[1]
self.svg.node(
self.nodes['plot'], 'path',
class_='bg-lines',
d='M%s %s L%s %s' % (
0, _current_y, self.width-self.margin_box.x, _current_y))
0, _current_y, self.width - self.margin_box.x, _current_y))
return ((self.width - self.margin_box.x) / squares[0],
(self.height - self.margin_box.y) / squares[1])

Expand Down
2 changes: 1 addition & 1 deletion pygal/graph/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _fill(self, values):

# Check to see if the data has been padded with "none's"
# Fill doesn't work correctly otherwise
end = len(values)-1
end = len(values) - 1
while end > 0:
x, y = values[end]
if self.missing_value_fill_truncation == "either":
Expand Down
4 changes: 2 additions & 2 deletions pygal/graph/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def _value_format(self, value):
Format value for map value display.
"""
return '%s: %s' % (
self.area_names.get(self.adapt_code(value[0]), '?'),
self._y_format(value[1]))
self.area_names.get(self.adapt_code(value[0]), '?'),
self._y_format(value[1]))

def _plot(self):
"""Insert a map in the chart and apply data on it"""
Expand Down
2 changes: 1 addition & 1 deletion pygal/graph/pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _plot(self):
if total == 0:
return
if self.half_pie:
current_angle = 3*pi/2
current_angle = 3 * pi / 2
else:
current_angle = 0

Expand Down
18 changes: 11 additions & 7 deletions pygal/graph/solidgauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,24 @@ class SolidGauge(Graph):
def gaugify(self, serie, squares, sq_dimensions, current_square):
serie_node = self.svg.serie(serie)
if self.half_pie:
start_angle = 3*pi/2
start_angle = 3 * pi / 2
center = (
(current_square[1]*sq_dimensions[0]) - (sq_dimensions[0] / 2.),
(current_square[0]*sq_dimensions[1]) - (sq_dimensions[1] / 4))
(current_square[1] * sq_dimensions[0]) - (
sq_dimensions[0] / 2.),
(current_square[0] * sq_dimensions[1]) - (
sq_dimensions[1] / 4))
end_angle = pi / 2
else:
start_angle = 0
center = (
(current_square[1]*sq_dimensions[0]) - (sq_dimensions[0] / 2.),
(current_square[0]*sq_dimensions[1]) - (sq_dimensions[1] / 2.))
(current_square[1] * sq_dimensions[0]) - (
sq_dimensions[0] / 2.),
(current_square[0] * sq_dimensions[1]) - (
sq_dimensions[1] / 2.))
end_angle = 2 * pi

max_value = serie.metadata.get(0, {}).get('max_value', 100)
radius = min([sq_dimensions[0]/2, sq_dimensions[1]/2]) * .9
radius = min([sq_dimensions[0] / 2, sq_dimensions[1] / 2]) * .9
small_radius = radius * serie.inner_radius

self.svg.gauge_background(
Expand Down Expand Up @@ -128,7 +132,7 @@ def _squares(self):
_x, _y = 2, 3
if abs(_x - _y) > 2:
_sq = 3
while (_x * _y)-1 < len(self.series):
while (_x * _y) - 1 < len(self.series):
_x, _y = _sq, _sq
_sq += 1
return (_x, _y)
Expand Down
4 changes: 2 additions & 2 deletions pygal/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class RedBlueStyle(Style):
opacity_hover = '.9'
colors = (
'#d94e4c', '#e5884f', '#39929a',
lighten('#d94e4c', 10), darken('#39929a', 15), lighten('#e5884f', 17),
lighten('#d94e4c', 10), darken('#39929a', 15), lighten('#e5884f', 17),
darken('#d94e4c', 10), '#234547')


Expand Down Expand Up @@ -332,7 +332,7 @@ class TurquoiseStyle(Style):
transition = '250ms ease-in'
colors = (
'#93d2d9', '#ef940f', '#8C6243', '#fff',
darken('#93d2d9', 20), lighten('#ef940f', 15),
darken('#93d2d9', 20), lighten('#ef940f', 15),
lighten('#8c6243', 15), '#1b8088')


Expand Down
10 changes: 5 additions & 5 deletions pygal/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def in_attrib_and_number(key):
del attrib[key]
elif key == 'href':
attrib[etree.QName(
'http://www.w3.org/1999/xlink', key)] = attrib[key]
'http://www.w3.org/1999/xlink', key)] = attrib[key]
del attrib[key]
return etree.SubElement(parent, tag, attrib)

Expand Down Expand Up @@ -319,18 +319,18 @@ def gauge_background(
coord_diff(
center,
coord_project(
radius-(radius-small_radius)/2, start_angle)),
radius - (radius - small_radius) / 2, start_angle)),
coord_diff(
center,
coord_project(
radius-(radius-small_radius)/2, end_angle))]
radius - (radius - small_radius) / 2, end_angle))]
pos = 0
for i in begin_end:
self.node(
serie_node['plot'], 'text',
class_='y-{} bound reactive'.format(pos),
x=i[0],
y=i[1]+10,
y=i[1] + 10,
attrib={'text-anchor': 'middle'}
).text = '{}'.format(0 if pos == 0 else max_value)
pos += 1
Expand Down Expand Up @@ -392,7 +392,7 @@ def solid_gauge(
return

x, y = coord_diff(center, coord_project(
(radius + small_radius) / 2, start_angle + angle / 2))
(radius + small_radius) / 2, start_angle + angle / 2))
self.graph._static_value(serie_node, val, x, y, metadata, 'middle')
self.graph._tooltip_data(
node, val, x, y, "centered",
Expand Down
4 changes: 2 additions & 2 deletions pygal/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ def test_formatters(Chart):
"""Test custom formatters"""
if Chart._dual or Chart == Box:
return
chart = Chart(formatter=lambda x, chart, serie: '%s%s$' % (
x, serie.title))
chart = Chart(
formatter=lambda x, chart, serie: '%s%s$' % (x, serie.title))
chart.add('_a', [1, 2, {'value': 3, 'formatter': lambda x: u('%s¥') % x}])
chart.add('_b', [4, 5, 6], formatter=lambda x: u('%s€') % x)
chart.x_labels = [2, 4, 6]
Expand Down
2 changes: 1 addition & 1 deletion pygal/test/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_date_labels():
date(2013, 1, 1),
date(2013, 2, 1),
date(2013, 3, 1)
]
]

q = datey.render_pyquery()
assert list(
Expand Down
2 changes: 1 addition & 1 deletion pygal/test/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_hermite_finite(Chart, datas):
def test_hermite_cardinal(Chart, datas):
"""Test hermite cardinal interpolation"""
chart = Chart(interpolate='hermite',
interpolation_parameters={'type': 'cardinal', 'c': .75})
interpolation_parameters={'type': 'cardinal', 'c': .75})
chart = make_data(chart, datas)
assert chart.render()

Expand Down

0 comments on commit 4ff6deb

Please sign in to comment.