Package PyDSTool :: Module MProject :: Class context
[hide private]
[frames] | no frames]

Class context

source code

object --+
         |
        context

A collection of related model interfaces that apply to a model. interface_pairs are a list of ModelInterface instance (test) and class (ref) pairs, the latter to be instantiated on a model.

Set the debug_mode attribute at any time, or as the optional argument at initializiation, to ensure that any exceptions that arise from interacting model interfaces and their features are fully passed back to the caller of the context containing them.

Instance Methods [hide private]
 
__init__(self, interface_pairs, debug_mode=False)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
reset_weights(self, old_weights=None)
Reset weights to unity, unless old_weights array is given, in which case reset to that.
source code
 
set_single_feat_weights(self, feat, weight=1)
Set weights for a single feature given as an (interface, feature) pair, setting all others to zero.
source code
 
set_weights(self, weight_dict)
Update weights with a dictionary keyed by test_mi, whose values are either: (1) dicts of feature -> scalar weight.
source code
 
show_res_info(self, resvec)
Show detail of feature -> residual mapping for a given residual vector.
source code
 
_map_to_features(self, x)
Utility to map 1D array x onto the model interface's features with non-zero weights, returning a dictionary.
source code
 
evaluate(self, model)
Evaluate whole context on a model instance, returning a single Boolean.
source code
 
residual(self, model, include_raw=False)
Evaluate whole context on a model instance, returning an array of residual error between quantitative features in the model trajectory and their target values.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, interface_pairs, debug_mode=False)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

set_weights(self, weight_dict)

source code 
Update weights with a dictionary keyed by test_mi, whose values are
either:
 (1) dicts of feature -> scalar weight.
 (2) a scalar which will apply to all features of that model interface
Features and model interfaces must correspond to those declared for the
context.

_map_to_features(self, x)

source code 

Utility to map 1D array x onto the model interface's features with non-zero weights, returning a dictionary.

x is assumed to have correct length.

residual(self, model, include_raw=False)

source code 

Evaluate whole context on a model instance, returning an array of residual error between quantitative features in the model trajectory and their target values.

Residual array will be weighted if one was set. Any weights set to zero will cause those features to *not appear* in the residual.

Provide include_raw=True argument to also return the raw, unweighted residual. (Mainly for internal use.)