From 4ff6debb01f466d53618b6b18298d91aef5c05d8 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Mon, 5 Sep 2016 15:01:24 +0200 Subject: [PATCH] Fix new codestyle --- pygal/graph/box.py | 26 +++++++++++++------------- pygal/graph/dual.py | 4 ++-- pygal/graph/graph.py | 9 +++++---- pygal/graph/line.py | 2 +- pygal/graph/map.py | 4 ++-- pygal/graph/pie.py | 2 +- pygal/graph/solidgauge.py | 18 +++++++++++------- pygal/style.py | 4 ++-- pygal/svg.py | 10 +++++----- pygal/test/test_config.py | 4 ++-- pygal/test/test_date.py | 2 +- pygal/test/test_interpolate.py | 2 +- 12 files changed, 46 insertions(+), 41 deletions(-) diff --git a/pygal/graph/box.py b/pygal/graph/box.py index 8f3b260..5a77afc 100644 --- a/pygal/graph/box.py +++ b/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 diff --git a/pygal/graph/dual.py b/pygal/graph/dual.py index 2b1bcef..ac8d4a8 100644 --- a/pygal/graph/dual.py +++ b/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( diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index 23e0669..c993597 100644 --- a/pygal/graph/graph.py +++ b/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]) diff --git a/pygal/graph/line.py b/pygal/graph/line.py index e7a1e4c..59e4c26 100644 --- a/pygal/graph/line.py +++ b/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": diff --git a/pygal/graph/map.py b/pygal/graph/map.py index 5600411..22e66d9 100644 --- a/pygal/graph/map.py +++ b/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""" diff --git a/pygal/graph/pie.py b/pygal/graph/pie.py index 3627b47..be2d425 100644 --- a/pygal/graph/pie.py +++ b/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 diff --git a/pygal/graph/solidgauge.py b/pygal/graph/solidgauge.py index eb0aa31..ae673d6 100644 --- a/pygal/graph/solidgauge.py +++ b/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) diff --git a/pygal/style.py b/pygal/style.py index 3f5d35a..1b01984 100644 --- a/pygal/style.py +++ b/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') diff --git a/pygal/svg.py b/pygal/svg.py index 21a22c0..94bf23d 100644 --- a/pygal/svg.py +++ b/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", diff --git a/pygal/test/test_config.py b/pygal/test/test_config.py index 11001c9..aecb289 100644 --- a/pygal/test/test_config.py +++ b/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] diff --git a/pygal/test/test_date.py b/pygal/test/test_date.py index d5b6f05..e58dd45 100644 --- a/pygal/test/test_date.py +++ b/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( diff --git a/pygal/test/test_interpolate.py b/pygal/test/test_interpolate.py index c7656e1..a2eda9c 100644 --- a/pygal/test/test_interpolate.py +++ b/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()