Package numarray :: Module generic :: Class NDArray
[show private | hide private]
[frames | no frames]

Type NDArray

object --+    
         |    
  _ndarray --+
             |
            NDArray

Known Subclasses:
RecArray

Multi-dimensional array abstract base class

This class defines the structural operations common to numarray.
Subclasses must provide the semantical interpretation of elements,
including the __str__, __repr__, _getitem, and _setitem methods.

Given an array index of arr[k,j,i] it is always true that the
byte offset of the element in the array is computed thusly:

with shape[0] --> dimension of current view
     strides[0] --> bytestride for k index dimension

element_byte_offset = byteoffset +
           ( i*strides[2] + j*strides[1] + k*strides[0])

where 0 <= i < shape[2],
      0 <= j < shape[1],
      0 <= k < shape[0]

For contiguous numarray strides[i] = shape[i+1]*strides[i+1]

Summary of attribute meanings:

_data           buffer with data for the array
_shape          dimensions of the array
_byteoffset     The byte offset of the first element from the beginning
                of the buffer
_bytestride     The separation between items in bytes.
_itemsize       The size of items in bytes

Method Summary
  __copy__(self)
support for copy.copy()
  __deepcopy__(self, memo)
support for copy.deepcopy()
  __getstate__(self)
returns state of NDArray for pickling.
  __nonzero__(self)
  __reduce__(self)
__reduce__ returns the pickling "reduction tuple" for an NDArray.
  __repr__(self)
  __setstate__(self, state)
restores state of NDArray after unpickling.
  __str__(self)
  astype(self, type)
  copy(self)
Return a new array with the same shape and type, but a copy of the data
  factory(self, *args, **keys)
factory(...) calls the array(...) factory function defined in the source module where the class of 'self' was defined.
  getflat(self)
  getrank(self)
  getshape(self)
  info(self)
info() prints out the key attributes of an array.
  is_c_array(self)
is_c_array() returns 1 iff the array is aligned and contiguous, and returns 0 otherwise.
  itemsize(self)
Size (in bytes) of an array element
  nonzero(self)
  put(self, *indices, **keywords)
  ravel(self)
ravel(self) setshapes 'self' into an equivalent 1D array.
  repeat(self, repeats, axis)
repeat() returns a new array with each element 'a[i]' repeated 'r[i]' times.
  resize(self, shape, *args)
resize() shrinks/grows 'self' to new 'shape', possibly replacing the underlying buffer object.
  setflat(self, flat)
  setshape(self, shape, *args)
Change array shape in place.
  take(self, *indices, **keywords)
  tofile(self, file)
Write the array as a binary image to a file.
  tostring(self)
Return a string with a binary copy of the array
  transpose(self, axes)
transpose() re-shapes the array by permuting it's dimensions as specified by 'axes'.
  _arrayIndexing(self, key, value)
  _broadcast(self, arr)
Return broadcast view of arr, else return None.
  _clone(self, shape)
  _copyFrom(self, arr)
Copy elements from another array.
  _dualbroadcast(self, arr)
Return broadcast views both self and arr, else return (None,None).
  _fix_pt_indices(self, indices)
  _isSlice(self, key)
  _put(self, indices, values, **keywds)
  _stridesFromShape(self)
Compute the strides from shape for a contiguous array
  _take(self, indices, **keywds)
  _tofileByBlocks(self, file, dims, indexlevel, blockingparameters)
Write the array to a file repeatedly in blocks
    Inherited from _ndarray
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __delitem__(x, y)
x.__delitem__(y) <==> del x[y]
  __getitem__(x, y)
x.__getitem__(y) <==> x[y]
  __len__(x)
x.__len__() <==> len(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __setitem__(x, i, y)
x.__setitem__(i, y) <==> x[i]=y
byte offset of indices within array _getByteOffset(indices)
_getByteOffset(indices) -> byte offset of indices within array
None _putter(axis1, axis2)
_putter(axis1, axis2) -> None
  _simpleIndexing(...)
_simpleIndexing(key, value=None) gets or sets for integer sequence key
None _taker(axis1, axis2)
_taker(axis1, axis2) -> None
  _universalIndexing(...)
_universalIndexing(key, value=None) gets(value=None) or sets(value!=None) at key
1 if array is fortran-contiguous, 0 otherwise. is_fortran_contiguous()
is_fortran_contiguous() -> 1 if array is fortran-contiguous, 0 otherwise.
1 if array is aligned, 0 otherwise. isaligned()
isaligned() -> 1 if array is aligned, 0 otherwise.
1 if array is contiguous, 0 otherwise. iscontiguous()
iscontiguous() -> 1 if array is contiguous, 0 otherwise.
total number of elements in array. nelements()
nelements() -> total number of elements in array.
total number of elements in array. size()
nelements() -> total number of elements in array.
None swapaxes(axis1, axis2)
swapaxes(axis1, axis2) -> None
array converted to nested list of scalars. tolist()
tolist() -> array converted to nested list of scalars.
new array object referring to same data buffer view()
view() -> new array object referring to same data buffer
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Property Summary
  flat: access to array as 1D
  shape: tuple of array dimensions

Class Variable Summary
    Inherited from _ndarray
getset_descriptor _aligned = <attribute '_aligned' of '_ndarray._ndarray' ...
getset_descriptor _byteoffset = <attribute '_byteoffset' of '_ndarray._nda...
getset_descriptor _bytestride = <attribute '_bytestride' of '_ndarray._nda...
getset_descriptor _contiguous = <attribute '_contiguous' of '_ndarray._nda...
getset_descriptor _data = <attribute '_data' of '_ndarray._ndarray' object...
getset_descriptor _itemsize = <attribute '_itemsize' of '_ndarray._ndarray...
getset_descriptor _shape = <attribute '_shape' of '_ndarray._ndarray' obje...
getset_descriptor _strides = <attribute '_strides' of '_ndarray._ndarray' ...
getset_descriptor flags = <attribute 'flags' of '_ndarray._ndarray' object...
getset_descriptor rank = <attribute 'rank' of '_ndarray._ndarray' objects>

Method Details

__copy__(self)

support for copy.copy()

__deepcopy__(self, memo)

support for copy.deepcopy()

__getstate__(self)

returns state of NDArray for pickling.

__reduce__(self)

__reduce__ returns the pickling "reduction tuple" for an NDArray. Used for NDArray derived from C basetypes, not classic classes.
Overrides:
__builtin__.object.__reduce__

__setstate__(self, state)

restores state of NDArray after unpickling.

copy(self)

Return a new array with the same shape and type, but a copy of the data

factory(self, *args, **keys)

factory(...) calls the array(...) factory function defined in the source module where the class of 'self' was defined.

info(self)

info() prints out the key attributes of an array.

is_c_array(self)

is_c_array() returns 1 iff the array is aligned and contiguous, and returns 0 otherwise.

itemsize(self)

Size (in bytes) of an array element

ravel(self)

ravel(self) setshapes 'self' into an equivalent 1D array.

repeat(self, repeats, axis=0)

repeat() returns a new array with each element 'a[i]' repeated 'r[i]' times.

resize(self, shape, *args)

resize() shrinks/grows 'self' to new 'shape', possibly replacing the underlying buffer object.

setshape(self, shape, *args)

Change array shape in place. Call as setshape(i,j,k) or setshape((i,j,k)).

tofile(self, file)

Write the array as a binary image to a file.

If file is a string, it attempts to open a file with that name, otherwise it assumes file is a file object. At the moment if special positioning is needed in the file one must do that with the file object beforehand. More options may be added to this method to allow positioning or appends.

Note that for numerical data, the system byte order in which the data is represented is *not* recorded in the file. This renders the file non-portable because extra information is required to interpret it on different machines than the one it was created on.

tostring(self)

Return a string with a binary copy of the array

Copies are always contiguous, but no conversions are implied

transpose(self, axes=None)

transpose() re-shapes the array by permuting it's dimensions as specified by 'axes'. If 'axes' is none, transpose returns the array with it's dimensions reversed.

_broadcast(self, arr)

Return broadcast view of arr, else return None.

_copyFrom(self, arr)

Copy elements from another array.

This is the generic version. Subclasses (such as numarray) may override this method

_dualbroadcast(self, arr)

Return broadcast views both self and arr, else return (None,None).

_stridesFromShape(self)

Compute the strides from shape for a contiguous array

_tofileByBlocks(self, file, dims, indexlevel, blockingparameters)

Write the array to a file repeatedly in blocks

This is done similarly to ufunc._doOverDimensions

Property Details

flat

access to array as 1D
Get Method:
getflat(self)
Set Method:
setflat(self, flat)

shape

tuple of array dimensions
Get Method:
getshape(self)
Set Method:
setshape(self, shape, *args)

Generated by Epydoc 2.1 on Thu Apr 21 13:11:50 2005 http://epydoc.sf.net