PyTAPS Helpers

OffsetList

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>
itaps.helpers.OffsetList(offsets, data)

If data is a tuple, return a new OffsetListTuple instance with the specified offsets and data. Otherwise, return a new OffsetListSingle instance.

class itaps.helpers.OffsetListSingle(offsets, data)

Return a new OffsetListSingle with the specified offsets and data.

len(o)

Return the number of sub-arrays in the object o. Equivalent to o.length().

Return :The number of sub-arrays
o[i]

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
o[i, j]

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
offsets

Return the raw offset array.

data

Return the raw data array.

length([i])

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:
  • i – Index of the sub-array to query
Returns:

If i is None, the number of sub-arrays stored in this object. Otherwise, the number of elements for the ith sub-array.

class itaps.helpers.OffsetListTuple(offsets, data)

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.

o.x

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
fields

Return the fields of the namedtuple used by this instance. Requires Python 2.6+.

slice(field)

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
o[i]
o[i, j]

These methods work as in an OffsetListSingle, but return a tuple (or namedtuple in Python 2.6+) of the requested data.

IndexedList

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])
class itaps.helpers.IndexedList(offsets, indices, data)

Return a new IndexedList with the specified offsets, indices, and data.

len(o)

Return the number of entities in the object o. Equivalent to o.length().

o[i]

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.

o[i, j]

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
indices

Return the offsets and indices as an OffsetListSingle instance.

data

Return the raw data array.

length([i])

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:
  • i – Index of the entity to query
Returns:

If i is None, the number of entities whose adjacencies are stored. Otherwise, the number of adjacencies for the ith entity.

Table Of Contents

Previous topic

iRel Interface

Next topic

C API

This Page