Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Expanded some documentation.

Added clean target to doc Makefile.
This commit is contained in:
Einar Ryeng 2006-10-17 17:18:46 +00:00
parent 5d4700da20
commit fe96772319
2 changed files with 26 additions and 2 deletions

View File

@ -8,4 +8,7 @@ html:
@echo ---------------- @echo ----------------
epydoc --html -o html/ ../fluents ../workflows 2> epydoc-html.log epydoc --html -o html/ ../fluents ../workflows 2> epydoc-html.log
clean:
-rm -rf html
-rm epydoc-html.log

View File

@ -23,9 +23,19 @@ import scipy
active_mode = 'default' active_mode = 'default'
class ObjectTable: class ObjectTable:
"""A 2D table of elements.""" """A 2D table of elements.
An ObjectTable is a resizable two-dimensional array of objects.
When resized, it will keep all the elements that fit in the new shape,
and forget about other elements. When new elements are needed to fill
out the new shape, they will be created.
"""
def __init__(self, xsize=0, ysize=0, creator=None): def __init__(self, xsize=0, ysize=0, creator=None):
"""Creates a two-dimensional table of objects.
@param xsize: Width of the object table.
@param ysize: Height of the object table.
@param creator: A function that will be used to instantiate new items.
"""
self._elements = [] self._elements = []
self._creator = creator or (lambda : None) self._creator = creator or (lambda : None)
self.xsize = xsize self.xsize = xsize
@ -33,7 +43,18 @@ class ObjectTable:
self.resize(xsize, ysize) self.resize(xsize, ysize)
def resize(self, xsize, ysize): def resize(self, xsize, ysize):
"""Resizes the table by removing and creating elements as required.""" """Resizes the table by removing and creating elements as required.
Makes the ObjectTable the specified size by removing elements that
will not fit in the new shape and appending elements to fill the
table. New elements will be created with the creator function passed
as an argument to __init__.
@param xsize: The new width.
@type xsize: int
@param ysize: The new height.
@type ysize: int
"""
# Delete or append new rows # Delete or append new rows
del self._elements[ysize:] del self._elements[ysize:]
new_rows = ysize - len(self._elements) new_rows = ysize - len(self._elements)