Changeset 3320
- Timestamp:
- 11/09/09 17:52:27 (4 months ago)
- Location:
- python/trunk
- Files:
-
- 2 added
- 6 modified
-
doc/helpers.rst (modified) (1 diff)
-
doc/igeom.rst (added)
-
doc/imesh.rst (modified) (6 diffs)
-
doc/index.rst (modified) (2 diffs)
-
doc/intro.rst (modified) (1 diff)
-
pkg/helpers.py (modified) (2 diffs)
-
test/__init__.py (modified) (1 diff)
-
test/ibase/__init__.py (added)
Legend:
- Unmodified
- Added
- Removed
-
python/trunk/doc/helpers.rst
r3309 r3320 6 6 :synopsis: Helper classes to simplify common operations. 7 7 8 AdjacencyList8 OffsetList 9 9 ============= 10 10 11 .. class:: AdjacencyList(adj, offsets)11 .. class:: OffsetList(offsets[, kwargs]) 12 12 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. 14 17 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. 16 57 17 58 .. attribute:: offsets 18 59 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 36 61 37 62 .. method:: length([i]) 38 63 39 Return the number of entities whose adjacenciesare stored in this object.40 If `i` is specified, return the number of adjacencies for the `i`\ th41 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. 42 67 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`. 47 76 48 77 -
python/trunk/doc/imesh.rst
r3309 r3320 84 84 If ``entities`` is a single entity handle, returns an array of adjacent 85 85 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`. 87 87 88 88 :param entities: Entity or array of entities being queried 89 89 :param typeReq: Type of adjacent entities being requested 90 90 :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`. 93 93 94 94 .. method:: getEnt2ndAdj(entities, bridgeType, typeReq) … … 99 99 single entity handle, returns an array of adjacent entities. If 100 100 ``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`. 102 102 103 103 :param entities: Entity or array of entities being queried … … 105 105 :param typeReq: Type of adjacent entities being requested 106 106 :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`. 109 109 110 110 .. method:: createEntSet(isList) … … 212 212 :return: Array of :class:`Tag`\ s associated with ``entities`` 213 213 214 Forward s215 -------- 214 Forwarding 215 ---------- 216 216 217 217 In addition to the methods listed above, :class:`Mesh` automatically forwards … … 237 237 Return whether this entity set is ordered. 238 238 239 .. method:: load( entSet,filename[, options])239 .. method:: load(filename[, options]) 240 240 241 241 Load a mesh from a file, adding it to this entity set. … … 273 273 respectively. 274 274 275 :param entSet: Entity set being queried276 275 :param type: Type of entities being requested 277 276 :param topo: Topology of entities being requested 278 :return: Array of entity handles from ``entSet`` meeting the requirements279 of ``type`` and ``topo``.277 :return: Array of entity handles from this entity set meeting the 278 requirements of ``type`` and ``topo`` 280 279 281 280 .. method:: getAdjEntIndices(type, topo, adjType) -
python/trunk/doc/index.rst
r3309 r3320 4 4 5 5 PyTAPS 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). 7 8 8 9 .. toctree:: … … 13 14 ibase 14 15 imesh 16 igeom 15 17 helpers -
python/trunk/doc/intro.rst
r3309 r3320 46 46 called is determined by the type of the argument passed to ``add``. 47 47 48 One notable exception to this rule is :meth:`itaps.iMesh. createEnt` and49 :meth:`itaps.iMesh. createEntArr`, which have the same signatures and so cannot50 be overloaded based on the types of the arguments.48 One 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 50 cannot be overloaded based on the types of the arguments. 51 51 52 52 An Example -
python/trunk/pkg/helpers.py
r3316 r3320 25 25 if key not in self._data: 26 26 raise AttributeError 27 return OffsetList .OffsetProxy(self, self._data[key])27 return OffsetList(self.offsets, **{key: self._data[key]}) 28 28 29 29 def raw(self, key): … … 38 38 def __len__(self): 39 39 return self.length() 40 41 class OffsetProxy:42 def __init__(self, parent, data):43 self.parent = parent44 self.data = data45 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)54 40 55 41 -
python/trunk/test/__init__.py
r3309 r3320 1 __all__ = ['i geom', 'imesh']1 __all__ = ['ibase', 'igeom', 'imesh']
![(please configure the [header_logo] section in trac.ini)](/projects/ITAPS/chrome/common/trac_banner.png)