An OffsetList() is a multi-dimensional jagged array. The data array is stored as a one-dimensional array which is then indexed into with an array of offsets.
For example:
>>> point = namedtuple('point', 'x y z')
>>> o = OffsetList([0,2,4], point([1,2,3,4], [5,6,7,8], [9,0,1,2]))
>>> o
<itaps.helpers.OffsetListTuple object at 0x7f3d9922b110>
>>> o[0]
point(x=[1, 2], y=[5, 6], z=[9, 0])
>>> o[0,1]
point(x=2, y=6, z=0)
>>> o.x
<itaps.helpers.OffsetListSingle object at 0x7f3d9922b7d0>
If data is a tuple, return a new OffsetListTuple instance with the specified offsets and data. Otherwise, return a new OffsetListSingle instance.
Return a new OffsetListSingle with the specified offsets and data.
Return the number of sub-arrays in the object o. Equivalent to o.length().
Return : | The number of sub-arrays |
---|
Return the ith sub-array of o. Equivalent to o.data[ o.offsets[i]:o.offsets[i+1] ].
Param i: | Outer dimension of the list |
---|---|
Return : | The ith sub-array |
Return the element in the jth position of the ith sub-array of o. Equivalent to o.data[ o.offsets[i]+j ].
Param i: | Outer dimension of the list |
---|---|
Param j: | Index into the ith array’s sub-array |
Return : | The jth element of the ith sub-array |
Return the raw offset array.
Return the raw data array.
Return the number of sub-arrays that are stored in this object. If i is specified, return the number of elements for the ith sub-array.
Parameters: |
|
---|---|
Returns: | If i is None, the number of sub-arrays stored in this object. Otherwise, the number of elements for the ith sub-array. |
Return a new OffsetListTuple with the specified offsets and data. This is a subclass of OffsetListSingle. In addition to the methods defined in OffsetListSingle, OffsetListTuple provides the following methods.
Return a new OffsetListSingle with the same offsets as o and data equal to o.data.x. Equivalent to o.slice('x'). Requires Python 2.6+.
Return : | A new OffsetListSingle |
---|
Return the fields of the namedtuple used by this instance. Requires Python 2.6+.
Return a new OffsetListSingle derived from this instance. If field is an integer, set the OffsetListSingle‘s data to data[field]. Otherwise, set the data to getattr(data, field). Using non-integer values requires Python 2.6+.
Returns: | A new OffsetListSingle |
---|
These methods work as in an OffsetListSingle, but return a tuple (or namedtuple in Python 2.6+) of the requested data.
An IndexedList is a multi-dimensional jagged array. The data array is stored as a one-dimensional array which is then indexed into with an array of offsets and an array of indices.
For example:
>>> import numpy
>>> o = IndexedList(numpy.array([0, 3, 6]),
... numpy.array([0, 1, 2,
... 1, 2, 3,
... 2, 3, 4]),
... numpy.array([10, 11, 12, 13, 14]))
>>> o[0]
array([10, 11, 12])
>>> o[0, 1]
11
>>> o.indices[0]
array([0, 1, 2])
Return a new IndexedList with the specified offsets, indices, and data.
Return the number of entities in the object o. Equivalent to o.length().
Return the ith sub-array of o. Equivalent to o.data[ o.indices[i] ].
Param i: | Outer dimension of the list |
---|---|
Return : | The ith sub-array |
Note
This method relies on the special indexing features of NumPy, namely indexing an array with another array.
Return the element in the jth position of the ith sub-array of o. Equivalent to o.data[ o.indices[i, j] ].
Param i: | Outer dimension of the list |
---|---|
Param j: | Index into the ith array’s sub-array |
Return : | The jth element of the ith sub-array |
Return the offsets and indices as an OffsetListSingle instance.
Return the raw data array.
Return the number of entities whose adjacencies are stored in this object. If i is specified, return the number of adjacencies for the ith entity.
Parameters: |
|
---|---|
Returns: | If i is None, the number of entities whose adjacencies are stored. Otherwise, the number of adjacencies for the ith entity. |