Browse Source

Fix new codestyle

pull/339/head
Florian Mounier 8 years ago
parent
commit
4ff6debb01
  1. 26
      pygal/graph/box.py
  2. 4
      pygal/graph/dual.py
  3. 9
      pygal/graph/graph.py
  4. 2
      pygal/graph/line.py
  5. 4
      pygal/graph/map.py
  6. 2
      pygal/graph/pie.py
  7. 18
      pygal/graph/solidgauge.py
  8. 4
      pygal/style.py
  9. 10
      pygal/svg.py
  10. 4
      pygal/test/test_config.py
  11. 2
      pygal/test/test_date.py
  12. 2
      pygal/test/test_interpolate.py

26
pygal/graph/box.py

@ -49,13 +49,13 @@ class Box(Graph):
"""
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(
@ -166,7 +166,7 @@ class Box(Graph):
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)
@ -241,12 +241,12 @@ class Box(Graph):
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]
@ -261,7 +261,7 @@ class Box(Graph):
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
@ -269,7 +269,7 @@ class Box(Graph):
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
@ -278,7 +278,7 @@ class Box(Graph):
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

4
pygal/graph/dual.py

@ -32,8 +32,8 @@ class Dual(Graph):
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(

9
pygal/graph/graph.py

@ -893,8 +893,8 @@ class Graph(PublicApi):
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
@ -905,7 +905,8 @@ class Graph(PublicApi):
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]
@ -913,7 +914,7 @@ class Graph(PublicApi):
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])

2
pygal/graph/line.py

@ -63,7 +63,7 @@ class Line(Graph):
# 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":

4
pygal/graph/map.py

@ -57,8 +57,8 @@ class BaseMap(Graph):
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"""

2
pygal/graph/pie.py

@ -97,7 +97,7 @@ class Pie(Graph):
if total == 0:
return
if self.half_pie:
current_angle = 3*pi/2
current_angle = 3 * pi / 2
else:
current_angle = 0

18
pygal/graph/solidgauge.py

@ -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(
@ -128,7 +132,7 @@ class SolidGauge(Graph):
_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)

4
pygal/style.py

@ -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')
@ -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')

10
pygal/svg.py

@ -199,7 +199,7 @@ class Svg(object):
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)
@ -319,18 +319,18 @@ class Svg(object):
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
@ -392,7 +392,7 @@ class Svg(object):
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",

4
pygal/test/test_config.py

@ -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]

2
pygal/test/test_date.py

@ -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(

2
pygal/test/test_interpolate.py

@ -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()

Loading…
Cancel
Save