Package enhanced_grid

Contains 2D and 3D Grid containers that supports extended slicing syntax. More...


Classes

class  RandomQueue
 A class that works just like a queue or a stack, except that a randomly selected element is returned. More...
class  PrincipleContainer
 Sub-classes of this container can be used directly. More...
class  AuxiliaryContainer
 Sub-classes of this container is used as windows by a PrincipleContainer, and should not be used directly! More...
class  Container
 Abstract super class of all grid-like containers. More...
class  Container1D
 Class that implements __str__ and __iter__. More...
class  Container2D
 Class that implements __str__ and __iter__. More...
class  Container3D
 Class that implements __str__ and __iter__. More...
class  GridWindow1D
class  Grid1D
 Class that represent a 2D grid, with enhanced slicing notation. More...
class  GridRow2D
class  GridCol2D
class  GridWindow2D
class  Grid2D
 Class that represent a 2D grid, with enhanced slicing notation. More...
class  GridBar3D
class  GridCol3D
class  GridRow3D
class  GridSliceXY
class  GridSliceXZ
class  GridSliceYZ
class  GridWindow3D
class  Grid3D
 Class that represent a 3D grid, with enhanced slicing notation. More...
class  ListGrid3D
class  ListGrid2D

Functions

def signum
 Class that represents a 2D array.
def int_point_2d
 Truncates a point to integer coordinates.
def int_point_3d
 Truncates a point to integer coordinates.
def points_to_grid
def points_to_grid_3d
 Converts a list of points to a 3D grid.
def make_grid_1d
def make_grid_2d
 Makes 2 list of lists.
def make_grid_3d
 Makes 2 list of lists.
def srange
 Returns an xrange that can be used to iterate over the slice of the container.
def is_slice
 Returns true if s is a slice or an Ellipsis.
def slice_len
 Returns the number of elements this slice will return, provided the provided primary is large enough.
def slice_mul
 Returns a slice that is equivalent to the two slices combined.
def complete_slice
 Completes this slice for a given length.
def __init__
def __getitem__
def __setitem__
def __init__
def __init__

Variables

 grid
 x
 y
 z


Detailed Description

Contains 2D and 3D Grid containers that supports extended slicing syntax.

These classes are provided for rapid prototyping, the methods defined on them might be slow.

 grid1 = Grid3D(10, 10, 10, 0)
 grid2 = Grid3D(10, 10, 10, 1)
 grid1[0, 0, 0] = grid2[0, 0, 0]
 grid1[0, 0, 2:6:2] = grid2[0, 0, 4:5]
 grid1[0, 0, ...] = grid2[0, 0, ...]
 grid1[0, ..., 0] = grid2[..., 0, 0]
 grid1[..., ..., ...] = grid2[..., ...., ....]

Slicing does not copy elements - an auxiliary window container is created that delegates further operations to the underlying container. Note that assignments to slices from the same object might not behave as espected. Parallel assignment also does not always work as expected. For example:

 grid[..., 0], grid[..., 1] = grid[..., 1], grid[..., 0]
does not correctly swop two rows, but the following does:
 grid[..., 0], grid[..., 1] = grid[..., 1].clone(), grid[..., 0].clone()
Strictly speaking, it is necessary only to clone the one object, but it is hard to remember which, so it is better to clone both (?).

Todo:
Implement a way to use copy containers instead of window containers


Function Documentation

def enhanced_grid::__getitem__ (   self,
  x 
)

Definition at line 783 of file enhanced_grid.py.

def enhanced_grid::__init__ (   self,
  grid,
  x,
  y,
  z 
)

Definition at line 976 of file enhanced_grid.py.

def enhanced_grid::__init__ (   self,
  grid,
  col_slice,
  row 
)

Definition at line 833 of file enhanced_grid.py.

def enhanced_grid.__init__ (   self,
  grid,
  col_slice 
)

Definition at line 778 of file enhanced_grid.py.

def enhanced_grid::__setitem__ (   self,
  x,
  item 
)

Definition at line 788 of file enhanced_grid.py.

def enhanced_grid.complete_slice (   s,
  length 
)

Completes this slice for a given length.

The resulting slice will give the same elements for a container of the given length, but none of the start, stop, or step attributes will be None. If s is the Ellipses, then the slice (0, length, 1) is returned.

Deprecated:

Definition at line 264 of file enhanced_grid.py.

def enhanced_grid.int_point_2d (   p  ) 

Truncates a point to integer coordinates.

Definition at line 102 of file enhanced_grid.py.

def enhanced_grid.int_point_3d (   p  ) 

Truncates a point to integer coordinates.

Definition at line 107 of file enhanced_grid.py.

def enhanced_grid.is_slice (   s  ) 

Returns true if s is a slice or an Ellipsis.

Definition at line 189 of file enhanced_grid.py.

def enhanced_grid.make_grid_1d (   width,
  initial_item = None 
)

Definition at line 135 of file enhanced_grid.py.

def enhanced_grid.make_grid_2d (   width,
  height,
  initial_item = None 
)

Makes 2 list of lists.

Definition at line 141 of file enhanced_grid.py.

def enhanced_grid.make_grid_3d (   width,
  height,
  depth,
  initial_item 
)

Makes 2 list of lists.

Definition at line 153 of file enhanced_grid.py.

def enhanced_grid.points_to_grid (   points,
  dimensions 
)

Definition at line 114 of file enhanced_grid.py.

def enhanced_grid.points_to_grid_3d (   points,
  dimensions 
)

Converts a list of points to a 3D grid.

Definition at line 127 of file enhanced_grid.py.

def enhanced_grid.signum (   x  ) 

Class that represents a 2D array.

The following convenient syntax is supported:

 p = 2, 3 # a coordinate in the grid
 grid[p] = 5
 print grid[p] 
 print grid[2, 3] 

Definition at line 93 of file enhanced_grid.py.

def enhanced_grid.slice_len (   s,
  length 
)

Returns the number of elements this slice will return, provided the provided primary is large enough.

Definition at line 194 of file enhanced_grid.py.

def enhanced_grid.slice_mul (   slice1,
  slice2,
  length 
)

Returns a slice that is equivalent to the two slices combined.

The following snippets are equivalent:

 list[s1][s2]

Definition at line 224 of file enhanced_grid.py.

def enhanced_grid.srange (   s,
  length 
)

Returns an xrange that can be used to iterate over the slice of the container.

The following snippets are equivalent

 s = slice(3, 18, 3)
 for i in srange(s):
        print list[i]

 for item in list[s]:
        print item

Definition at line 181 of file enhanced_grid.py.


Variable Documentation

Definition at line 779 of file enhanced_grid.py.

Definition at line 780 of file enhanced_grid.py.

Definition at line 836 of file enhanced_grid.py.

Definition at line 980 of file enhanced_grid.py.


Generated on Sun May 24 21:48:21 2009 by  doxygen 1.5.8