Commits

Ralph Bean committed b3778ea

PEP8 in samples.py.

Comments (0)

Files changed (3)

     author_email='rbean@redhat.com',
     url='http://github.com/toscawidgets/tw2.protovis.conventional',
     install_requires=[
-        "tw2.core",
+        "tw2.core>=2.0.0",
         "tw2.protovis.core",
         ],
     packages=find_packages(exclude=['ez_setup']),

tw2/protovis/conventional/samples.py

 import random
 import time
 
+
 class DemoAreaChart(AreaChart):
-    p_data = [{'x': i, 'y' : math.sin(i) + random.random() * .5 + 2}
-                for i in map(lambda x : x / 10.0, range(100))]
+    p_data = [{'x': i, 'y': math.sin(i) + random.random() * .5 + 2}
+                for i in map(lambda x: x / 10.0, range(100))]
+
 
 class DemoBarChart(BarChart):
-    p_data = [random.random()*100 for i in range(10)]
+    p_data = [random.random() * 100 for i in range(10)]
     p_labels = ['label ' + str(i) for i in range(10)]
 
+
 class DemoScatterPlot(ScatterPlot):
-    p_data = [{'x': i, 'y' : random.random(), 'z' : 10**(2*random.random())}
+    p_data = [{'x': i, 'y': random.random(), 'z': 10 ** (2 * random.random())}
                 for i in range(100)]
 
+
 class DemoPieChart(PieChart):
     p_data = [random.random() for i in range(10)]
 
 
-
 class DemoLineChart(LineChart):
     class AutoRefreshingData(object):
-        """ Helper class for DemoLineChart.  Refreshes its data dynamically. """
+        """ Helper class for DemoLineChart.  Refreshes its data dynamically.
+        """
         def __iter__(self):
             n = 20.0
             T_scale = 1000.0
             now = int(time.time())
-            tspan = range(now-100, now)
+            tspan = range(now - 100, now)
             funcs = [
-                lambda t : math.sin(t/n),
-                lambda t : abs(math.sin(t/n))**((t%(2*n))/n),
-                lambda t : math.cos(t/(n+1))*1.5,
+                lambda t: math.sin(t / n),
+                lambda t: abs(math.sin(t / n)) ** ((t % (2 * n)) / n),
+                lambda t: math.cos(t / (n + 1)) * 1.5,
             ]
             funcs.append(
-                lambda t : funcs[1](t) * funcs[2](t)
+                lambda t: funcs[1](t) * funcs[2](t)
             )
 
             for i in range(len(funcs)):
-                yield [ { 'x': t*1000.0, 'y' : funcs[i](float(t)) }
-                       for t in tspan ]
+                yield [{'x': t * 1000.0, 'y': funcs[i](float(t))}
+                       for t in tspan]
 
         def __repr__(self):
             print "repr"
     p_time_series = True
     p_time_series_format = "%I:%M:%S"
 
+
 class DemoStackedAreaChart(StackedAreaChart):
     class AutoRefreshingData(object):
-        """ Helper class for DemoLineChart.  Refreshes its data dynamically. """
+        """ Helper class for DemoLineChart.  Refreshes its data dynamically.
+        """
         def __iter__(self):
             n = 20.0
             T_scale = 1000.0
             now = int(time.time())
-            tspan = range(now-100, now)
+            tspan = range(now - 100, now)
             funcs = [
-                lambda t : math.sin(t/n),
-                lambda t : abs(math.sin(t/n))**((t%(2*n))/n),
-                lambda t : math.cos(t/(n+1))*1.5,
+                lambda t: math.sin(t / n),
+                lambda t: abs(math.sin(t / n)) ** ((t % (2 * n)) / n),
+                lambda t: math.cos(t / (n + 1)) * 1.5,
             ]
             funcs.append(
-                lambda t : funcs[1](t) * funcs[2](t)
+                lambda t: funcs[1](t) * funcs[2](t)
             )
 
             for i in range(len(funcs)):
-                yield [ { 'x': t*1000.0, 'y' : abs(funcs[i](float(t))) }
-                       for t in tspan ]
+                yield [{'x': t * 1000.0, 'y': abs(funcs[i](float(t)))}
+                       for t in tspan]
 
         def __repr__(self):
             print "repr"
     p_time_series = True
     p_time_series_format = "%I:%M:%S"
 
+
 class DemoGroupedBarChart(GroupedBarChart):
     p_data = [
         [random.random() + 0.1 for j in range(4)] for i in range(3)]

tw2/protovis/conventional/widgets.py

     print value
     return value
 
-class js(twc.JSSymbol):
-    def __init__(self, src):
-        super(js, self).__init__(src=src)
+js = twc.js_symbol
 
 class AreaChart(twp.PVWidget):
     p_color = twc.Param('Color of the area', default='rgb(121,173,210)')