From 5fb3ea060025241105dc8e9a174513c112f9a133 Mon Sep 17 00:00:00 2001 From: rcoh Date: Thu, 27 Jan 2011 16:50:59 -0500 Subject: A metric $#%$-ton of changes. Added doc-strings to EVERYTHING. Phew. Fixed a massive bug that increases performance in by up to a factor of 60. A bunch of new behaviors for the class. --- pixelcore/Screen.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'pixelcore/Screen.py') diff --git a/pixelcore/Screen.py b/pixelcore/Screen.py index b595847..9a81df7 100644 --- a/pixelcore/Screen.py +++ b/pixelcore/Screen.py @@ -10,9 +10,10 @@ import itertools import sys import pdb from logger import main_log -#Class representing a collection of Pixels grouped into PixelStrips. Needs a -#PixelMapper, currently set via setMapper by may be migrated into the argDict. class Screen: + """Class representing a collection of Pixels grouped into PixelStrips. Needs a + PixelMapper, currently set via setMapper by may be migrated into the argDict.""" + def __init__(self): self.responseQueue = [] self.pixelStrips = [] @@ -20,14 +21,15 @@ class Screen: self.xPixelLocs = [] sizeValid = False self.pixelsSorted = False + def addStrip(self, lS): self.pixelStrips.append(lS) self.sizeValid = False #keep track of whether or not our screen size has self.pixelsSorted = False #been invalidated by adding more pixels - #Returns (pixelIndex, pixel). Does a binary search. def pixelsInRange(self, minX, maxX): + """Returns (pixelIndex, pixel). Does a binary search.""" if not self.pixelsSorted: self.computeXSortedPixels() minIndex = Search.find_ge(self.xPixelLocs, minX) @@ -41,10 +43,7 @@ class Screen: self.xSortedPixels.sort() self.xPixelLocs = [p[0] for p in self.xSortedPixels] self.pixelsSorted = True - #For debug only - def allOn(self): - [lS.allOn(-1) for lS in self.pixelStrips] - + def __iter__(self): #the iterator of all our pixel strips chained togther return itertools.chain(*[strip.__iter__() for strip in \ self.pixelStrips]) #the * operator breaks the list into args -- cgit v1.2.3