Repository: ManiacalLabs/BiblioPixel
Pull request #1008 (2018-10-13 14:27:17)

Tweaks


Patch:
diff --git a/bibliopixel/util/colors/palette.py b/bibliopixel/util/colors/palette.py
index cbec26e..df1bd00 100644
--- a/bibliopixel/util/colors/palette.py
+++ b/bibliopixel/util/colors/palette.py
@@ -44,7 +44,7 @@ class Palette(list):
         self.offset = offset
         self.autoscale = autoscale
 
-    def get(self, position, length=None):
+    def get(self, position=0, length=None):
         """
         Return a color interpolated from the Palette.
 


Test patch:
diff --git a/test/bibliopixel/control/envelope/envelope_test.py b/test/bibliopixel/control/envelope/envelope_test.py
index 1c1a1cc..306c4f0 100644
--- a/test/bibliopixel/control/envelope/envelope_test.py
+++ b/test/bibliopixel/control/envelope/envelope_test.py
@@ -93,21 +93,21 @@ class EnvelopeTest(unittest.TestCase):
 
     def test_simple_segments(self):
         env = envelope.Segments([1, 2, 3, 4])
-        self.assertEquals(env.period, 1)
+        self.assertEqual(env.period, 1)
 
         expected = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 0]
         function_tester(env, self, expected)
 
     def test_simple_segments2(self):
         env = envelope.Segments([1, 1.5, 3, 7])
-        self.assertEquals(env.period, 1)
+        self.assertEqual(env.period, 1)
 
         expected = [0, 0.5, 1, 1.25, 1.5, 2.25, 3, 5, 0]
         function_tester(env, self, expected)
 
     def test_decreasing_segments(self):
         env = envelope.Segments([1, 3, 2, 4])
-        self.assertEquals(env.period, 1)
+        self.assertEqual(env.period, 1)
 
         expected = [0, 0.5, 1, 2, 3, 2.5, 2, 3, 0]
         function_tester(env, self, expected)
diff --git a/test/bibliopixel/control/envelope/segments_test.py b/test/bibliopixel/control/envelope/segments_test.py
index aaa73be..c0694ac 100644
--- a/test/bibliopixel/control/envelope/segments_test.py
+++ b/test/bibliopixel/control/envelope/segments_test.py
@@ -15,37 +15,37 @@ class SegmentsTest(unittest.TestCase):
 
     def test_simple_segments(self):
         segs = segments.Segments([1, 2, 3, 4])
-        self.assertEquals(segs.total_time, 1)
+        self.assertEqual(segs.total_time, 1)
 
         expected = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4]
         function_tester(segs, self, expected)
 
     def test_simple_segments2(self):
         segs = segments.Segments([1, 1.5, 3, 7])
-        self.assertEquals(segs.total_time, 1)
+        self.assertEqual(segs.total_time, 1)
 
         expected = [0, 0.5, 1, 1.25, 1.5, 2.25, 3, 5, 7]
         function_tester(segs, self, expected)
 
     def test_decreasing_segments(self):
         segs = segments.Segments([1, 3, 2, 4])
-        self.assertEquals(segs.total_time, 1)
+        self.assertEqual(segs.total_time, 1)
 
         expected = [0, 0.5, 1, 2, 3, 2.5, 2, 3, 4]
         function_tester(segs, self, expected)
 
     def test_timed_segments(self):
         segs = segments.Segments([(1, 1), (2, 1), (5, 0.5), (11, 0.5)])
-        self.assertEquals(segs.total_time, 3)
+        self.assertEqual(segs.total_time, 3)
         log.printer(segs)
-        self.assertEquals(segs(0), 0)
-        self.assertEquals(segs(0.5), 0.5)
-        self.assertEquals(segs(1), 1)
-        self.assertEquals(segs(2), 2)
-        self.assertEquals(segs(2.25), 3.5)
-        self.assertEquals(segs(2.5), 5)
-        self.assertEquals(segs(2.75), 8)
-        self.assertEquals(segs(3), 11)
+        self.assertEqual(segs(0), 0)
+        self.assertEqual(segs(0.5), 0.5)
+        self.assertEqual(segs(1), 1)
+        self.assertEqual(segs(2), 2)
+        self.assertEqual(segs(2.25), 3.5)
+        self.assertEqual(segs(2.5), 5)
+        self.assertEqual(segs(2.75), 8)
+        self.assertEqual(segs(3), 11)
 
 
 def function_tester(function, test, expected, frac=0):
@@ -55,4 +55,4 @@ def function_tester(function, test, expected, frac=0):
 
     actual = [round(i, 12) for i in actual]
     expected = [round(i, 12) for i in expected]
-    test.assertEquals(expected, actual)
+    test.assertEqual(expected, actual)
diff --git a/test/bibliopixel/util/colors/palette_test.py b/test/bibliopixel/util/colors/palette_test.py
index a22640f..d6c9f56 100644
--- a/test/bibliopixel/util/colors/palette_test.py
+++ b/test/bibliopixel/util/colors/palette_test.py
@@ -3,19 +3,20 @@ from fractions import Fraction
 
 from bibliopixel.util.colors.palette import Palette
 from bibliopixel.util.colors.classic import Black, White, Red, Green, Blue
+from bibliopixel.util import log
 
 
 class PaletteTest(unittest.TestCase):
     def test_empty(self):
         p = Palette()
         self.assertEqual(p[0], Black)
-        self.assertEqual(p.get(0), Black)
+        self.assertEqual(p.get(), Black)
         self.assertEqual(p.get(1), Black)
 
     def test_single(self):
         p = Palette([Red])
         self.assertEqual(p[0], Red)
-        self.assertEqual(p.get(0), Red)
+        self.assertEqual(p.get(), Red)
         self.assertEqual(p.get(1), Red)
 
     def test_get(self):
@@ -185,17 +186,18 @@ class PaletteTest(unittest.TestCase):
             Green, Red, Red, Red, Green, Blue, Blue, White,
             Blue]
 
-        # result2 = [tuple(float(i) for i in c) for c in result]
-        # print('', *result2, sep=',\n            ')
         self.assertEqual(expected, result)
 
+    def _print_result(self, result):
+        result2 = [tuple(float(i) for i in c) for c in result]
+        log.printer('', *result2, sep=',\n            ')
+
     def test_autoscale(self):
         colors = [Red, Green, Blue, White]
         p = Palette(colors, autoscale=True)
 
         expected = [Red, Red, Green, Green, Blue, Blue, White, White, Red, Red]
         result = [p.get(32 * i, 256) for i in range(10)]
-        print(*result, sep='\n')
         self.assertEqual(expected, result)
 
         result = [p.get(Fraction(i) / 2) for i in range(10)]