oasislmf.pytools.fm.compute_sparse

Attributes

Functions

get_base_children(node, children, nodes_array, ...)

fill up temp_children_queue with all the base children of node from index 0 and return the number of base children

first_time_layer(profile_len, base_children_len, ...)

first time there is a back allocation with multiple layer, we duplicate loss and extra from layer 1 to the other layers

first_time_layer_extra(profile_len, base_children_len, ...)

first time there is a back allocation with multiple layer, we duplicate loss and extra from layer 1 to the other layers

aggregate_children_extras(node, len_children, ...)

aggregate the loss and extra of the children of the node that is currently computed

aggregate_children(node, len_children, nodes_array, ...)

aggregate the loss of the children of the node that is currently computed

set_parent_next_compute(parent_id, child_id, ...)

Set the parent node that needs to be computed at the next level

load_net_value(computes, compute_idx, nodes_array, ...)

compute_event(compute_info, keep_input_loss, ...)

compute an entire event, result losses are stored inplace in loss_val

init_variable(compute_info, max_sidx_val, temp_dir, ...)

extras, loss contains the same index as sidx

reset_variable(children, compute_idx, computes)

reset the per event array

Module Contents

oasislmf.pytools.fm.compute_sparse.logger[source]
oasislmf.pytools.fm.compute_sparse.get_base_children(node, children, nodes_array, temp_children_queue)[source]

fill up temp_children_queue with all the base children of node from index 0 and return the number of base children Args:

node: top node children: array of all the children with loss value for each node nodes_array: array of information on all nodes temp_children_queue: empty array where we write base children.

Returns:

number of base children

oasislmf.pytools.fm.compute_sparse.first_time_layer(profile_len, base_children_len, temp_children_queue, compute_idx, nodes_array, sidx_indptr, sidx_indexes, loss_indptr, loss_val)[source]

first time there is a back allocation with multiple layer, we duplicate loss and extra from layer 1 to the other layers

oasislmf.pytools.fm.compute_sparse.first_time_layer_extra(profile_len, base_children_len, temp_children_queue, compute_idx, nodes_array, sidx_indptr, sidx_indexes, loss_indptr, loss_val, extras_indptr, extras_val)[source]

first time there is a back allocation with multiple layer, we duplicate loss and extra from layer 1 to the other layers

oasislmf.pytools.fm.compute_sparse.aggregate_children_extras(node, len_children, nodes_array, children, temp_children_queue, compute_idx, temp_node_sidx, sidx_indexes, sidx_indptr, sidx_val, all_sidx, temp_node_loss, loss_indptr, loss_val, temp_node_extras, extras_indptr, extras_val)[source]

aggregate the loss and extra of the children of the node that is currently computed Args:

node: node that we compute len_children: number of children of the node nodes_array: array of information on all nodes children: array of all the children with loss value for each node temp_children_queue: array storing all the base children of the node compute_idx: single element named array containing all the pointer needed to tract the computation (compute_idx_dtype) temp_node_sidx: dense array to store if sample id has value for this node sidx_indexes: index of sidx for nodes sidx_indptr: : index to sidx pointer sidx_val: sidx values all_sidx: list of all sidx in this computation temp_node_loss: dense array storing the sum of children loss loss_indptr: index to the loss pointer loss_val: loss values temp_node_extras: dense array storing the sum of children extra extras_indptr: index to the extra pointer extras_val: extra values

oasislmf.pytools.fm.compute_sparse.aggregate_children(node, len_children, nodes_array, children, temp_children_queue, compute_idx, temp_node_sidx, sidx_indexes, sidx_indptr, sidx_val, all_sidx, temp_node_loss, loss_indptr, loss_val)[source]

aggregate the loss of the children of the node that is currently computed Args:

node: node that we compute len_children: number of children of the node nodes_array: array of information on all nodes children: array of all the children with loss value for each node temp_children_queue: array storing all the base children of the node compute_idx: single element named array containing all the pointer needed to tract the computation (compute_idx_dtype) temp_node_sidx: dense array to store if sample id has value for this node sidx_indexes: index of sidx for nodes sidx_indptr: : index to sidx pointer sidx_val: sidx values all_sidx: list of all sidx in this computation temp_node_loss: dense array storing the sum of children loss loss_indptr: index to the loss pointer loss_val: loss values

oasislmf.pytools.fm.compute_sparse.set_parent_next_compute(parent_id, child_id, nodes_array, children, computes, compute_idx)[source]

Set the parent node that needs to be computed at the next level Args:

parent_id: id of the parent child_id: id of the child nodes_array: array of information on all nodes children: array of all the children with loss value for each node computes: array of node that need to be computed. compute_idx: single element named array containing all the pointer needed to tract the computation (compute_idx_dtype)

oasislmf.pytools.fm.compute_sparse.load_net_value(computes, compute_idx, nodes_array, sidx_indptr, sidx_indexes, loss_indptr, loss_val)[source]
oasislmf.pytools.fm.compute_sparse.compute_event(compute_info, keep_input_loss, nodes_array, node_parents_array, node_profiles_array, len_array, max_sidx_val, sidx_indexes, sidx_indptr, sidx_val, loss_indptr, loss_val, extras_indptr, extras_val, children, computes, compute_idx, item_parent_i, fm_profile, stepped)[source]

compute an entire event, result losses are stored inplace in loss_val Args:

compute_info: general information on the computation (financial_structure.compute_info_dtype) keep_input_loss: if true compute the net loss instead of the insured loss nodes_array: array of information on all nodes node_parents_array: array of node to parent node node_profiles_array: array of profile for each node len_array: length of array needed to store loss and extra as dence array max_sidx_val: maximum sidx value sidx_indptr: index to sidx pointer sidx_indexes: index of sidx for nodes sidx_val: sidx values loss_indptr: index of loss for nodes loss_val: loss values extras_indptr: index of extra for nodes extras_val: extra values children: array of all the children with loss value for each node computes: array of node that need to be computed. it is filled up as the computation carries on compute_idx: single element named array containing all the pointer needed to tract the computation (compute_idx_dtype) item_parent_i: each node may have multiple parent that are selected one after another. This array keeps track of which parent index to select fm_profile: array of all the profiles stepped: (True or None) determine if this computation contain stepped profile (using None instead of False to allow jit compilation)

oasislmf.pytools.fm.compute_sparse.init_variable(compute_info, max_sidx_val, temp_dir, low_memory)[source]

extras, loss contains the same index as sidx therefore we can use only sidx_indexes to tract the length of each node values

oasislmf.pytools.fm.compute_sparse.reset_variable(children, compute_idx, computes)[source]

reset the per event array Args:

children: array of all the children with loss value for each node compute_idx: single element named array containing all the pointer needed to tract the computation (compute_idx_dtype) computes: array of node to compute