sfc :: common :: ParameterDict :: ParameterDict :: Class ParameterDict
[hide private]
[frames] | no frames]

Class ParameterDict

source code


A dictionary with attribute-style access,
that maps attribute access to the real dictionary.

Interactive example:
>>> m = ParameterDict(Re = 1.0, f = "sin(x)")
>>> print m
Re = 1.0
f = 'sin(x)'
>>> s = ParameterDict(max_iterations = 10, tolerance = 1e-8)
>>> print s
max_iterations = 10
tolerance = 1e-08
>>> p = ParameterDict(model = m, solver = s)
>>> print p
model = {
    Re = 1.0
    f = 'sin(x)'
}
solver = {
    max_iterations = 10
    tolerance = 1e-08
}
>>> q = p.copy()
>>> q.model.Re = 2.3e6
>>> q.solver.max_iterations = 100
>>> print q
model = {
    Re = 2300000.0
    f = 'sin(x)'
}
solver = {
    max_iterations = 100
    tolerance = 1e-08
}
>>> print p
model = {
    Re = 1.0
    f = 'sin(x)'
}
solver = {
    max_iterations = 10
    tolerance = 1e-08
}
>>> p.update(q)
>>> print p
model = {
    Re = 2300000.0
    f = 'sin(x)'
}
solver = {
    max_iterations = 100
    tolerance = 1e-08
}
>>> s.nothere = 123
Traceback (most recent call last):
  File "doctest.py", line 1212, in __run
    compileflags, 1) in test.globs
  File "<doctest __main__.ParameterDict[13]>", line 1, in <module>
    s.nothere = 123
  File "ParameterDict.py", line 107, in __setattr__
    raise AttributeError("%s is not an item in this parameter dict." % key)
AttributeError: nothere is not an item in this parameter dict.

Instance Methods [hide private]
new empty dictionary

__init__(self, **params)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__getstate__(self) source code
 
__setstate__(self, items) source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
__delitem__(self, key)
del x[y]
source code
 
__setattr__(self, key, value)
x.__setattr__('name', value) <==> x.name = value
source code
 
__getattr__(self, key) source code
 
format(self, indent=None)
Make a recursive indented pretty-print string of self and parameter subsets.
source code
a shallow copy of D
copy(self)
Make a copy of self, including recursive copying of parameter subsets.
source code
None
update(self, other)
A recursive update that handles parameter subsets correctly unlike dict.update.
source code

Inherited from dict: __cmp__, __contains__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __setitem__, __sizeof__, clear, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, values, viewitems, viewkeys, viewvalues

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __subclasshook__

Class Variables [hide private]

Inherited from dict: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **params)
(Constructor)

source code 

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

Returns:
new empty dictionary

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__delitem__(self, key)
(Index deletion operator)

source code 

del x[y]

Overrides: dict.__delitem__
(inherited documentation)

__setattr__(self, key, value)

source code 

x.__setattr__('name', value) <==> x.name = value

Overrides: object.__setattr__
(inherited documentation)

copy(self)

source code 

Make a copy of self, including recursive copying of parameter subsets. Parameter values themselves are not copied.

Returns: a shallow copy of D
Overrides: dict.copy

update(self, other)

source code 

A recursive update that handles parameter subsets correctly unlike dict.update.

Returns: None
Overrides: dict.update