def make_bitmap(lightness=1, saturation=1): '''Make the bitmap of the color wheel.''' bitmap = wx.EmptyBitmap(BIG_LENGTH, BIG_LENGTH) assert isinstance(bitmap, wx.Bitmap) dc = wx.MemoryDC(bitmap) dc.SetBrush(wx_tools.get_background_brush()) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangle(-5, -5, BIG_LENGTH + 10, BIG_LENGTH + 10) center_x = center_y = BIG_LENGTH // 2 background_color_rgb = wx_tools.wx_color_to_rgb( wx_tools.get_background_color() ) for x, y in cute_iter_tools.product(xrange(BIG_LENGTH), xrange(BIG_LENGTH)): # This is a big loop so the code is optimized to keep it fast. rx, ry = (x - center_x), (y - center_y) distance = (rx ** 2 + ry ** 2) ** 0.5 if (SMALL_RADIUS - AA_THICKNESS) <= distance <= \ (BIG_RADIUS + AA_THICKNESS): angle = -math.atan2(rx, ry) hue = (angle + math.pi) / two_pi rgb = colorsys.hls_to_rgb(hue, lightness, saturation) if abs(distance - RADIUS) > HALF_THICKNESS: # This pixel requires some anti-aliasing. if distance < RADIUS: aa_distance = SMALL_RADIUS - distance else: # distance > RADIUS aa_distance = distance - BIG_RADIUS aa_ratio = aa_distance / AA_THICKNESS rgb = color_tools.mix_rgb( aa_ratio, background_color_rgb, rgb ) color = wx_tools.rgb_to_wx_color(rgb) pen = wx.Pen(color) dc.SetPen(pen) dc.DrawPoint(x, y) return bitmap
def test(): '''Test the basic workings of `CrossProcessPersistent`.''' checkers = [_check_deepcopying, _check_process_passing] cross_process_persistent_classes = [A, CrossProcessPersistent] iterator = cute_iter_tools.product( checkers, cross_process_persistent_classes, ) for checker, cross_process_persistent_class in iterator: yield checker, cross_process_persistent_class
def test(): '''Test the basic workings of `CrossProcessPersistent`.''' checkers = [_check_deepcopying, _check_process_passing] cross_process_persistent_classes = [A, CrossProcessPersistent] iterator = cute_iter_tools.product( checkers, cross_process_persistent_classes, ) for checker, cross_process_persistent_class in iterator: yield checker, cross_process_persistent_class
def simpack_test(): simpacks = [life, prisoner, _history_test, queue] crunchers = \ [garlicsim.asynchronous_crunching.crunchers.CruncherThread, garlicsim.asynchronous_crunching.crunchers.CruncherProcess] crunchers = [garlicsim.asynchronous_crunching.crunchers.CruncherThread] # Until multiprocessing shit is solved for simpack, cruncher in cute_iter_tools.product(simpacks, crunchers): yield simpack_check, simpack, cruncher
def test_helpful_warnings_for_old_protocols(): ''' Test that helpful errors are given when trying to pickle with old protocol. ''' pickle_modules = [pickle, cPickle] cross_process_persistents = [A(), CrossProcessPersistent()] old_protocols = [0, 1] iterator = cute_iter_tools.product(pickle_modules, cross_process_persistents, old_protocols) for pickle_module, cross_process_persistent, old_protocol in iterator: yield (_check_helpful_warnings_for_old_protocols, pickle_module, cross_process_persistent, old_protocol)
def test_helpful_warnings_for_old_protocols(): ''' Test that helpful errors are given when trying to pickle with old protocol. ''' pickle_modules = [pickle] cross_process_persistents = [A(), CrossProcessPersistent()] old_protocols = [0, 1] iterator = cute_iter_tools.product( pickle_modules, cross_process_persistents, old_protocols ) for pickle_module, cross_process_persistent, old_protocol in iterator: yield (_check_helpful_warnings_for_old_protocols, pickle_module, cross_process_persistent, old_protocol)