# Path: bibliopixel/colors/gamma.py
# class Gamma(object):
#     def __init__(self, gamma=1.0, offset=0, lower_bound=0):
#         def gam(i):
#     def get(self, i):
#     def batch_correct(self, uncorrected):
# APA102 = Gamma(gamma=2.5, offset=0.5)
# WS2801 = SM16716 = Gamma(gamma=2.5)
# NONE = DEFAULT = Gamma()  # For when you need no correction
# WS2812B = NEOPIXEL = WS2812 = Gamma(gamma=1 / 0.45)
# LPD8806 = Gamma(gamma=2.5, offset=0.5, lower_bound=128)
# 
# Path: bibliopixel/drivers/driver_base.py
# class DriverBase(object):
#     def construct(cls, project, **desc):
#     def __init__(self, num=0, width=0, height=0, c_order="RGB",
#                  gamma=None, maker=data_maker.MAKER, **kwds):
#     def set_pixel_positions(self, pixel_positions):
#     def set_colors(self, colors, pos):
#     def set_project(self, project):
#     def start(self):
#     def stop(self):
#     def cleanup(self):
#     def join(self, timeout=None):
#     def bufByteCount(self):
#     def sync(self):
#     def _compute_packet(self):
#     def _send_packet(self):
#     def update_colors(self):
#     def set_brightness(self, brightness):
#     def _render(self):
#     def _make_buffer(self):


import unittest
from bibliopixel.colors import gamma
from bibliopixel.drivers.driver_base import DriverBase, ChannelOrder
from bibliopixel.drivers.SPI import SPI, SPI_INTERFACES
from bibliopixel.drivers.ledtype import LEDTYPE
    def do_test(self, driver, expected):
        driver.set_colors(self.COLORS, 0)
        driver._render()
        self.assertEqual(list(driver._buf), expected)

    def test_trivial(self):
        driver = DriverBase(num=4)
        for i in range(len(driver._buf)):
            driver._buf[i] = 23  # randomize
        self.assertTrue(all(driver._buf))
        driver.set_colors([(0, 0, 0)] * 4, 0)
        driver._render()
        self.assertFalse(any(driver._buf))  # It wrote zeroes!

    def test_simple(self):
        driver = DriverBase(num=4)
        expected = [0, 0, 0, 1, 8, 64, 2, 16, 128, 3, 24, 192]
        self.do_test(driver, expected)

    def test_permute(self):
        driver = DriverBase(num=4, c_order=ChannelOrder.GRB)
        expected = [0, 0, 0, 8, 1, 64, 16, 2, 128, 24, 3, 192]
        self.do_test(driver, expected)

    def test_permute2(self):
        driver = DriverBase(num=4, c_order=ChannelOrder.BRG)
        expected = [0, 0, 0, 64, 1, 8, 128, 2, 16, 192, 3, 24]
        self.do_test(driver, expected)

    def test_gamma1(self):

# Path: bibliopixel/colors/gamma.py
# class Gamma(object):
#     def __init__(self, gamma=1.0, offset=0, lower_bound=0):
#         def gam(i):
#     def get(self, i):
#     def batch_correct(self, uncorrected):
# APA102 = Gamma(gamma=2.5, offset=0.5)
# WS2801 = SM16716 = Gamma(gamma=2.5)
# NONE = DEFAULT = Gamma()  # For when you need no correction
# WS2812B = NEOPIXEL = WS2812 = Gamma(gamma=1 / 0.45)
# LPD8806 = Gamma(gamma=2.5, offset=0.5, lower_bound=128)
# 
# Path: bibliopixel/drivers/driver_base.py
# class DriverBase(object):
#     def construct(cls, project, **desc):
#     def __init__(self, num=0, width=0, height=0, c_order="RGB",
#                  gamma=None, maker=data_maker.MAKER, **kwds):
#     def set_pixel_positions(self, pixel_positions):
#     def set_colors(self, colors, pos):
#     def set_project(self, project):
#     def start(self):
#     def stop(self):
#     def cleanup(self):
#     def join(self, timeout=None):
#     def bufByteCount(self):
#     def sync(self):
#     def _compute_packet(self):
#     def _send_packet(self):
#     def update_colors(self):
#     def set_brightness(self, brightness):
#     def _render(self):
#     def _make_buffer(self):


# Path: test/bibliopixel/drivers/driver_test.py
import unittest
from bibliopixel.colors import gamma
from bibliopixel.drivers.driver_base import DriverBase, ChannelOrder
from bibliopixel.drivers.SPI import SPI, SPI_INTERFACES
from bibliopixel.drivers.ledtype import LEDTYPE

    def do_test(self, driver, expected):
        driver.set_colors(self.COLORS, 0)
        driver._render()
        self.assertEqual(list(driver._buf), expected)

    def test_trivial(self):
        driver = DriverBase(num=4)
        for i in range(len(driver._buf)):
            driver._buf[i] = 23  # randomize
        self.assertTrue(all(driver._buf))
        driver.set_colors([(0, 0, 0)] * 4, 0)
        driver._render()
        self.assertFalse(any(driver._buf))  # It wrote zeroes!

    def test_simple(self):
        driver = DriverBase(num=4)
        expected = [0, 0, 0, 1, 8, 64, 2, 16, 128, 3, 24, 192]
        self.do_test(driver, expected)

    def test_permute(self):
        driver = DriverBase(num=4, c_order=ChannelOrder.GRB)
        expected = [0, 0, 0, 8, 1, 64, 16, 2, 128, 24, 3, 192]
        self.do_test(driver, expected)

    def test_permute2(self):
        driver = DriverBase(num=4, c_order=ChannelOrder.BRG)
        expected = [0, 0, 0, 64, 1, 8, 128, 2, 16, 192, 3, 24]
        self.do_test(driver, expected)

    def test_gamma1(self):

        driver = DriverBase(num=4, gamma=gamma.LPD8806)