Classes

Model Classes

FairModel

FairMetaModel

FairCalculations

FairDataInput

FairDependencyNode

class pyfair.model.model_node.FairDependencyNode(name)

Represents the status of a given calculation for FairDependencyTree

FairModel has a captive FairDependencyTree, and a FairDependencyTree is made of FairDependencyNodes. It is a simple structure that holds a status tag, and related nodes to allow for traversing the tree stucture.

Parameters:

name (str) – A human-readable designation for identification.

name

A human-readable designation for identification.

Type:

str

parent

The single node immediately above the current node in the tree (default is None).

Type:

pyfair.model.FairDependencyNode

children

A list of the child nodes below the node in the tree (default is an empty list).

Type:

list

status

‘Calculated’} An identifier that gives the status of the node (default is ‘Required’).

Type:

{‘Required’, ‘Not Required’, ‘Supplied’, ‘Calculable’,

add_child(child)

Add a child to an individual node (orchestated by tree)

Parameters:

child (pyfair.model.FairDependencyNode) – A node to attach as a child

add_parent(parent)

Add a parent to an individual node (orchestated by tree)

Parameters:

parent (pyfair.model.FairDependencyNode) – A node to attach as a parent

FairDependencyTree

class pyfair.model.model_tree.FairDependencyTree

A captive class tracking FAIR calculation dependencies.

An instance of this class is created when a FairModel is instantiated. It is used to during the lifetime of the FairModel to track what data has been supplied to the model. Consequently it can be used to determine what further data is needed and what calculations can be performed.

It is created from a group of nodes of type FairDependencyNode. When data is supplied, information is propogated down the tree and then up the tree when performing calculations. On its own, it is pretty dumb. The FairModel tells the tree what to do.

nodes

A dict with name string key and a FairDependencyNode value

Type:

dict

Notes

http://pubs.opengroup.org/onlinepubs/9699919899/toc.pdf

calculation_completed()

Determine whether the model has been completed

Returns:

True if the calculation is complete, otherwise False

Return type:

bool

get_node_statuses()

Simple getter to obtain node statuses.

Returns:

A dict with keys of node names and values of node statuses

Return type:

dict

ready_for_calculation()

Ensure there are no required items remaining

Returns:

True if model is ready for calculation, otherwise False

Return type:

bool

update_status(node_name, new_status)

Notify node that data was provided

This function notifies the node that the status has changed and then propogates data down the tree as necessary. For example, if data is supplied for a node, then all nodes underneath it are no longer required. The nodes are recursively updated to the bottom of the tree.

In addition, information is also propgated up the tree. For example, if two nodes are calculabe (in other words, can be calculated), they can be calculated. In addition, if the calculation makes it possible for other nodes to be calculated, those will be calculated up the tree.

Parameters:
  • node_name (str) – The node in self.nodes that will be updated

  • new_status (str) – The new status with which to update the node

Example

>>> # usually captive, but we're instantiating here
>>> tree = FairDependencyTree()
>>> # This will update nodes below (and above)
>>> tree.update_status('Loss Event Frequency', 'Supplied')
>>> tree.update_status('Loss Magnitude', 'Supplied')

Report Classes

FairSimpleReport

FairBaseReport

FairBaseCurve

FairDistributionCurve

FairExceedenceCurves

FairTreeGraph

FairViolinPlot

Utility Classes

FairException

FairBetaPert

FairModelFactory

FairDatabase