GenericSelectedEventFunction#

class libcasm.monte.sampling.GenericSelectedEventFunction(
self: GenericSelectedEventFunction,
name: str,
description: str,
requires_event_state: bool,
function: Callable[[], None],
has_value_function: Callable[[], bool] = None,
order: int = 0,
)#

Bases: pybind11_object

A generic function that will be evaluated after selecting an event and before collecting data about the event.

Notes

These functions can:

  • request to have the event state of the selected event calculated,

  • be customized to only evaluate after particular event types are selected, and

  • be evaluated before selected event data collection functions are evaluated, in user-specified order.

Constructor

Parameters:
  • name (str) – Name of the sampled quantity.

  • description (str) – Description of the function.

  • requires_event_state (bool) – If true, the function requires the event state of the selected event to be calculated.

  • function (function) – A function with 0 arguments that returns nothing. Typically this is a lambda function that has been given a reference or pointer to a Monte Carlo calculation object so that it can access the last selected event state and the Monte Carlo state before the event occurs. It may print information, perform calculations, modify a data structure used by other functions, etc.

  • has_value_function (Optional[function] = None) – An optional function with 0 arguments that returns a bool indicating that the value of function should be collected. Default is to always return True. Typically this is a lambda function that has been given a reference or pointer to a Monte Carlo calculation object so that it can access the current selected event and determine if a value should be collected.

  • order (int = 0) – Order in which the function is evaluated. Functions with lower order are evaluated first. If two functions have the same order, they are evaluated in lexicographical order by function name.

Methods

Attributes

description

Description of the function.

function

The function to be evaluated.

has_value_function

A function that returns a bool indicating that the value of function should be collected.

name

Name of the function.

order

Order in which generic functions are evaluated, starting with the lowest number, and breaking ties by comparing function names lexicographically.

requires_event_state

If True, the function requires the event state of the selected event to be calculated.