Package paramz :: Package core :: Module observable_array :: Class ObsAr
[hide private]
[frames] | no frames]

Class ObsAr

source code


An ndarray which reports changes to its observers.

.. warning:

  ObsAr tries to not ever give back an observable array itself. Thus,
  if you want to preserve an ObsAr you need to work in memory. Let
  `a` be an ObsAr and you want to add a random number `r` to it. You need to
  make sure it stays an ObsAr by working in memory (see numpy for details):

  .. code-block:: python

      a[:] += r

The observers can add themselves with a callable, which will be called every time this array changes. The callable takes exactly one argument, which is this array itself.

Instance Methods [hide private]
 
__array_finalize__(self, obj)
None.
source code
Object of same type as ndarray object a.
__array_wrap__(self, out_arr, context=None) source code
 
_setup_observers(self) source code
 
copy(self)
Make a copy.
source code
Deep copy of array
__deepcopy__(self, memo)
Used if copy.deepcopy is called on an array.
source code
 
__reduce__(self)
For pickling.
source code
 
__setstate__(self, state)
For unpickling.
source code
 
__setitem__(self, s, val)
x[i]=y
source code
 
__getslice__(self, start, stop)
x[i:j]
source code
 
__setslice__(self, start, stop, val)
x[i:j]=y
source code
 
__ilshift__(self, *args, **kwargs)
x<<=y
source code
 
__irshift__(self, *args, **kwargs)
x>>=y
source code
 
__ixor__(self, *args, **kwargs)
x^=y
source code
 
__ipow__(self, *args, **kwargs)
x**=y
source code
 
__ifloordiv__(self, *args, **kwargs)
x//=y
source code
 
__isub__(self, *args, **kwargs)
x-=y
source code
 
__ior__(self, *args, **kwargs)
x|=y
source code
 
__itruediv__(self, *args, **kwargs)
x/=y
source code
 
__idiv__(self, *args, **kwargs)
x/=y
source code
 
__iand__(self, *args, **kwargs)
x&=y
source code
 
__imod__(self, *args, **kwargs)
x%=y
source code
 
__iadd__(self, *args, **kwargs)
x+=y
source code
 
__imul__(self, *args, **kwargs)
x*=y
source code

Inherited from numpy.ndarray: __abs__, __add__, __and__, __array__, __array_prepare__, __complex__, __contains__, __copy__, __delitem__, __delslice__, __div__, __divmod__, __eq__, __float__, __floordiv__, __ge__, __getitem__, __gt__, __hex__, __index__, __int__, __invert__, __iter__, __le__, __len__, __long__, __lshift__, __lt__, __mod__, __mul__, __ne__, __neg__, __nonzero__, __oct__, __or__, __pos__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __repr__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __sizeof__, __str__, __sub__, __truediv__, __xor__, all, any, argmax, argmin, argpartition, argsort, astype, byteswap, choose, clip, compress, conj, conjugate, cumprod, cumsum, diagonal, dot, dump, dumps, fill, flatten, getfield, item, itemset, max, mean, min, newbyteorder, nonzero, partition, prod, ptp, put, ravel, repeat, reshape, resize, round, searchsorted, setfield, setflags, sort, squeeze, std, sum, swapaxes, take, tobytes, tofile, tolist, tostring, trace, transpose, var, view

Inherited from pickleable.Pickleable: __getstate__, __init__, pickle

Inherited from observable.Observable: add_observer, change_priority, notify_observers, remove_observer, set_updates

Inherited from object: __delattr__, __format__, __getattribute__, __reduce_ex__, __setattr__, __subclasshook__

Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, input_array, *a, **kw) source code
Class Variables [hide private]
  __array_priority__ = -1
Array priority.

Inherited from numpy.ndarray: __hash__

Properties [hide private]
  values
Return the ObsAr underlying array as a standard ndarray.

Inherited from numpy.ndarray: T, __array_interface__, __array_struct__, base, ctypes, data, dtype, flags, flat, imag, itemsize, nbytes, ndim, real, shape, size, strides

Inherited from object: __class__

Method Details [hide private]

__new__(cls, input_array, *a, **kw)
Static Method

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

__array_finalize__(self, obj)

source code 

None.

Overrides: __array_finalize__
(inherited documentation)

__array_wrap__(self, out_arr, context=None)

source code 
Returns: Object of same type as ndarray object a.
Overrides: numpy.ndarray.__array_wrap__
(inherited documentation)

copy(self)

source code 

Make a copy. This means, we delete all observers and return a copy of this array. It will still be an ObsAr!

Overrides: pickleable.Pickleable.copy

__deepcopy__(self, memo)

source code 

Used if copy.deepcopy is called on an array.

Returns: Deep copy of array
Overrides: pickleable.Pickleable.__deepcopy__

__reduce__(self)

source code 

For pickling.

Overrides: object.__reduce__
(inherited documentation)

__setstate__(self, state)

source code 
For unpickling.

Parameters
----------
version : int
    optional pickle version. If omitted defaults to 0.
shape : tuple
dtype : data-type
isFortran : bool
rawdata : string or list
    a binary string with the data (or a list if 'a' is an object array)

Overrides: pickleable.Pickleable.__setstate__

__setitem__(self, s, val)
(Index assignment operator)

source code 

x[i]=y

Overrides: numpy.ndarray.__setitem__
(inherited documentation)

__getslice__(self, start, stop)
(Slicling operator)

source code 

x[i:j]

Use of negative indices is not supported.

Overrides: numpy.ndarray.__getslice__
(inherited documentation)

__setslice__(self, start, stop, val)
(Slice assignment operator)

source code 

x[i:j]=y

Use of negative indices is not supported.

Overrides: numpy.ndarray.__setslice__
(inherited documentation)

__ilshift__(self, *args, **kwargs)

source code 

x<<=y

Overrides: numpy.ndarray.__ilshift__
(inherited documentation)

__irshift__(self, *args, **kwargs)

source code 

x>>=y

Overrides: numpy.ndarray.__irshift__
(inherited documentation)

__ixor__(self, *args, **kwargs)

source code 

x^=y

Overrides: numpy.ndarray.__ixor__
(inherited documentation)

__ipow__(self, *args, **kwargs)

source code 

x**=y

Overrides: numpy.ndarray.__ipow__
(inherited documentation)

__ifloordiv__(self, *args, **kwargs)

source code 

x//=y

Overrides: numpy.ndarray.__ifloordiv__
(inherited documentation)

__isub__(self, *args, **kwargs)

source code 

x-=y

Overrides: numpy.ndarray.__isub__
(inherited documentation)

__ior__(self, *args, **kwargs)

source code 

x|=y

Overrides: numpy.ndarray.__ior__
(inherited documentation)

__itruediv__(self, *args, **kwargs)

source code 

x/=y

Overrides: numpy.ndarray.__itruediv__
(inherited documentation)

__idiv__(self, *args, **kwargs)

source code 

x/=y

Overrides: numpy.ndarray.__idiv__
(inherited documentation)

__iand__(self, *args, **kwargs)

source code 

x&=y

Overrides: numpy.ndarray.__iand__
(inherited documentation)

__imod__(self, *args, **kwargs)

source code 

x%=y

Overrides: numpy.ndarray.__imod__
(inherited documentation)

__iadd__(self, *args, **kwargs)

source code 

x+=y

Overrides: numpy.ndarray.__iadd__
(inherited documentation)

__imul__(self, *args, **kwargs)

source code 

x*=y

Overrides: numpy.ndarray.__imul__
(inherited documentation)

Property Details [hide private]

values

Return the ObsAr underlying array as a standard ndarray.

Get Method:
unreachable.values(self) - Return the ObsAr underlying array as a standard ndarray.