Package paramz :: Package core :: Module index_operations :: Class ParameterIndexOperations
[hide private]
[frames] | no frames]

Class ParameterIndexOperations

source code


This object wraps a dictionary, whos keys are _operations_ that we'd like to apply to a parameter array, and whose values are np integer arrays which index the parameter array appropriately.

A model instance will contain one instance of this class for each thing that needs indexing (i.e. constraints, ties and priors). Parameters within the model constain instances of the ParameterIndexOperationsView class, which can map from a 'local' index (starting 0) to this global index.

Here's an illustration:

   #=======================================================================
   model : 0 1 2 3 4 5 6 7 8 9
   key1: 4 5
   key2: 7 8

   param1: 0 1 2 3 4 5
   key1: 2 3
   key2: 5

   param2: 0 1 2 3 4
   key1: 0
   key2: 2 3
   #=======================================================================

The views of this global index have a subset of the keys in this global (model) index.

Adding a new key (e.g. a constraint) to a view will cause the view to pass the new key to the global index, along with the local index and an offset. This global index then stores the key and the appropriate global index (which can be seen by the view).

See also: ParameterIndexOperationsView

Instance Methods [hide private]
 
__init__(self, constraints=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
items(self) source code
 
properties(self) source code
 
indices(self) source code
 
shift_right(self, start, size) source code
 
shift_left(self, start, size) source code
 
clear(self) source code
 
properties_for(self, index)
Returns a list of properties, such that each entry in the list corresponds to the element of the index given.
source code
 
properties_dict_for(self, index)
Return a dictionary, containing properties as keys and indices as index Thus, the indices for each constraint, which is contained will be collected as one dictionary
source code
 
add(self, prop, indices) source code
 
remove(self, prop, indices) source code
 
update(self, parameter_index_view, offset=0) source code
 
copy(self) source code
 
__deepcopy__(self, memo) source code
 
__getitem__(self, prop) source code
 
__delitem__(self, prop) source code
 
__str__(self, *args, **kwargs)
str(x)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
  _offset = 0
Properties [hide private]
  size

Inherited from object: __class__

Method Details [hide private]

__init__(self, constraints=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

properties_for(self, index)

source code 

Returns a list of properties, such that each entry in the list corresponds to the element of the index given.

Example: let properties: 'one':[1,2,3,4], 'two':[3,5,6]

>>> properties_for([2,3,5])
[['one'], ['one', 'two'], ['two']]

properties_dict_for(self, index)

source code 

Return a dictionary, containing properties as keys and indices as index Thus, the indices for each constraint, which is contained will be collected as one dictionary

Example: let properties: 'one':[1,2,3,4], 'two':[3,5,6]

>>> properties_dict_for([2,3,5])
{'one':[2,3], 'two':[3,5]}

__str__(self, *args, **kwargs)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Property Details [hide private]

size

Get Method:
unreachable.size(self)