Changeset 3320

Show
Ignore:
Timestamp:
11/09/09 17:52:27 (4 months ago)
Author:
jvporter
Message:

* Eliminate unnecessary helpers.OffsetList?.OffsetProxy?
* (Partially) update documentation

Location:
python/trunk
Files:
2 added
6 modified

Legend:

Unmodified
Added
Removed
  • python/trunk/doc/helpers.rst

    r3309 r3320  
    66   :synopsis: Helper classes to simplify common operations. 
    77 
    8 AdjacencyList 
     8OffsetList 
    99============= 
    1010 
    11 .. class:: AdjacencyList(adj, offsets) 
     11.. class:: OffsetList(offsets[, kwargs]) 
    1212 
    13    .. attribute:: adj 
     13   Return a new OffsetList initialized from an array of offsets and a list of 
     14   data arrays specified as keyword arguments. An OffsetList is a  
     15   multi-dimensional jagged array. The data array is stored as a one-dimensional 
     16   array which is then indexed into with an array of offsets. 
    1417 
    15       A one-dimensional array of entities adjacent to the queried entities 
     18   Passing in a single data array creates an OffsetList that returns scalars 
     19   when indexing into it; passing in muliple data arrays creates an OffsetList 
     20   that returns dictionary objects. The supplied names for the data arrays can 
     21   be used to extract each individual data array. For example:: 
     22 
     23        o = OffsetList([0,3], x=[1,2,3], y=[4,5,6], z=[7,8,9]) 
     24        o[0]    # returns {'x': [1,2,3], 'y': [4,5,6], 'z': [7,8,9]} 
     25        o[0, 0] # returns {'x': 1, 'y': 4, 'z': 7} 
     26        o.x     # returns an OffsetList with only x as a data array 
     27 
     28   .. describe:: len(o) 
     29 
     30      Return the number of sub-arrays in the object `o`. Equivalent to 
     31      ``o.length()``. 
     32 
     33   .. describe:: o.x 
     34 
     35      For an OffsetList `o`, returns a new OffsetList with `x` as its lone data 
     36      array.       
     37 
     38   .. describe:: o[i] 
     39   .. describe:: o[i, j] 
     40 
     41      Return the array (or dictionary of arrays) for the `i`\ th element of 
     42      `o`. If `j` is specified, returns only the `j`\ th element of the 
     43      preceding array (or a dictionary of the `j`\ th elements). 
     44 
     45      .. note:: 
     46         If `o` has a single data array named `x`, this method is equivalent to 
     47         ``o.raw('x')[ o.offsets[i]:o.offsets[i+1] ]`` when 
     48         only `i` is specified, and is equivalent to 
     49         ``o.raw('x')[ o.offsets[i]+j ]`` when both `i` and `j` are specified. 
     50 
     51      :param i: Outer dimension of the list 
     52      :param j: Index into the `i`\ th array's sub-array 
     53      :return: If `o` has only one data array, then: 1) if `j` is specified, 
     54               a scalar, otherwise 2) an array. If `o` has multiple data 
     55               arrays, then 1) if `j` is specified, a dictionary of scalars, 
     56               otherwise 2) a dictionary of arrays. 
    1657 
    1758   .. attribute:: offsets 
    1859 
    19       An array of offsets into :attr:`adj` for each of the queried entities 
    20  
    21    .. method:: __getitem__(i[, j]) 
    22  
    23       Return the entities adjacent to the `i`\ th entity. If `j` is specified, 
    24       returns only the `j`\ th entity of the preceding array. As you would 
    25       expect, this is generally called as ``list[i, j]``. 
    26  
    27       .. note:: 
    28          This method is equivalent to ``adj[ offsets[i]:offsets[i+1] ]`` when 
    29          only `i` is specified, and is equivalent to ``adj[ offsets[i]+j ]`` 
    30          when both `i` and `j` are specified. 
    31  
    32       :param i: Index of the entity to query for adjacencies 
    33       :param j: Index into the `i`\ th entity's adjacency array 
    34       :return: If `j` is specified, a single entity. Otherwise, an array of 
    35                entities. 
     60      An array of offsets into the data for each of the queried entities 
    3661 
    3762   .. method:: length([i]) 
    3863 
    39       Return the number of entities whose adjacencies are stored in this object. 
    40       If `i` is specified, return the number of adjacencies for the `i`\ th 
    41       entity. 
     64      Return the number of sub-arrays that are stored in this object. 
     65      If `i` is specified, return the number of elements for the `i`\ th 
     66      sub-array. 
    4267 
    43       :param i: Index of the entity to query 
    44       :return: If `i` is ``None``, the number of entities whose adjacencies 
    45                are stored. Otherwise, the number of adjacencies for the 
    46                `i`\ th entity. 
     68      :param i: Index of the sub-array to query 
     69      :return: If `i` is ``None``, the number of sub-arrays stored in this 
     70               object. Otherwise, the number of elements for the `i`\ th 
     71               sub-array. 
     72 
     73   .. method:: raw(name) 
     74 
     75      Return the raw (one-dimensional) array for the data array given by `name`. 
    4776 
    4877 
  • python/trunk/doc/imesh.rst

    r3309 r3320  
    8484      If ``entities`` is a single entity handle, returns an array of adjacent 
    8585      entities. If ``entities`` is an array of entities, return an 
    86       :class:`~itaps.helpers.AdjacencyList` instance. 
     86      :class:`~itaps.helpers.OffsetList` instance with a data array named `adj`. 
    8787 
    8888      :param entities: Entity or array of entities being queried 
    8989      :param typeReq: Type of adjacent entities being requested 
    9090      :return: If ``entities`` is a single element, an array of adjacent 
    91                entities. Otherwise, an :class:`~itaps.helpers.AdjacencyList` 
    92                instance. 
     91               entities. Otherwise, an :class:`~itaps.helpers.OffsetList` 
     92               instance with a data array named `adj`. 
    9393 
    9494   .. method:: getEnt2ndAdj(entities, bridgeType, typeReq) 
     
    9999      single entity handle, returns an array of adjacent entities. If  
    100100      ``entities`` is an array of entities, return an 
    101       :class:`~itaps.helpers.AdjacencyList` instance. 
     101      :class:`~itaps.helpers.OffsetList` instance with a data array named `adj`. 
    102102 
    103103      :param entities: Entity or array of entities being queried 
     
    105105      :param typeReq: Type of adjacent entities being requested 
    106106      :return: If ``entities`` is a single element, an array of adjacent 
    107                entities. Otherwise, an :class:`~itaps.helpers.AdjacencyList` 
    108                instance. 
     107               entities. Otherwise, an :class:`~itaps.helpers.OffsetList` 
     108               instance with a data array named `adj`. 
    109109 
    110110   .. method:: createEntSet(isList) 
     
    212212      :return: Array of :class:`Tag`\ s associated with ``entities`` 
    213213 
    214 Forwards 
    215 -------- 
     214Forwarding 
     215---------- 
    216216 
    217217In addition to the methods listed above, :class:`Mesh` automatically forwards 
     
    237237      Return whether this entity set is ordered. 
    238238 
    239    .. method:: load(entSet, filename[, options]) 
     239   .. method:: load(filename[, options]) 
    240240 
    241241      Load a mesh from a file, adding it to this entity set. 
     
    273273      respectively. 
    274274 
    275       :param entSet: Entity set being queried 
    276275      :param type: Type of entities being requested 
    277276      :param topo: Topology of entities being requested 
    278       :return: Array of entity handles from ``entSet`` meeting the requirements 
    279                of ``type`` and ``topo``. 
     277      :return: Array of entity handles from this entity set meeting the 
     278               requirements of ``type`` and ``topo`` 
    280279 
    281280   .. method:: getAdjEntIndices(type, topo, adjType) 
  • python/trunk/doc/index.rst

    r3309 r3320  
    44 
    55PyTAPS is a Python package designed to interface with `ITAPS 
    6 <http://www.tstt-scidac.org/>`_, focusing on the iMesh interface. 
     6<http://www.tstt-scidac.org/>`_, focusing on support for the Fathom project 
     7(MOAB and CGM). 
    78 
    89.. toctree:: 
     
    1314   ibase 
    1415   imesh 
     16   igeom 
    1517   helpers 
  • python/trunk/doc/intro.rst

    r3309 r3320  
    4646called is determined by the type of the argument passed to ``add``. 
    4747 
    48 One notable exception to this rule is :meth:`itaps.iMesh.createEnt` and 
    49 :meth:`itaps.iMesh.createEntArr`, which have the same signatures and so cannot 
    50 be overloaded based on the types of the arguments. 
     48One notable exception to this rule is :meth:`itaps.iMesh.Mesh.createEnt` and 
     49:meth:`itaps.iMesh.Mesh.createEntArr`, which have the same signatures and so 
     50cannot be overloaded based on the types of the arguments. 
    5151 
    5252An Example 
  • python/trunk/pkg/helpers.py

    r3316 r3320  
    2525        if key not in self._data: 
    2626            raise AttributeError 
    27         return OffsetList.OffsetProxy(self, self._data[key]) 
     27        return OffsetList(self.offsets, **{key: self._data[key]}) 
    2828 
    2929    def raw(self, key): 
     
    3838    def __len__(self): 
    3939        return self.length() 
    40  
    41     class OffsetProxy: 
    42         def __init__(self, parent, data): 
    43             self.parent = parent 
    44             self.data = data 
    45  
    46         def __getitem__(self, key): 
    47             return self.parent._get_one(self.data, key) 
    48  
    49         def length(self, i = None): 
    50             return self.parent.length(i) 
    51  
    52         def __len__(self): 
    53             return len(self.parent) 
    5440 
    5541 
  • python/trunk/test/__init__.py

    r3309 r3320  
    1 __all__ = ['igeom', 'imesh'] 
     1__all__ = ['ibase', 'igeom', 'imesh']