- class ModelsDict(*args, **kwargs)¶
This subclassed dictionary is assigned to the
modelsattribute of all objects that inherit from the
ModelsMixinclass. Each dictionary entry corresponds to an entry in the target object’s dictionary, and contains the models and associated parameters for generating the model.
The main features of this subclass are three methods the help resolve the order in which models should be called:
Returns a NetworkX graph object of the dependencies
deep (bool, optional) – Defines whether intra- or inter-object dependency graph is desired. Default is False, i.e. only returns dependencies within the object.
To visualize the dependencies, the following NetworkX function and settings is helpful:
>>> import openpnm as op >>> net = op.network.Cubic(shape=[3, 3, 3]) >>> geo = op.geometry.StickAndBall(network=net, ... pores=net.Ps, ... throats=net.Ts) >>> dtree = geo.models.dependency_graph() >>> import networkx as nx >>> nx.draw_spectral(dtree, ... arrowsize=50, ... font_size=32, ... with_labels=True, ... node_size=2000, ... width=3.0, ... edge_color='lightgrey', ... font_weight='bold')
Returns a list of dependencies in the order with which they should be called to ensure data is calculated by one model before it’s asked for by another.
This raises an exception if the graph has cycles which means the dependencies are unresolvable (i.e. there is no order which the models can be called that will work). In this case it is possible to visually inspect the graph using
- dependency_map(ax=None, figsize=None, deep=False, style='shell')¶
Create a graph of the dependency graph in a decent format
ax (matplotlib.axis, optional) – Matplotlib axis object on which dependency map is to be drawn.
figsize (tuple, optional) – Tuple containing frame size.